This article will go through how to check IP addresses using IP command in Linux. IP is an abbreviation of Internet Protocol, a unique address used to identify computers on the internet. Let us look at several IP command examples used to check IP addresses.
IP Command in Linux
- To check your IP address, run the
ip address
command below.
ip address
Sample output
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: ens33: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:c3:bb:0f brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.171.144/24 brd 192.168.171.255 scope global dynamic noprefixroute ens33 valid_lft 1481sec preferred_lft 1481sec inet6 fe80::b75c:74e1:9a32:d195/64 scope link noprefixroute valid_lft forever preferred_lft forever
- Alternatively, you use the shortened version of it as shown below.
ip addr
Sample output
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: ens33: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:c3:bb:0f brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.171.144/24 brd 192.168.171.255 scope global dynamic noprefixroute ens33 valid_lft 1306sec preferred_lft 1306sec inet6 fe80::b75c:74e1:9a32:d195/64 scope link noprefixroute valid_lft forever preferred_lft forever
- We can even use the shortened version to check IP addresses.
ip a
Sample output
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: ens33: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:c3:bb:0f brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.171.144/24 brd 192.168.171.255 scope global dynamic noprefixroute ens33 valid_lft 1191sec preferred_lft 1191sec inet6 fe80::b75c:74e1:9a32:d195/64 scope link noprefixroute valid_lft forever preferred_lft forever
- To only display IPv4 use the command below.
ip -4 a
Sample output
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: ens33: mtu 1500 qdisc fq_codel state UP group default qlen 1000 altname enp2s1 inet 192.168.171.144/24 brd 192.168.171.255 scope global dynamic noprefixroute ens33 valid_lft 1146sec preferred_lft 1146sec
- To output only IPv6, use the following command.
ip -6 a
Sample output
1: lo: mtu 65536 state UNKNOWN qlen 1000 inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: mtu 1500 state UP qlen 1000 inet6 fe80::b75c:74e1:9a32:d195/64 scope link noprefixroute valid_lft forever preferred_lft forever
You can also print each record on a single line;
ip -o a
Sample output;
1: lo inet 127.0.0.1/8 scope host lo\ valid_lft forever preferred_lft forever 1: lo inet6 ::1/128 scope host \ valid_lft forever preferred_lft forever 2: wlp0s20f3 inet 192.168.10.7/24 brd 192.168.10.255 scope global dynamic noprefixroute wlp0s20f3\ valid_lft 50107sec preferred_lft 50107sec 2: wlp0s20f3 inet6 fe80::11b6:b2:7010:8e94/64 scope link noprefixroute \ valid_lft forever preferred_lft forever 3: virbr0 inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0\ valid_lft forever preferred_lft forever 5: virbr1 inet 192.168.200.1/24 brd 192.168.200.255 scope global virbr1\ valid_lft forever preferred_lft forever
- You have reached the end of our guide, we have gone through how to check IP addresses using IP command in Linux.
Read more about IP Command