Inspecting local connectivity
On this page
A connection fails, but you do not yet know whether Linux has an address, which route it would use, or whether the other machine answers. Changing settings before reading them makes the original problem harder to understand.
By the end, you can collect those observations without changing network configuration. You can also explain why a ping reply and a listening-service report answer different questions.
Before you start
Section titled “Before you start”Finish Network vocabulary for Linux users. Work locally in ~/lab, from the B04 setup. The commands here are read-only.
The recording uses the prepared two-container lab: learner@rootvolt is local and learner@labserver is the server console. Its private Docker bridge connects two containers; it is not a home network. To reproduce the server commands, you need that prepared lab or a server you control with a known hostname and console access. Your VM does not automatically have a host called labserver.
Your IP and MAC addresses, interface names and indexes, routes, ports, and ping times will differ. Compare the fields and relationships rather than copying these values into settings.
Find the interface carrying the address
Section titled “Find the interface carrying the address”ip addressip routelearner@rootvolt:~/lab$ ip address1: lo: <LOOPBACK,UP,LOWER_UP> 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: eth0@if80: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 3e:4b:05:54:f3:21 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 172.19.0.3/16 brd 172.19.255.255 scope global eth0
valid_lft forever preferred_lft foreverlearner@rootvolt:~/lab$ ip routedefault via 172.19.0.1 dev eth0
172.19.0.0/16 dev eth0 proto kernel scope link src 172.19.0.3 learner@rootvolt:~/lab$ Steps (6)
- Type
ip address - Press Enter
- Output:
1: lo: <LOOPBACK,UP,LOWER_UP> 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: eth0@if80: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 3e:4b:05:54:f3:21 brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 172.19.0.3/16 brd 172.19.255.255 scope global eth0 valid_lft forever preferred_lft forever - Type
ip route - Press Enter
- Output:
default via 172.19.0.1 dev eth0 172.19.0.0/16 dev eth0 proto kernel scope link src 172.19.0.3
Start with the interface headings. lo is loopback; its 127.0.0.1 address refers to this container. The other heading is eth0@if80 in this capture. eth0 is the local interface name, and the suffix describes its virtual peer relationship. You do not need to type the suffix as part of the interface name.
Look under eth0 for inet, which introduces an IPv4 address. inet6 introduces IPv6. The /16 after the captured IPv4 address is a network prefix length, describing the network portion of the address. It is not a port number. The link/ether line contains the MAC address, a separate link-layer identifier.
The UP and LOWER_UP flags describe the interface’s administrative and lower-layer state. They do not prove that a distant service works. Here, the non-loopback address and route using eth0 identify the interface relevant to the lab connection. On a VM with several adapters, inspect the route for your destination rather than assuming the first listed interface is the right one.
Read the route without modifying it
Section titled “Read the route without modifying it”The default route begins with default. Its via field names the next-hop gateway; dev names the outgoing interface. The second line is a connected-network route. The server’s captured address falls in that network, so the more specific connected route applies instead of the default.
These key values repeat the wide output in a narrow form:
| Field | Captured value and role |
|---|---|
| Local IPv4 address | 172.19.0.3/16 on eth0 |
| Default route | via 172.19.0.1 dev eth0 |
| Connected network | 172.19.0.0/16 dev eth0 |
| Connected route source | 172.19.0.3 |
You have inspected configuration, not tested delivery. A route can exist while a cable, gateway, firewall, or destination prevents communication. Do not add or delete routes for this exercise.
Ask for replies from the server
Section titled “Ask for replies from the server”getent hosts labserverping -c 3 labserverss -ltngetent hosts asks the configured host-name lookup system for the name. In this prepared lab, Docker DNS supplies the server address. ping sends ICMP echo requests, which are reachability probes rather than TCP connections. -c 3 limits the run to three requests instead of leaving it running.
Predict: if all three requests receive replies, does that establish that SSH accepts a login?
Run it, then compare with your guess
learner@rootvolt:~/lab$ getent hosts labserver172.19.0.2 labserverlearner@rootvolt:~/lab$ ping -c 3 labserverPING labserver (172.19.0.2) 56(84) bytes of data.
64 bytes from labserver.rootvolt-lab (172.19.0.2): icmp_seq=1 ttl=64 time=0.709 ms
64 bytes from labserver.rootvolt-lab (172.19.0.2): icmp_seq=2 ttl=64 time=0.161 ms
64 bytes from labserver.rootvolt-lab (172.19.0.2): icmp_seq=3 ttl=64 time=0.061 ms
--- labserver ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2027ms
rtt min/avg/max/mdev = 0.061/0.310/0.709/0.284 mslearner@rootvolt:~/lab$ ss -ltnState Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.11:34055 0.0.0.0:* learner@rootvolt:~/lab$ Steps (9)
- Type
getent hosts labserver - Press Enter
- Output:
172.19.0.2 labserver - Type
ping -c 3 labserver - Press Enter
- Output:
PING labserver (172.19.0.2) 56(84) bytes of data. 64 bytes from labserver.rootvolt-lab (172.19.0.2): icmp_seq=1 ttl=64 time=0.709 ms 64 bytes from labserver.rootvolt-lab (172.19.0.2): icmp_seq=2 ttl=64 time=0.161 ms 64 bytes from labserver.rootvolt-lab (172.19.0.2): icmp_seq=3 ttl=64 time=0.061 ms --- labserver ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2027ms rtt min/avg/max/mdev = 0.061/0.310/0.709/0.284 ms - Type
ss -ltn - Press Enter
- Output:
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 4096 127.0.0.11:34055 0.0.0.0:*
No. The capture records three transmitted packets, three received packets, and zero percent loss. It tests ICMP replies, not a TCP port, SSH host identity, or account authentication.
The destination resolves to 172.19.0.2 here. The reply times are measurements for this private-container run, not performance targets. A reply demonstrates that a request and response traveled successfully at that moment.
An unanswered ping alone does not prove a host is down. ICMP can be filtered or disabled while a service remains reachable. A missing reply can also have several other causes. This capture received replies; it does not contain a staged timeout or blocked-ICMP experiment.
Check listeners on the machine that owns them
Section titled “Check listeners on the machine that owns them”ss reports socket information. The options in ss -ltn mean listening (-l), TCP (-t), and numeric addresses and ports (-n). Running it locally inspects local sockets. It does not query the server’s sockets through the network. In the recording, the local table has one row: 127.0.0.11 on a high port, Docker’s internal name resolver inside the lab container. Nothing on the local machine listens on port 22 or 80.
Use the server console, learner@labserver:~$, for the same command:
ss -ltnlearner@labserver:~$ ss -ltnState Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.11:45901 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:* learner@labserver:~$ Steps (3)
- Type
ss -ltn - Press Enter
- Output:
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 4096 127.0.0.11:45901 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 5 0.0.0.0:80 0.0.0.0:* LISTEN 0 128 [::]:22 [::]:*
| Server local endpoint | Meaning in this capture |
|---|---|
0.0.0.0:22 |
SSH listens on all IPv4 addresses |
[::]:22 |
SSH also has an IPv6 listening socket |
0.0.0.0:80 |
The lab web server listens on IPv4 port 80 |
127.0.0.11:45901 |
Docker’s internal resolver-related listener; its port varies |
The wildcard peer * is not a connected client. These rows are listening sockets waiting for connections. Their presence does not prove that traffic from another machine can pass every firewall. A real client request is the next test; the following lesson retrieves a page from port 80.
Mistakes to recognize
Section titled “Mistakes to recognize”Looking for the server’s port 22 in local ss output. Read the prompt first. Local and server socket tables belong to different machines, even though both use the account name learner.
Reading state UNKNOWN on loopback as a failed internet connection. Loopback has no ordinary physical carrier state. Read the relevant non-loopback interface and route instead.
Treating zero packet loss as a complete service test. It describes these ICMP requests. It says nothing about whether an SSH account can authenticate.
Try it yourself
Section titled “Try it yourself”Goal: A server console shows a port-80 listener, but ping gets no answers. State what is established and choose the next useful test.
Solution
The server has a local TCP listener. The ping observation establishes no ICMP replies for that attempt. Neither proves the web service is reachable from the client. Try a web request from the client and inspect its result; do not conclude the server is down from ping alone.
Reset this lesson
Section titled “Reset this lesson”The probe finished after three requests. No files, background commands, or network settings were changed. The recorded reset returns to the local starting directory:
cd ~/labpwdlearner@rootvolt:~/lab$ cd ~/lablearner@rootvolt:~/lab$ pwd/home/learner/lablearner@rootvolt:~/lab$ Steps (5)
- Type
cd ~/lab - Press Enter
- Type
pwd - Press Enter
- Output:
/home/learner/lab
- Read the interface’s address separately from its MAC address and state.
- The default route is a fallback; a connected route can be more specific.
- Ping tests ICMP replies, and silence alone does not prove a host is down.
- Run ss on the machine whose listeners you need to inspect.
Next, Retrieving content tests the lab web service and saves a response.
Further reading
Section titled “Further reading”- On Ubuntu:
man ip-address,man ip-route,man getent,man ping, andman ss. - Ubuntu ip-address, ip-route, and ss manuals.
- Ubuntu ping manual.