Sub topic 2
Inspecting What the Server Is Using Now
Before changing a server's network settings, inspect its current state. This chapter assumes you can use a Linux shell, edit files, run commands with sudo, and understand basic IPv4 addresses, subnets, and default gateways. You should also have console or out-of-band access if the server is remote.
Inspection gives you a reference point. It helps you identify the correct network interface, understand how traffic currently leaves the server, and avoid replacing a working setting with an incorrect one.
Read the current network state
Run these commands before editing any configuration:
ip -br address show
ip route show default
hostnamectl
resolvectl statusThe ip command is the main tool for viewing addresses and routes.
ip -br address showdisplays interfaces and their addresses in a compact format.ip route show defaultdisplays the default route. The route usually points to the local router, called the default gateway.hostnamectldisplays the system hostname and related operating system details.resolvectl statusdisplays DNS resolver settings, including DNS servers and search domains.
An example address might be 192.168.1.50/24. The /24 is the prefix length. It means that the first 24 bits identify the local network. A server with address 192.168.1.50/24 normally treats addresses from 192.168.1.0 through 192.168.1.255 as local.
The default route determines where packets go when no more specific route exists. An example route might look like this:
default via 192.168.1.1 dev enp1s0This means that traffic for other networks leaves through gateway 192.168.1.1 on interface enp1s0.
Identify the interface and manager
Interface names vary. Common names include enp1s0, ens160, and eth0. Do not assume the name from another server.
The configuration manager also varies by distribution and installation. Netplan commonly generates configuration for systemd-networkd or NetworkManager. NetworkManager can be inspected directly with nmcli.
nmcli device status
nmcli connection show
systemctl is-active NetworkManager
systemctl is-active systemd-networkd
ls -l /etc/netplan/Use the results together:
| Observation | Likely management path |
|---|---|
| Netplan files exist and `systemd-networkd` is active | Netplan with networkd |
| Netplan files exist and NetworkManager is active | Netplan with NetworkManager |
| NetworkManager is active and connections are listed | NetworkManager profiles |
| A different service manages the interface | Follow that service's configuration |
Do not edit a generated or runtime file without first identifying its source. A service may overwrite manual changes when it restarts.
Understand hostname and name resolution
A hostname identifies the machine. A fully qualified domain name, or FQDN, includes the host and domain, such as web01.example.com. Check both the configured and currently active hostname:
hostnamectl --static
hostname
hostname --fqdnName resolution is the process of turning a name such as example.com into an IP address. Linux commonly follows the order in /etc/nsswitch.conf. The hosts: line may include files and dns.
The files entry usually means /etc/hosts is checked first. The dns entry sends a query to the configured resolver. Inspect the relevant settings:
grep '^hosts:' /etc/nsswitch.conf
cat /etc/hosts
resolvectl statusThe resolver may receive its settings from Netplan, NetworkManager, DHCP, or another local service. Treat /etc/resolv.conf as a possible link rather than assuming it is the authoritative configuration.
Check behavior, not only configuration
A setting can look correct while traffic still fails. Test each layer separately:
ip -br address show dev enp1s0
ip route get 9.9.9.9
resolvectl query example.com
getent hosts example.com
ping -c 3 192.168.1.1ip route get shows the path the kernel would use. resolvectl query tests the system resolver. getent hosts tests name service resolution through the configured nsswitch.conf order. A gateway ping tests local reachability, although some networks block ping.
Exercise
The server has an address, but ip route get 9.9.9.9 reports “Network is unreachable.” Which current setting should you inspect first?
Show answer
Inspect the routing table with ip route show, especially for a missing or incorrect default route. Also verify that the interface is up and has the expected prefix length.