linux virtual machines with a bridge interface, and I want to display the machine's IP address after the machine is booted (in login, it usually shows the release and kernel).
This is just a text file...you write it in the same way you would send text to the file using any other shell script. Something like this will replace /etc/issue with your ip address:
ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -f2 -d: > /etc/issue
Obviously, depending on the information you want in /etc/issue, you can make this more complex file at will.
You can write to this file using the local equivalent /etc/rc.d/rc.local (usually executed after all other startup scripts).
On CentOS 7 and Debian 8, just append the following line to /etc/issue
My IP address: \4
This will resolve to the machine’s IPv4 address. If you have multiple network interfaces and want to select a specific network interface, you can use specify it
My IP address: \4{eth0}
Check man getty for the list of escape sequences supported by your distribution.
This script will add/remove IP addresses to/from /etc/issue Submit files as needed:
#!/bin/sh
PREFIX="Local IP addresses:"
IPADDRS=$(hostname -I | tr " " "\n" | grep -v "^$" | sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tr "\n" " ")
perl -i -p -0777 -e "s/^$PREFIX[^\n]*\n\n//m; s/$/\n$PREFIX $IPADDRS\n/ if length('$IPADDRS')>6" /etc/issue
If you are using a Debian-based distribution, it is best to put the script in the following location:
/etc/network/if-up.d/update-issue
/etc/network/if-post-down.d/update-issue
In this way, the script will be executed whenever the interface appears or fails. Putting it in /etc/rc.d/rc.local has the disadvantage of only executing it once at startup.