Source: taken from (http://offbytwo.com/2008/05/09/show-ip-address-of-vm-as-console-pre-login-message.html)

TL;DR Install with one the following lines (choose either slurdge.org, github.com or gitlab.com) as root. Feel free to checkout the source.

wget https://gitlab.com/snippets/1660984/raw -O - | sh
wget https://gist.githubusercontent.com/slurdge/1fe64837f751101015137c7d2b93ff77/raw/install_ip_prompt.sh -O - | sh
wget https://www.slurdge.org/posts/how-to-display-ip-remote-vm/install-ip-prompt.sh -O - | sh