Last active
August 29, 2015 13:57
-
-
Save guedressel/9565506 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo | |
echo | |
DEVS=($(cat /proc/net/dev | tail -n+3 | cut -d: -f1 | tr -d " ")) | |
for i in "${DEVS[@]}" | |
do | |
ip link show $i | grep -q "state DOWN" # check interface status | |
if (( $? == 1 )) | |
then | |
# interface is up | |
echo "$i:" | |
ipv4=$(ip addr show $i | grep -o -P "inet ([0-9\.]+)" | cut -d' ' -f2) | |
ipv6=$(ip addr show $i | grep "inet6 " | sed -n 's/.*inet6 \(.*\)\/.*/\1/p') | |
if [[ "$ipv4" != "" ]] | |
then | |
echo " IPv4 $ipv4" | |
fi | |
if [[ "$ipv6" != "" ]] | |
then | |
echo " IPv6 $ipv6" | |
fi | |
else | |
# interface is down | |
#echo "$i (is down)" | |
do=nothing | |
fi | |
done | |
DEFAULT_ROUTE=$(ip route | grep default | sed -n 's/default via \(.*\) dev.*/\1/p') | |
DEFAULT_ROUTE_DEV=$(ip route | grep default | sed -n 's/default via .* dev \([^ ]*\) .*/\1/p') | |
echo "default route: $DEFAULT_ROUTE (over $DEFAULT_ROUTE_DEV)" | |
echo | |
echo |
call the script in /etc/rc.local to adjust the /etc/issue file on system start:
/usr/local/bin/show_network_config.sh >> /etc/issue
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
have a look at http://askubuntu.com/questions/265072/ubuntu-linux-12-10-message-of-the-day to see how to put it into the message-of-the-day in ubuntu systems