Commands to Verify TCP/IP Configuration On Linux (Ubuntu)

On Windows OS, the ipconfig command can be used to verify IP addresses and other TCP/IP configuration ; on Linux, a combination of several commands can be used to verify that the TCP/IP is properly configured.

The following table summarizes the commands and what can be verified.

Verification contentsCommand
IP address / subnet mask
MAC address
ifconfig
ip addr show
Default Gatewayip route show
IP address of DNS Serversystemd-resolve –status
Table Commands to Verify TCP/IP Configuration On Linux (Ubuntu)

The following section provides an overview of the commands and examples.

The command logs are taken from Ubuntu 18.04.3 LTS.


Verifying IP address/subnet mask and MAC address

ifconfig

To verify the IP address on Linux, use the ifconfig command from the terminal. ifconfig command not only tells you the IP address, but also the MAC address.

ifconfig

gene@ubuntu:~$ ifconfig
ens33: flags=4163  mtu 1500
        inet 192.168.1.194  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::8f2:65d7:6b13:ae31  prefixlen 64  scopeid 0x20
        ether 00:0c:29:af:c5:51  txqueuelen 1000  (イーサネット)
        RX packets 472399  bytes 47229895 (47.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2438  bytes 230150 (230.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (ローカルループバック)
        RX packets 635  bytes 49330 (49.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 635  bytes 49330 (49.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

The ifconfig command may not be installed. In that case, install the ifconfig command with the following command.

Installing the ifconfig command

$ sudo apt install net-tools

ip addr show

Alternatively, the ip addr show command will also give you the IP address and MAC address.

ip addr show

gene@ubuntu:~$ 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: ens33:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:af:c5:51 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.194/24 brd 192.168.1.255 scope global dynamic noprefixroute ens33
       valid_lft 86118sec preferred_lft 86118sec
    inet6 fe80::8f2:65d7:6b13:ae31/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

The “ip addr show” can be abbreviated with just “ip a”.

Verifying the default gateway

The default gateway is verified with the ip route show command. The “default” is “0.0.0.0.0/0”, i.e., the default route, and the IP address after “via” is the IP address of the default gateway.

ip addr show

gene@ubuntu:~$ ip route show
default via 192.168.1.1 dev ens33 proto dhcp metric 100 
169.254.0.0/16 dev ens33 scope link metric 1000 
192.168.1.0/24 dev ens33 proto kernel scope link src 192.168.1.194 metric 100 

The “ip route show” can be abbreviated with just “ip r”.

Verifying DNS servers

The IP address of the DNS server is verified with the systemd-resolv –status command.

systemd-resolv –status

gene@ubuntu:~$ systemd-resolve --status
Global
          DNSSEC NTA: 10.in-addr.arpa
-- omitted --

Link 2 (ens33)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 8.8.8.8