| |

LFCS 165 ๐Ÿง LFCS Practice Scenarios โ€” Networking

โฑ๏ธ Estimated read: 9 min | |

The previous chapter covered the storage practice scenarios. This chapter covers the networking practice: the scenarios that simulate the exam tasks in the networking domain. The LFCS networking domain is weighted at 15% of the total score, and the objectives cover the interface configuration, the routing, the DNS, the hostname, the SSH, the firewall, and the diagnostics . The critical trap is the persistence. The ip addr add is the runtime. The NetworkManager connection is the persistence. The ip route add is the runtime. The nmcli connection is the persistence. The iptables rules are the runtime. The firewall-cmd --permanent is the persistence. The scenarios test the complete workflow, not just the single command.

Key point: The networking scenarios are the end-to-end tasks: the interface configuration, the static address, the route, the DNS, the hostname, the SSH, the firewall, and the diagnostics. The candidate must verify the state with the ip addr, the ip route, the dig, the ss, and the firewall-cmd, and make the change persistent with the NetworkManager, the /etc/hosts, the /etc/resolv.conf (or the resolved.conf), and the firewall-cmd --permanent.


Why the networking practice requires a specific mental model

The persistence problem. The ip addr add, the ip route add, and the iptables -A are the runtime changes. The reboot resets them. The NetworkManager connection profile, the nmcli modification, and the firewall-cmd --permanent are the persistent changes. The exam tests the persistence.

The connectivity problem. The networking changes are the most likely to break the remote connectivity. The ip link set down on the primary interface drops the SSH. The iptables -A INPUT -j DROP without the -A INPUT -p tcp --dport 22 -j ACCEPT before it locks out the administrator. The practice must include the safe changes and the verification before the persistence.

The DNS problem. The resolv.conf is the runtime. The NetworkManager or the systemd-resolved is the persistent. The /etc/hosts is the static override. The nsswitch.conf controls the order. The scenario tests the resolution path, not just the file edit.

The firewall problem. The firewall-cmd is the frontend for the firewalld. The --permanent flag is the persistence. The --reload applies. The ufw is the alternative on Ubuntu. The scenario tests the persistent rule, not the runtime.

The trade-off. The networking scenarios are the most likely to break the connectivity and the most likely to test the persistence. The practice must be on the VM with the console access, not on the remote host.


a. The interface configuration

The scenario: the configure the static IP 192.168.1.100/24 on the ens192 interface, the gateway 192.168.1.1, the DNS 1.1.1.1, and the persistence.

# View the current state
ip addr show ens192
nmcli device status

# Configure via NetworkManager (persistent)
sudo nmcli connection modify "Wired connection 1" \
  ipv4.method manual \
  ipv4.addresses 192.168.1.100/24 \
  ipv4.gateway 192.168.1.1 \
  ipv4.dns 1.1.1.1

# Reactivate
sudo nmcli connection up "Wired connection 1"

# Verify
ip addr show ens192
ip route show

The ipv4.method manual sets the static. The ipv4.addresses sets the IP and the prefix. The ipv4.gateway sets the default. The ipv4.dns sets the resolver. The nmcli connection up applies. The ip addr and the ip route confirm.

The transient alternative.

# Runtime only (lost on reboot)
sudo ip addr add 192.168.1.100/24 dev ens192
sudo ip route add default via 192.168.1.1

The ip addr add is the runtime. The reboot resets it. The exam tests the persistent, but the transient is useful for the testing.


b. The DNS and the hostname

The scenario: the set the hostname to web01.example.com, the /etc/hosts mapping, the DNS resolution, and the verification.

# Set the hostname
sudo hostnamectl set-hostname web01.example.com

# Update the hosts file
echo "127.0.1.1 web01.example.com web01" | sudo tee -a /etc/hosts

# Set the DNS via NetworkManager
sudo nmcli connection modify "Wired connection 1" ipv4.dns "1.1.1.1 8.8.8.8"
sudo nmcli connection up "Wired connection 1"

# Verify the resolution
getent hosts web01
dig +short example.com @1.1.1.1

The hostnamectl set-hostname is the persistent. The /etc/hosts is the local override. The nmcli ipv4.dns is the DNS servers. The getent hosts uses the nsswitch.conf order. The dig @1.1.1.1 bypasses the local resolver and tests the specific server.

The resolved.conf alternative.

# Persistent via systemd-resolved
sudo tee /etc/systemd/resolved.conf <<'EOF'
[Resolve]
DNS=1.1.1.1 8.8.8.8
Domains=example.com
EOF
sudo systemctl restart systemd-resolved
resolvectl status

The resolved.conf is the persistent for the systemd-resolved. The resolvectl status shows the current servers.


c. The SSH, the firewall, and the diagnostics

The scenario: the configure the SSH key auth, the firewall rule for the SSH, and the diagnostics.

# SSH key
ssh-keygen -t ed25519
ssh-copy-id user@server

# Firewall (firewalld)
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
sudo firewall-cmd --list-all

# Firewall (ufw)
sudo ufw allow ssh
sudo ufw allow http
sudo ufw enable

# Diagnostics
ss -tlnp
ping -c 4 8.8.8.8
traceroute 8.8.8.8
dig +short example.com

The ssh-keygen and the ssh-copy-id set the key auth. The firewall-cmd --permanent persists the rule. The --reload applies. The ss -tlnp shows the listening sockets. The ping tests the connectivity. The traceroute tests the path. The dig tests the DNS.

The SSH server config.

# Disable the password auth (after the key test)
sudo sed -i 's/^#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
sudo sshd -t
sudo systemctl reload sshd

The PasswordAuthentication no disables the password. The sshd -t validates the config. The systemctl reload applies. The key auth must be tested before the password disable.


Complete Example Session

# ============================================
# PART 1: STATIC IP
# ============================================

sudo nmcli connection modify "Wired connection 1" ipv4.method manual ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns 1.1.1.1
sudo nmcli connection up "Wired connection 1"
ip addr show ens192
# ============================================
# PART 2: VERIFY THE ROUTE
# ============================================

ip route show
ip route get 8.8.8.8
# ============================================
# PART 3: HOSTNAME
# ============================================

sudo hostnamectl set-hostname web01.example.com
hostnamectl --static
# ============================================
# PART 4: HOSTS FILE
# ============================================

echo "127.0.1.1 web01.example.com web01" | sudo tee -a /etc/hosts
getent hosts web01
# ============================================
# PART 5: DNS
# ============================================

sudo nmcli connection modify "Wired connection 1" ipv4.dns "1.1.1.1 8.8.8.8"
sudo nmcli connection up "Wired connection 1"
dig +short example.com
# ============================================
# PART 6: SSH KEY
# ============================================

ssh-keygen -t ed25519
ssh-copy-id user@server
# ============================================
# PART 7: FIREWALL
# ============================================

sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
# ============================================
# PART 8: SSH HARDENING
# ============================================

sudo sed -i 's/^#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
sudo sshd -t
sudo systemctl reload sshd
# ============================================
# PART 9: DIAGNOSTICS
# ============================================

ss -tlnp
ping -c 4 8.8.8.8
traceroute 8.8.8.8

The nine parts trace the networking scenarios: the static IP, the route, the hostname, the hosts file, the DNS, the SSH key, the firewall, the SSH hardening, and the diagnostics.


Quick Reference

Interface Configuration

CommandPurpose
nmcli con mod ipv4.method manualStatic IP
nmcli con mod ipv4.addressesIP and prefix
nmcli con mod ipv4.gatewayDefault gateway
nmcli con upApply

Hostname and DNS

CommandPurpose
hostnamectl set-hostnameSet the hostname
/etc/hostsStatic override
nmcli con mod ipv4.dnsDNS servers
resolvectl statusResolved config

Firewall

CommandPurpose
firewall-cmd --permanentPersistent rule
firewall-cmd --reloadApply
firewall-cmd --list-allVerify
ufw allowUbuntu rule

Diagnostics

CommandPurpose
ip addrIP addresses
ip routeRoutes
ss -tlnpListening sockets
pingReachability
digDNS query

Best Practices

โœ… Do This:

sudo nmcli connection modify ... ipv4.addresses
<!-- Use the NetworkManager for the persistence -->   # โœ…
sudo firewall-cmd --permanent --add-service=ssh
<!-- Use the permanent flag -->                       # โœ…
sudo sshd -t && sudo systemctl reload sshd
<!-- Test the SSH config before reload -->           # โœ…

โŒ Don’t Do This:

sudo ip addr add 192.168.1.100/24 dev eth0
<!-- Runtime only, lost on reboot -->                # โŒ
sudo iptables -A INPUT -j DROP
# Without allowing SSH first
<!-- Locks out the remote admin -->                  # โŒ
# Disable the password auth before testing the key
<!-- Locks out the admin -->                         # โŒ

Common Pitfalls

PitfallWhy It HappensFix
IP lost on rebootUsed ip addr addUse nmcli
DNS not workingWrong resolv.confUse nmcli or resolved
SSH locked outWrong sshd_configTest with sshd -t
Firewall blocks SSHNo allow ruleAdd the rule before the drop
Route missingNo default routeip route or nmcli gateway

Real-World Examples

1. Static IP

nmcli con mod "Wired connection 1" ipv4.method manual ipv4.addresses 192.168.1.100/24

2. Gateway

nmcli con mod "Wired connection 1" ipv4.gateway 192.168.1.1

3. DNS

nmcli con mod "Wired connection 1" ipv4.dns "1.1.1.1"

4. Hostname

hostnamectl set-hostname web01.example.com

5. Hosts

echo "127.0.1.1 web01" >> /etc/hosts

6. SSH Key

ssh-copy-id user@server

7. Firewall

firewall-cmd --permanent --add-service=http

8. Reload

firewall-cmd --reload

9. SSH Disable Password

sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config

10. Diagnostics

ss -tlnp; ping -c 4 8.8.8.8

Visual

Networking Scenario Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Identify the interface (ip addr, nmcli)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Configure (nmcli connection modify)         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Apply (nmcli connection up)                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Persist (NetworkManager profile)            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Verify (ip addr, ip route, dig, ss)         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Firewall Rule Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  firewall-cmd --permanent --add-service=ssh  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  firewall-cmd --reload                       โ”‚
โ”‚  โ†’ Applies the permanent rules               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  firewall-cmd --list-all                     โ”‚
โ”‚  โ†’ Verify the rule                           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary

ItemValue
Interface confignmcli connection modify
Static IPipv4.method manual
Gatewayipv4.gateway
DNSipv4.dns
Hostnamehostnamectl set-hostname
Hosts override/etc/hosts
Firewallfirewall-cmd --permanent
SSH keyssh-keygen, ssh-copy-id
Diagnosticsip, ss, ping, dig

Key takeaways:

  • The NetworkManager is the persistence. The ip addr add is the runtime. The nmcli connection modify is the persistent. The nmcli connection up applies. The reboot preserves the profile.
  • The firewall is the permanent. The firewall-cmd --permanent writes the rule to the configuration. The --reload applies. The rule without the --permanent is lost on the reload.
  • The SSH hardening is the key first. The key auth must be tested before the password is disabled. The sshd -t validates the config. The systemctl reload applies the change.
  • The DNS is the layered. The /etc/hosts is the override, the resolv.conf is the runtime, the NetworkManager or the resolved is the persistent. The getent hosts uses the nsswitch.conf order.
  • The diagnostics is the verification. The ip addr, the ip route, the ss -tlnp, the ping, the dig. The exam checks the state, not the command. The diagnostics proves the state.

Remember: The networking scenarios are the end-to-end tasks. The interface, the IP, the route, the DNS, the hostname, the SSH, the firewall, the diagnostics. The nmcli is the persistence. The firewall-cmd is the permanent. The sshd -t is the safe. The ss is the listening. The exam tests the complete workflow.

Was this helpful?


Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!