Skip to content

Instantly share code, notes, and snippets.

@hoangdh
Last active March 5, 2019 08:52
Show Gist options
  • Save hoangdh/f3130550ead2267bba7c0ee439414280 to your computer and use it in GitHub Desktop.
Save hoangdh/f3130550ead2267bba7c0ee439414280 to your computer and use it in GitHub Desktop.
Get interface's name with IP Address.
#!/bin/bash
# ifs=`ifconfig -a | grep "flags=" | cut -d":" -f1 | sort -u`
for x in `ifconfig -a | grep "flags=" | cut -d":" -f1 | sort -u` # $ifs
do
IP=`ip -f inet -o addr show $x | cut -d\ -f 7 | cut -d/ -f 1`
if [ -z "$IP" ]
then
echo "${x}: Not connected."
else
echo "${x}: $IP"
fi
done
@hoangdh
Copy link
Author

hoangdh commented Mar 5, 2019

Xoá IP trên Interface: ip addr flush dev XXX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment