This script will add/remove IP addresses to/from the
/etc/issue file as needed:
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're using a Debian-based distro, it's best to place the script at these locations:
This way the scripts are executed everytime an interface comes up or goes down. Placing it in
/etc/rc.d/rc.local has the disadvantage of beeing executed only one time during bootup.