Linux Intermediate 07 — IP Addresses, Routes, and Name Resolution

Linux course index · Linux Intermediate category · Lesson 7 of 9

AI disclosure — AI-generated content, posted as is. AI can make mistakes. This lesson draws on the linked Open Education posts and adds original explanations or lab examples where useful. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.

Learning goal

Separate the problems of link state, addressing, routing, name resolution, and listening services.

Concepts and setup

The site’s networking posts compare legacy ifconfig and modern ip commands, and show a Netplan static-address example. This lab inspects live settings without changing them. Save a snapshot and use the VM console before remote address changes. An interface may be up without an IPv4 address, and a hostname may fail while a numeric IP still works.

A host-only network is suitable for services that must not leak onto a shared LAN. A separate NAT adapter can give the VM package access. Track which adapter handles each role.

Trace a route and inspect name resolution

ip -br link
ip -br address
ip route show default
ip route get 198.51.100.20
getent hosts localhost
ss -ltn

Possible output

lo               UNKNOWN ...
enp0s3           UP ...
lo               UNKNOWN        127.0.0.1/8 ::1/128
enp0s3           UP             10.0.2.15/24
default via 10.0.2.2 dev enp0s3
198.51.100.20 via 10.0.2.2 dev enp0s3 src 10.0.2.15 ...
::1             localhost
State  Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0      128        127.0.0.1:8000      0.0.0.0:*

198.51.100.20 is a documentation address. ip route get asks the kernel what it would choose and does not send traffic. ss -ltn shows local TCP listeners without resolving names.

Read-only persistence checks on a managed system

# Ubuntu using Netplan, where installed:
sudo netplan get
# Red Hat-family using NetworkManager, where installed:
nmcli device status

Possible output

network:
  version: 2
  ethernets:
    enp0s3:
      dhcp4: true
...
DEVICE   TYPE      STATE      CONNECTION
ens33    ethernet  connected  lab-nat

Use the command for your lab, not both blindly. Before modifying a remote host, plan console access. On Ubuntu, netplan try can offer a timed configuration rollback, but do not rely on it as your only recovery path.

Questions only

Quick-check questions

  1. What does a default route do?
  2. Does a listener on 127.0.0.1 accept connections from another VM?

Assessment questions

  1. A client reaches a numeric server address but not its hostname. What would you check?
  2. What command shows which outgoing interface the kernel would choose?
  3. Show evidence that a connection refusal is from a missing listener rather than a guess.

Questions and answers

Quick-check answers

  1. What does a default route do?
    Answer — It is the fallback route when a more specific route does not match.
  2. Does a listener on 127.0.0.1 accept connections from another VM?
    Answer — Not directly. The 127.0.0.1 address is loopback in that host’s network namespace.

Assessment answer key

  1. A client reaches a numeric server address but not its hostname. What would you check?
    Answer — Compare getent hosts for the real hostname with the intended resolver configuration and DNS response. Check /etc/hosts and resolver precedence as relevant.
  2. What command shows which outgoing interface the kernel would choose?
    Answer — ip route get ADDRESS. Substitute the real destination for your lab.
  3. Show evidence that a connection refusal is from a missing listener rather than a guess.
    Answer — Check ss -ltn on the server for the intended address and port. Then correlate the client attempt and server state. A firewall can also reject a connection.

Source articles on this site

Continue the course

Previous lesson 06 — Boot, Services, Logs, and Timers. Next lesson 08 — SSH Keys, Host Identity, and File Transfer.

Linux course index · Linux Intermediate category · Lesson 7 of 9

Leave a Reply