Skip to content

Instantly share code, notes, and snippets.

@tankibaj
Last active July 29, 2021 12:35
Show Gist options
  • Save tankibaj/747db19ed6acd70e526208f26e5a8792 to your computer and use it in GitHub Desktop.
Save tankibaj/747db19ed6acd70e526208f26e5a8792 to your computer and use it in GitHub Desktop.

IP ADDRESS :

ip addr show |grep -w inet |grep -v 127.0.0.1|awk '{ print $2}'| cut -d "/" -f 1
Output : 192.168.16.30

PREFIX (Netmask in CIDR Notation) :

ip addr show |grep -w inet |grep -v 127.0.0.1|awk '{ print $2}'| cut -d "/" -f 2
Output : 24

Broadcast IP :

ip addr show |grep -w inet |grep -v 127.0.0.1|awk '{ print $4}'
Output : 192.168.16.255

Device name :

ip addr show |grep -w inet |grep -v 127.0.0.1|awk '{ print $7}'
Output : eth0

IPv6 ADDRESS :

ip addr show |grep -w inet6 |grep -v ::1|awk '{ print $2}'| cut -d "/" -f 1
Output : fe80::222:15ff:fef6:55e6

IPv6 PREFIX (Netmask in CIDR Notation) :

ip addr show |grep -w inet6 |grep -v ::1|awk '{ print $2}'| cut -d "/" -f 2
Output : 64

Ethernet Card MAC Address :

ip addr show | grep -w ether | awk '{ print $2 }'
Output : 00:22:15:f6:55:e6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment