How do I find out my IP address on Linux?
Three commands to see your Linux machine's IP: list every interface, ask the kernel which source address it really uses, and confirm it sits on the default route.
What this covers
You need your machine's IP — to let someone SSH in, to open the right subnet in a firewall, or to configure a service to listen on the right address — and the habit of typing ifconfig now just returns command not found on a modern distribution. The right tool is iproute2's ip command. This walks through it in three short moves: see every address on the box, pin down which one your traffic actually uses, and confirm it is the one on the default route, so you can give an answer with confidence instead of guessing between two interfaces.
Symptom
List every interface with its address in one table
Start here because the answer is not one value — a machine with Docker, VPN or virtual machines has several addresses, and you need to see which one sits on which interface. The compact listing prints one line per interface with its administrative state and its IPv4 and IPv6 addresses, so you can ignore loopback (127.0.0.1), link-local (fe80::…) and the bridge devices named docker0, virbr0 or veth…, and read the IPv4 address off the physical interface that shows UP — eth0, enp3s0, wlan0 or wlp2s0. If the line you need shows no IPv4 address, that interface simply has no address right now and the listing has already told you why nothing else worked.
One command that prints every interface with its state and IPv4/IPv6 addresses in a short table — the modern, memorable replacement for digging through `ifconfig` or the verbose `ip addr` output.
$ ip -br aAsk the kernel which source address it would actually use
The table gives you candidates; this step gives you the definitive one for talking to the outside world. The kernel performs a real route lookup for whatever destination you name and prints the source address it would stamp on the packet — that value in the src field is the address every other machine on the network sees as you. Put a real off-LAN destination in place of the example address, for instance a public DNS server such as 8.8.8.8; if you look up a host inside your own subnet you only learn which address reaches that subnet, which is the same answer but less convincing. If the lookup reports the route goes out via a device you did not expect (a VPN tunnel like tun0 or wg0), that is your answer for general traffic and you should report that address instead.
See exactly which interface, source address and gateway the kernel picks for a given destination — no guessing from routing tables.
$ ip route get 192.168.1.10Confirm that interface is the one holding the default route
An address is only useful if traffic actually leaves through the interface that owns it. The routing table shows a default line in the form default via <gateway> dev <interface> — the device named there must be the same interface whose address you read in step one. If it matches, your answer is settled: the address belongs to the NIC that carries all off-LAN traffic, and the gateway printed on that line is a handy sanity check that you are on the network you think you are. If it does not match, the address you found belongs to a secondary card or a bridge, and you should give the address of the interface named on the default line instead.
The routing table is the first thing to check when traffic leaves the wrong interface or the gateway seems dead — and `ip route show` is the quick, modern way to read it.
$ ip route showHow to confirm it worked
You have a private-range address (192.168.x.x, 10.x.x.x or 172.16–31.x.x) from the address table, the same address appears in the src field of the route lookup toward a public destination, and that interface is the device named on the default route line.
Sources
- ip(8) — Linux manual pageEvidence: Documents `ip -br addr` as the brief, one-line-per-interface output format of the ip command
- ip-route(8) — main IPv4/IPv6 routing table managementEvidence: Page documents the 'get' subcommand ('ip route get' — get a single route) and route attributes like via/dev/src; confirms 'ip route' and 'get' appear in the text.
- ip-route(8) — Ubuntu man pageEvidence: Man page contains the 'get' subcommand description showing it performs a route lookup and returns the resolved via/dev/src values.
Last verified: 2026-09-22
Related guides
A step-by-step problem-fix guide for Linux network trouble: check interfaces and routes, hunt packet loss along the path, reconnect Wi-Fi, and verify connectivity end to end.
Diagnose and fix DNS resolution failures on systemd-based Linux: confirm the interface has an IP, inspect the live resolver status, query the resolver directly, flush the stub cache and set known-good DNS servers.
Find the process leaking file descriptors with ss and lsof, then raise the limit with ulimit and make it persist across logins.