I work with a lot of virtual machines. For testing and preproduction set up.

I would like the login promt or header to display the ip address of the machine. That way when I start it up I can see what IP I will be ssh into. Our network works uses a DHCP. So it can change between boot up.

$ cat /etc/issue
Ubuntu 11.04 \n \l

Which comes up as

Ubuntu 11.04 [hostname] tty[x]

I want it to come up as

Ubuntu 11.04 [hostname] tty[x] ip xxx.xxx.xxx.xxx

I was think about writing an init / upstart script. Is there a better way.

link|improve this question

feedback

1 Answer

up vote 1 down vote accepted

Getty does not know machine's ip addresses. But this question was already asked at serverfault. Here's the accepted answer:

It's just a text file...you write to it the same way you'd send text to a file with any other shell script. Something like this would replace /etc/issue with just your ip address:

ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -f2 -d: > /etc/issue

Obviously you can make this arbitrarily more complex, depending on what information you want in your /etc/issue file.

You can write to this file in your local equivalent of /etc/rc.d/rc.local (which typically executes after all the other startup scripts).

Also, beware that the file /etc/issue.net is used for remote logins so you may want to edit that as well.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.