Web servers and networking · Beginner · 12 min
See your server's addresses, routes and neighbours with ip
By Padding · Updated 18 Nov 2026
Ubuntu 26.04.1 LTS · iproute2 6.19
You will read your Ubuntu 26.04 server's interfaces, addresses, routes, neighbour table, error counters and DNS servers with ip and resolvectl, and save them all to a one-page network snapshot you can compare later.
On this page
When a server cannot reach something, or something cannot reach the server, the first questions are always the same. Which interfaces does it have? Which addresses are on them? Where does traffic go by default? Has the network card been dropping packets? Which DNS servers does it ask? On Ubuntu 26.04 one tool answers most of these: ip, from the iproute2 package, which is installed on every Ubuntu server.
Every command in this tutorial only reads. Nothing you run here changes an address or a route, so it is safe on a production server over SSH. At the end you will have a short script that writes all the answers into one text file, so you can take a snapshot before a change and compare it afterwards.
Interface names, addresses and counters differ from server to server, so the sample output below is "something like" what you will see, not an exact match.
Step 1 · Confirm the tool and find your main interface
Check the iproute2 version:
ip -VIt prints something like ip utility, iproute2-6.19.0, libbpf 1.6.2. Any 6.x release supports everything in this tutorial.
Most commands below need the name of the interface that carries your internet traffic. On a cloud server it is often ens3, ens5, enp1s0 or eth0. Rather than guess, ask the routing table which interface the default route uses and keep the answer in a shell variable:
IFACE=$(ip route show default | awk '{print $5; exit}')
GW=$(ip route show default | awk '{print $3; exit}')
echo "interface: $IFACE gateway: $GW"The default route line looks like default via 10.0.0.1 dev ens3 .... The third word is the gateway and the fifth is the interface, which is what the two awk commands pick out. The variables last until you close this SSH session; if you reconnect, run the three lines again.
Check it worked
The echo line prints two non-empty values, for example interface: ens3 gateway: 10.0.0.1. If either is empty, the server has no default route, which on its own explains why it cannot reach the internet. Skip ahead to the routes step.
Step 2 · List interfaces and addresses
The brief view shows one line per interface:
ip -br addrSomething like:
lo UNKNOWN 127.0.0.1/8 ::1/128
ens3 UP 203.0.113.24/24 2001:db8:41::24/64 fe80::5054:ff:fe12:3456/64
ens4 UP 10.10.0.5/24Read the three columns as name, state and addresses. Each address carries its prefix length after the slash: /24 means the first 24 bits are the network, so 203.0.113.24/24 sits on the network 203.0.113.0. The fe80:: address is IPv6 link-local and is always there when IPv6 is on; it is only usable on the local link. lo is the loopback interface and shows UNKNOWN as its state, which is normal.
For full detail on one interface:
ip addr show dev "$IFACE"Look for these words in the inet lines:
scope globalmeans a normal, routable address.scope hostis loopback only, andscope linkis link-local.dynamicmeans the address came from DHCP. Thevalid_lftandpreferred_lftvalues count down to the lease ending; the DHCP client renews it before then. A static address showsforever.secondarymarks a second address in the same network on one interface.
ip accepts short prefixes of its objects, so ip a, ip addr and ip address are the same command. Add -c for colour (ip -c -br addr) if your terminal supports it.
Check it worked
ip -4 -br addr show dev "$IFACE"You see one line for your main interface with at least one IPv4 address and a prefix length, such as 203.0.113.24/24. That is the address your server uses on that network. On many cloud servers it is a private address and the public one is mapped to it by the provider, so do not be surprised if it does not match the IP you SSH to.
Step 3 · Check the link layer
An address is no use if the cable, virtual or not, is down. ip link shows the layer below addresses:
ip -br link
ip link show dev "$IFACE"The brief output adds each interface's MAC address. The full output for one interface looks something like:
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ffWhat matters in the angle brackets:
UPmeans the interface is switched on in software.LOWER_UPmeans there is a working physical or virtual link underneath.UPwithoutLOWER_UP, often shown withNO-CARRIER, means the interface is enabled but nothing is connected: a pulled cable, a detached cloud network card or a switch port that is down.mtu 1500is the largest packet the interface sends without splitting it. Some providers and VPN links use a smaller value, such as 1450 or 1420. A mismatch shows up as connections that open but then hang on large transfers.
Interfaces you did not create, such as docker0, veth... or wg0, belong to software on the server: Docker, a VPN and so on.
Check it worked
Your main interface shows both UP and LOWER_UP, and its MTU is the value your provider documents (1500 on most networks).
Step 4 · Read the routing table
The routing table decides where every outgoing packet goes:
ip routeSomething like:
default via 203.0.113.1 dev ens3 proto dhcp src 203.0.113.24 metric 100
10.10.0.0/24 dev ens4 proto kernel scope link src 10.10.0.5
203.0.113.0/24 dev ens3 proto kernel scope link src 203.0.113.24 metric 100Each line is a destination network and how to reach it:
- The
defaultline is the route of last resort: anything that matches no other line goesviathe gateway, out of the nameddev. A server with nodefaultline can only talk to the networks listed directly. - Lines with
scope linkand noviaare networks the server is directly attached to. The kernel adds them (proto kernel) when an address is put on an interface. proto dhcpmeans the route came from the DHCP lease;proto staticmeans someone configured it, usually in Netplan.metricbreaks ties: when two routes match equally, the lower metric wins.
When several lines match, the most specific one wins. A packet for 10.10.0.9 matches both 10.10.0.0/24 and default, and the /24 is longer, so it leaves through ens4 directly.
IPv6 has its own table, shown with ip -6 route, and the IPv6 tutorial in the Next steps covers it.
Check it worked
ip route show defaultYou see exactly one default via ... dev ... line, and it names the gateway and interface you saved in the first step. Two default lines with the same metric on different interfaces is a common cause of traffic that works only some of the time.
Step 5 · Ask which way a packet would go
Reading a long routing table by eye is slow and easy to get wrong. ip route get asks the kernel to make the decision for one destination and tells you the result, without sending anything:
ip route get 1.1.1.1Something like:
1.1.1.1 via 203.0.113.1 dev ens3 src 203.0.113.24 uid 1000
cacheThis tells you the gateway, the interface and, importantly, the source address the server would put on the packet. That source address is what the other side sees, and what its firewall must allow.
Try it with an address on a private network you expect to reach directly, and with the loopback address:
ip route get 10.10.0.9
ip route get 127.0.0.1The first shows the route the kernel picks for that address: on a server with a private interface it names that interface with no via. If it shows via your public gateway instead, the private network is not configured and that traffic would go out to the internet, where it will be dropped. The second shows local 127.0.0.1 dev lo, which means the kernel delivers it to the server itself.
This matters on servers with more than one way out. A small office server in Lagos or Nairobi with fibre plus an LTE backup on prepaid data, or a cloud server with a public and a private network, can quietly send traffic over the link you did not intend. ip route get answers "which link will this use" in one line, before you find out from the data bill.
Check it worked
ip route get 1.1.1.1 names your main interface and a src address that is one of the addresses from the brief list. ip route get 127.0.0.1 starts with local.
Step 6 · See the neighbour table
Before sending a packet to the gateway, or to any machine on the same network, the server must learn that machine's MAC address. For IPv4 it uses ARP, for IPv6 neighbour discovery, and it keeps the answers in the neighbour table:
ip neighSomething like:
203.0.113.1 dev ens3 lladdr 00:00:5e:00:01:01 REACHABLE
10.10.0.7 dev ens4 lladdr 52:54:00:ab:cd:ef STALE
fe80::1 dev ens3 lladdr 00:00:5e:00:01:01 router STALEThe last word is the state of each entry:
REACHABLEwas confirmed recently.STALEwas valid a while ago and will be checked again when it is next used. This is normal, not a fault.DELAYandPROBEare being checked right now.FAILEDorINCOMPLETEmeans the server asked and nobody answered. AFAILEDentry for your gateway means the server cannot reach its gateway at all, which is a problem for your provider or the local network, not for DNS or your firewall.PERMANENTwas added by hand and never expires.
Send a little traffic to the gateway so its entry is fresh, then look at it alone:
ping -c 3 "$GW" || true
ip neigh show dev "$IFACE"Some providers' gateways do not answer ping. That is fine here: the server still has to look up the gateway's MAC address before it can send the ping, and that lookup is what you are checking. The || true stops a missing reply counting as an error.
Check it worked
The gateway's address appears in the list with an lladdr MAC address and a state of REACHABLE, STALE or DELAY. If it shows FAILED, contact your provider with that output.
Step 7 · Look for errors and drops
The kernel counts every packet each interface sends and receives, and every one it had to throw away. Show the counters:
ip -s link show dev "$IFACE"Something like:
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped missed mcast
9184411736 7032145 0 112 0 0
TX: bytes packets errors dropped carrier collsns
812630911 2210418 0 0 0 0RX is received, TX is sent. The columns to watch:
errorscounts damaged packets: bad checksums, framing problems. Any steady growth points at hardware, a cable or the virtual network, and is worth a support ticket.droppedcounts packets the kernel discarded, often because a queue was full or because the packet was for a protocol nothing on the server handles. A small number that grows slowly is common and usually harmless. A number that jumps during busy periods means the server is not keeping up.carrieron the TX side counts times the link went away while sending.
The counters start at zero when the interface comes up, so a total on its own tells you little on a server that has run for months. What tells you something is change. Read them, wait, and read them again:
ip -s link show dev "$IFACE" | grep -A1 -E 'RX:|TX:'
sleep 10
ip -s link show dev "$IFACE" | grep -A1 -E 'RX:|TX:'Add a second -s (ip -s -s link show dev "$IFACE") for a breakdown of the error types.
Check it worked
You can say, for your main interface, whether errors or dropped grew between the two readings. On a healthy server errors stays at 0 and dropped does not move in ten seconds.
Step 8 · Find your DNS servers
Addresses and routes can all be right and the server can still fail to reach example.com because name lookups fail. On Ubuntu 26.04, systemd-resolved handles DNS. Ask it which servers it uses:
resolvectl statusLook for Current DNS Server and DNS Servers under your main interface's Link section. They usually come from DHCP or from the nameservers part of your Netplan file. For a one-line-per-interface summary:
resolvectl dnsYou may notice that /etc/resolv.conf names 127.0.0.53 rather than your provider's servers:
grep nameserver /etc/resolv.confThat is expected. 127.0.0.53 is systemd-resolved's local listener: programs ask it, and it forwards the question to the real servers that resolvectl lists. Editing /etc/resolv.conf by hand is the wrong fix on Ubuntu, because the file is generated; change the DNS servers in Netplan instead.
Check it worked
resolvectl dns lists at least one DNS server address next to your main interface. If the list is empty, name lookups will fail even though ip route get shows a working route, and the static IP tutorial below shows where to set them.
Step 9 · Map old habits to new commands and save a snapshot
Many guides and colleagues still use ifconfig, route, arp and netstat from the older net-tools package, which is often not installed on a fresh Ubuntu server. The table maps each habit to its replacement. Everything in it reads only.
| Old command | Replacement | Shows |
|---|---|---|
| ifconfig | ip -br addr or ip addr | Interfaces and addresses |
| ifconfig -a | ip link | All interfaces, including down ones |
| ifconfig eth0 (RX/TX lines) | ip -s link show dev eth0 | Packet, error and drop counters |
| route -n or netstat -rn | ip route | The routing table |
| (no direct equivalent) | ip route get <address> | The route one destination would use |
| arp -n | ip neigh | The neighbour (ARP) table |
| netstat -i | ip -s link | Per-interface counters |
| netstat -tlnp | sudo ss -tlnp | Listening TCP ports and their programs |
| netstat -tan | ss -tan | All TCP connections |
ss is also part of iproute2 and has its own tutorial, linked below.
Now put the commands from this tutorial into a small script that writes everything into one file. Create a folder for it:
mkdir -p ~/network-demo
cat > ~/network-demo/snapshot.sh <<'EOF'
#!/usr/bin/env bash
# Write a read-only snapshot of this server's network state to stdout.
set -euo pipefail
iface=$(ip route show default | awk '{print $5; exit}')
echo "== host: $(hostname) taken: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
echo "== addresses"; ip -br addr
echo "== links"; ip -br link
echo "== routes"; ip route
echo "== route to 1.1.1.1"; ip route get 1.1.1.1 || echo "no route"
echo "== neighbours"; ip neigh
echo "== counters for $iface"; ip -s link show dev "$iface"
echo "== dns"
resolvectl dns 2>/dev/null || grep nameserver /etc/resolv.conf
EOF
chmod +x ~/network-demo/snapshot.shThe script only calls the read-only commands you have already used. If resolvectl is not available, it falls back to the nameserver lines in /etc/resolv.conf.
Run it and save the result:
~/network-demo/snapshot.sh > ~/network-demo/before.txt
cat ~/network-demo/before.txtBefore your next network change, such as a new Netplan file, a firewall change or a provider migration, run it again into after.txt and compare the two with diff ~/network-demo/before.txt ~/network-demo/after.txt. The timestamp and counter lines always differ; any other line that changed is something your change did.
Check it worked
grep -c '^== ' ~/network-demo/before.txtThe count is 8, one for each section, and before.txt shows your main interface, a default via line, the counters and at least one DNS server. Keep the folder if you want to use the script again; otherwise remove it with rm -r ~/network-demo.
Next steps
You can now answer the first questions in any network fault from the server itself, and you have a snapshot to compare against.
- Make sense of the prefix lengths and private ranges you saw: /tutorials/understand-ip-addresses-subnets-and-cidr
- Set a fixed address, routes and DNS servers on purpose: /tutorials/configure-a-static-ip-with-netplan
- Find which program owns a port: /tutorials/find-what-is-listening-on-a-port-with-ss
- Follow traffic beyond your gateway: /tutorials/trace-the-network-path-with-traceroute-and-mtr
- Read the IPv6 addresses and routes you saw: /tutorials/ipv6-basics-for-server-admins
Related tutorials
- Write Nginx location blocks that match what you expectYou will build a practice Nginx 1.30 server where every location block labels its responses, predict which block answers each of twelve URLs, check your answers with curl, and fix the alias, regex-order and proxy_pass mistakes that catch most people out.
- Write a server firewall with nftablesYou will write one /etc/nftables.conf with a default-drop input chain, rate-limited SSH, named address sets, counters and logging, and load it over SSH behind a timer that undoes it if you lose your connection.
- Watch a TCP connection open and close with tcpdumpYou will capture a curl request to a local web server with tcpdump on Ubuntu 26.04, read its handshake, data and teardown line by line, see the reset a closed port sends, and save, filter and rotate captures as pcap files.
Need this done for you?
Padding does this work for growing companies, from the first diagnosis to a system that keeps working.
Get new tutorials