Knowing the IP address of a Linux system is essential for troubleshooting network connectivity, configuring firewalls, and enabling remote access. It acts as the machine's numeric identity on a local network or across routed segments, allowing services and peers to reach the correct host.

On modern Linux systems, network configuration is exposed through tools from the iproute2 suite, primarily the ip utility, along with helpers such as hostname. These commands read kernel networking state and list IPv4 and IPv6 addresses attached to each interface, including wired, wireless, virtual, and tunnel devices.

IP configuration can change dynamically due to DHCP leases, VPN tunnels, containers, and multiple active interfaces, so output often contains several addresses and both IPv4 and IPv6 entries. The commands below operate in read-only mode and therefore do not alter network settings, but care is still required to choose the correct address for a specific task.

Steps to check IP address in Linux:

  1. Open a terminal on the Linux system to run shell commands.
    $ whoami
    alice
  2. Show all IP addresses assigned to the host in a single line.
    $ hostname -I
    192.168.1.42 172.17.0.1 fe80::a00:27ff:fe4e:66a1

    The first IPv4 address is commonly the primary LAN address; additional entries may represent Docker or container bridges, VPN interfaces, and IPv6 addresses.

  3. Display all network interfaces and their detailed IP configuration using ip.
    $ ip addr show
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
        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
    2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
        link/ether 08:00:27:4e:66:a1 brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.42/24 brd 192.168.1.255 scope global dynamic enp0s3
           valid_lft 86322sec preferred_lft 86322sec
    ##### snipped #####

    Focus on inet lines for IPv4 addresses and inet6 lines for IPv6; the interface name appears at the start of each block (for example enp0s3 or wlp2s0).

  4. Show a concise per-interface summary of IP addresses in a tabular view.
    $ ip -br addr
    lo               UNKNOWN        127.0.0.1/8 ::1/128
    enp0s3           UP             192.168.1.42/24 fe80::a00:27ff:fe4e:66a1/64

    The brief format is useful for quick checks or scripts where a single line per interface is easier to parse.

  5. Inspect the IP configuration of a specific interface, replacing enp0s3 with the actual interface name.
    $ ip addr show dev enp0s3
    2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
        link/ether 08:00:27:4e:66:a1 brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.42/24 brd 192.168.1.255 scope global dynamic enp0s3
           valid_lft 86322sec preferred_lft 86322sec
        inet6 fe80::a00:27ff:fe4e:66a1/64 scope link
           valid_lft forever preferred_lft forever

    Interface names often follow predictable patterns such as eth0, enp0s3, ens33, or wlp2s0 depending on the hardware and udev naming scheme.

  6. Determine the primary IPv4 address used for outbound connections by querying the route to a public IP.
    $ ip route get 1.1.1.1
    1.1.1.1 via 192.168.1.1 dev enp0s3 src 192.168.1.42 uid 1000
        cache

    The address shown after src is the IP the system uses to reach the destination, which is typically the main LAN address of the host.

  7. Verify that the selected IP address corresponds to a working network path by sending a small number of ICMP echo requests to a known reachable host.
    $ ping -c 3 192.168.1.1
    PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
    64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.432 ms
    64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.389 ms
    64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.401 ms
    
    --- 192.168.1.1 ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss
    rtt min/avg/max/mdev = 0.389/0.407/0.432/0.018 ms

    Successful replies confirm that the interface and IP address are functioning on the network; packet loss or timeouts usually indicate connectivity or routing issues.

Discuss the article:

Comment anonymously. Login not required.