Linux offers a range of options to check your system’s IP address. Besides GUI network manager based on the Linux distribution, there is a set of common CLI commands that are mostly supported across different distributions by default. So, we’ll be covering such commands.
ip Command
ip command has a lot of options. To list all network interfaces, use ip a command or specify the name of the network interface as shown below.
$ ip addr show eth0 6: eth0: mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:15:5d:8c:b4:c4 brd ff:ff:ff:ff:ff:ff inet 172.23.120.4/20 brd 172.23.127.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::215:5dff:fe8c:b4c4/64 scope link valid_lft forever preferred_lft forever $
hostname Command
hostname command with -I flag can list down all IPs attached to your different network interfaces.
$ hostname -I 172.23.120.4 10.42.0.0 10.42.0.1 $
ifconfig Command
Like ip command, ifconfig used to be the default command for viewing/modifying network parameters in a Linux system though it is still supported by a lot of distributions. You can use ifconfig -a to view all network adapters and their IPs or to specify a specific network interface with ifconfig use:
$ ifconfig eth0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.23.120.4 netmask 255.255.240.0 broadcast 172.23.127.255 inet6 fe80::215:5dff:fe8c:b4c4 prefixlen 64 scopeid 0x20<link> ether 00:15:5d:8c:b4:c4 txqueuelen 1000 (Ethernet) RX packets 1339936 bytes 1152733066 (1.1 GB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 393472 bytes 333379281 (333.3 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 $