Skip to content

Find Local Network IP

This process how to find the LAN IPv4 address of a Linux machine and make sense of the shell outputs. A typically use case for this is to get the address to connect over SSH.

Ask the kernel which interface and source address it would use to reach the public internet. The src field is the IP this machine presents on the LAN.

Terminal window
ip route get 1.1.1.1

Example output:

Terminal window
1.1.1.1 via 192.168.1.1 dev wlp4s0 src 192.168.1.4

The src 192.168.1.4 is the LAN IP. dev wlp4s0 is the active interface.

Two single-line commands that filter to the relevant addresses without parsing full ip a output.

Terminal window
ip -4 addr show scope global
hostname -I

When you need to see all interfaces run ip a and look for the inet line on the active interface.

Terminal window
ip a

Example excerpt for a wired desktop:

Terminal window
enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP>
inet 192.168.1.6/24 brd 192.168.1.255 scope global dynamic noprefixroute enp4s0

Reading the line:

  • enp4s0 is the wired Ethernet interface (en* = Ethernet, wl* = Wi-Fi, lo = loopback).
  • UP means the interface is enabled, LOWER_UP means the physical link is active.
  • scope global means it is a real network address, not loopback.
  • dynamic means the IP was assigned by DHCP from the router.
  • 192.168.1.6 is the LAN IP is the address to use for SSH from another machine.

Several interfaces show up in ip a but are not the address you want for SSH from another machine.

  • lo / 127.0.0.1 is a loopback. It points back to the same machine, unreachable from outside.
  • docker0, br-…, veth… are Docker / container networks. Typically in 172.17-172.19.x.x.
  • virbr0 is virtual machine bridge, often 192.168.122.x.

The address you want is the IPv4 on the real active LAN interface which is usually 192.168.1.x or similar, on en* (wired) or wl* (Wi-Fi).

From the other machine that will be doing the SSH, ping the discovered IP first to confirm basic reachability before trying to connect.

Terminal window
ping 192.168.1.6
ssh your-user@192.168.1.6