Scope: Debian-based and RHEL-based Linux distributions
Topics: Interface inspection, links, routes, neighbors, sockets, hostname configuration, netplan, NetworkManager, and verification.
1. Inspect Network Interfaces#
List all interfaces and addresses:
ip addr showUse the compact view:
ip -br addrExpected output:
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0 UP 192.0.2.10/24 fe80::a00:27ff:fe1a:2b3c/642. Inspect and Change the Link State#
Show link state and MAC addresses:
ip link showBring an interface up:
sudo ip link set <INTERFACE> up3. Inspect Routes#
Show the routing table:
ip route showExpected output:
default via 192.0.2.1 dev eth0
192.0.2.0/24 dev eth0 proto kernel scope link src 192.0.2.10Check which route a destination uses:
ip route get <TARGET_IP>4. Inspect Neighbors#
Show the ARP/NDP neighbor table:
ip neigh showExpected output:
192.0.2.1 dev eth0 lladdr 00:11:22:33:44:55 REACHABLE5. Inspect Listening Ports#
List listening TCP and UDP sockets with owning processes:
ss -tulpnExpected output:
Netid State Local Address:Port Process
tcp LISTEN 0.0.0.0:22 users:(("sshd",pid=812,fd=3))
tcp LISTEN 0.0.0.0:80 users:(("nginx",pid=950,fd=6))Options:
-t: Shows TCP sockets.-u: Shows UDP sockets.-l: Shows listening sockets only.-p: Shows the owning process. Requires root for processes of other users.-n: Shows numeric port numbers instead of service names.
6. Test Connectivity#
Test reachability and latency:
ping -c 4 <GATEWAY_IP>
ping -c 4 <TARGET_IP>Options:
-c 4: Sends four packets and stops.
7. Inspect the Hostname#
Show the hostname and related settings:
hostnamectlSet a static hostname:
sudo hostnamectl set-hostname <HOSTNAME>The static hostname is stored in /etc/hostname and is applied at boot on both distribution families.
Part 1: Debian-Based Systems#
Examples: Debian, Ubuntu
1. Identify the Netplan Configuration#
List existing netplan files:
ls /etc/netplan/Expected output:
00-installer-config.yamlFile names end in .yaml and are applied in lexical order.
2. Write a Static Address Configuration#
Edit the file:
sudo vim /etc/netplan/00-installer-config.yamlExample configuration:
network:
version: 2
renderer: networkd
ethernets:
<INTERFACE>:
dhcp4: no
addresses:
- 192.0.2.10/24
routes:
- to: default
via: 192.0.2.1
nameservers:
addresses:
- 192.0.2.53
- 8.8.8.8For DHCP, set dhcp4: true and drop the addresses, routes, and nameservers keys.
3. Validate and Apply#
Validate the syntax and generate the backend configuration:
sudo netplan generateApply with automatic rollback:
sudo netplan trynetplan try applies the configuration and rolls it back after 120 seconds unless it is confirmed. Use it for remote sessions.
Apply without rollback:
sudo netplan apply4. Verify the Result#
Check the address and the default route:
ip -br addr show <INTERFACE>
ip route showConfirm the gateway is reachable:
ping -c 4 192.0.2.1Part 2: RHEL-Based Systems#
Examples: RHEL, Rocky Linux, AlmaLinux
1. Inspect Devices and Connections#
Show device states:
nmcli device statusExpected output:
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected eth0
lo loopback unmanaged --Show connection profiles:
nmcli device show <INTERFACE>
nmcli connection show2. Configure a Static Address#
Modify the active connection profile:
sudo nmcli connection modify <CONNECTION> \
ipv4.method manual \
ipv4.addresses 192.0.2.10/24 \
ipv4.gateway 192.0.2.1 \
ipv4.dns "192.0.2.53 8.8.8.8"Activate the changes:
sudo nmcli connection up <CONNECTION>Switch back to DHCP:
sudo nmcli connection modify <CONNECTION> ipv4.method auto
sudo nmcli connection up <CONNECTION>Options:
ipv4.method manual: Configures a static address. Useautofor DHCP.ipv4.addresses: Sets the address and prefix length.ipv4.gateway: Sets the default gateway.ipv4.dns: Sets the DNS servers for this connection.
3. Verify the Result#
Check the applied configuration:
ip -br addr show <INTERFACE>
ip route show
nmcli device show <INTERFACE>Confirm that IP4.ADDRESS and IP4.GATEWAY contain the expected values.
Part 3: Important Notes#
Legacy Interface Configuration#
On older Debian systems, interfaces are configured in /etc/network/interfaces with the ifupdown tools. Example:
auto eth0
iface eth0 inet static
address 192.0.2.10/24
gateway 192.0.2.1Apply with ifup eth0 or systemctl restart networking. On current releases, netplan is the supported configuration path. Do not mix ifupdown and netplan configuration for the same interface.
On RHEL 7 and earlier, interface files were stored in /etc/sysconfig/network-scripts/. RHEL 9 manages these profiles through NetworkManager. Prefer nmcli over editing keyfiles directly.
Configuration File Locations#
| Item | Debian-based | RHEL-based |
|---|---|---|
| Interface configuration | /etc/netplan/*.yaml | NetworkManager connection profiles |
| Connection profiles | Not used | /etc/NetworkManager/system-connections/ |
| Legacy interface files | /etc/network/interfaces | /etc/sysconfig/network-scripts/ |
| Static hostname | /etc/hostname | /etc/hostname |
| Local name mappings | /etc/hosts | /etc/hosts |
Verification Steps#
Run these checks after every configuration change:
- Confirm the interface is up:
ip link show <INTERFACE>. - Confirm the expected address:
ip -br addr show <INTERFACE>. - Confirm the default route:
ip route show. - Confirm the gateway is reachable:
ping -c 4 <GATEWAY_IP>. - Confirm external connectivity:
ping -c 4 8.8.8.8. - Confirm that name resolution works.
Command Reference#
| Operation | Debian-based | RHEL-based |
|---|---|---|
| Show addresses | ip addr show | ip addr show |
| Show routes | ip route show | ip route show |
| Show listening ports | ss -tulpn | ss -tulpn |
| Edit configuration | Text files in /etc/netplan/ | nmcli connection modify |
| Apply configuration | netplan apply | nmcli connection up <CONNECTION> |
| Test before applying | netplan try | Not available |
| Set hostname | hostnamectl set-hostname <HOSTNAME> | hostnamectl set-hostname <HOSTNAME> |
Security Guidelines#
- Do not edit and apply network configuration blindly over SSH. Keep console access or use
netplan trybeforenetplan apply. - Replace placeholders such as
<INTERFACE>,<CONNECTION>, and<HOSTNAME>with actual values. Do not include the angle brackets in commands. - Make one change at a time and verify connectivity after each change.
- Persist configuration through netplan or NetworkManager. Do not leave long-lived addresses configured only with
ip addr add. - Document static addresses centrally and avoid conflicts with active DHCP ranges.
- Restrict management access to dedicated networks where possible. Do not expose management ports on public interfaces.
- Keep an out-of-band or console path available before changing network settings on a remote host.