How to display ip on a remove vm before login

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

This is mainly useful when you boot up a WM with a remote console and want to switch to ssh for connection.

First, create a script in /usr/local/bin/get-ip-address with the following contents:

/sbin/ifconfig | grep "inet addr" | grep -v "127.0.0.1" | awk '{ print $2 }' | awk -F: '{ print $2 }'

Then add the following script to /etc/network/if-up.d/show-ip-address with the following contents:

#!/bin/sh
if [ "$METHOD" = loopback ]; then
    exit 0
fi

# Only run from ifup.
if [ "$MODE" != start ]; then
    exit 0
fi

cp /etc/issue-standard /etc/issue
echo "IP Address: " >> /etc/issue
/usr/local/bin/get-ip-address >> /etc/issue
echo "" >> /etc/issue

You need to copy your standard issue to a copy and fix rights:

sudo cp /etc/issue /etc/issue-standard
sudo chmod +x /usr/local/bin/get-ip-address
sudo chmod +x /etc/network/if-up.d/show-ip-address

it will give you a simple prompt like this one:

Example of IP display

That’s all folks!