You may have seen the ip command page on this website, and even used ip addr show version of it. Here's a few more really powerful options for ip.
Show Only IPv4 Addresses with ip command
If default ip addr show (or ip a for short) is too much information:
greys@becky:~ $ ip addr show
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:b5:fb:da brd ff:ff:ff:ff:ff:ff
inet 192.168.1.66/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::ba27:ebff:feb5:fbda/64 scope link
valid_lft forever preferred_lft forever
…just specify the -4 option (short for IPv4) to only show IPv4 addresses info:
greys@becky:~ $ ip -4 addr show
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 192.168.1.66/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
Show Specific Interface with ip command
To further narrow it down and show just info for one of the interfaces, specify it in the command line:
greys@becky:~ $ ip -4 addr show dev eth0
2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 192.168.1.66/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
Show Brief Summary using ip command
Just specify -br option to see just bare essentials for the specified interfaces (or all of them if you're not indicating interface name) – you'll get interface name, status (whether it's UP or DOWN right now) and the assigned IP address:
greys@becky:~ $ ip -br -4 addr lo UNKNOWN 127.0.0.1/8 eth0 UP 192.168.1.66/24
If I want to just show this for eth0, here's how I do it
greys@becky:~ $ ip -br -4 addr show dev eth0 eth0 UP 192.168.1.66/24
That's useful enough to learn in case ifconfig command is not found or you simply want to use ip command instead of ifconfig command a bit more.
Leave a Reply