Exam weight: 4 โ LPIC-1 v5, Exam 102
What You Need to Know
From the official LPIC-1 objectives:
- Understand basic TCP/IP host configuration.
- Configure Ethernet and Wi-Fi network using NetworkManager.
- Awareness of
systemd-networkd.
Key files and commands: /etc/hostname, /etc/hosts, /etc/nsswitch.conf, /etc/resolv.conf, /etc/network/interfaces, ifup, ifdown, ip, ifconfig, route, nmcli, hostnamectl.
Network Interface Naming
Naming Prefixes
| Prefix | Interface type |
|---|---|
en | Ethernet |
ib | InfiniBand |
sl | Serial line (SLIP) |
wl | Wireless LAN |
ww | Wireless WAN (WWAN) |
Naming Policies (predictable names)
The kernel assigns names in order of priority:
- BIOS onboard index โ
eno1,eno2 - PCI slot number โ
ens1,ens3 - Bus topology (PCI bus/slot/function) โ
enp2s0 - MAC address โ
enx001122334455 - Legacy โ
eth0,eth1(fallback)
Listing Interfaces
ip link show # modern
ifconfig -a # all interfaces, including inactive
nmcli device # NetworkManager device list
/etc/network/interfaces (Debian/Ubuntu)
The traditional network configuration file used with ifupdown.
# Loopback
auto lo
iface lo inet loopback
# DHCP
auto eth0
iface eth0 inet dhcp
# Static
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
Key directives:
| Directive | Description |
|---|---|
auto IFACE | Bring up interface at boot |
iface IFACE inet dhcp | Configure via DHCP |
iface IFACE inet static | Static configuration |
address | IP address |
netmask | Subnet mask |
gateway | Default gateway |
dns-nameservers | DNS servers (requires resolvconf) |
ifup / ifdown
ifup eth0 # bring up interface
ifdown eth0 # bring down interface
Hostname Configuration
/etc/hostname
Contains the system’s static hostname as a single line:
myserver
hostnamectl
hostnamectl # show current hostname info
hostnamectl set-hostname myserver # set static hostname
hostnamectl set-hostname "My Server" --pretty # set pretty hostname
hostnamectl set-hostname "" --transient # set transient hostname
hostnamectl status # show all hostname types
Three hostname types:
| Type | Description |
|---|---|
| Static | Stored in /etc/hostname; persists across reboots |
| Transient | Set by the kernel or DHCP; lost on reboot |
| Pretty | Free-form human-readable label |
Name Resolution Files
/etc/nsswitch.conf
Controls the order and sources for name resolution. The hosts line determines how hostnames are resolved:
hosts: files dns
This checks /etc/hosts first, then DNS.
/etc/hosts
Maps IP addresses to hostnames locally, bypassing DNS:
127.0.0.1 localhost
127.0.1.1 myserver
::1 localhost ip6-localhost ip6-loopback
192.168.1.10 fileserver fs
Format: IP ADDRESS hostname [alias ...]
/etc/resolv.conf
Configures DNS servers and search domains:
nameserver 8.8.8.8
nameserver 8.8.4.4
search example.com
| Directive | Description |
|---|---|
nameserver IP | DNS server (up to 3) |
search DOMAIN | Append domain for unqualified lookups (up to 6) |
domain DOMAIN | Local domain (mutually exclusive with search) |
Note: NetworkManager and other tools may overwrite this file automatically.
NetworkManager and nmcli
NetworkManager is the standard network management daemon on most distributions. nmcli is its command-line client.
nmcli Object Overview
| Object | Description |
|---|---|
general | Overall NetworkManager status |
networking | Enable/disable networking |
radio | Wi-Fi and WWAN radio switches |
connection | Manage saved connections |
device | Manage network interfaces |
agent | Secret agents |
monitor | Monitor network activity |
Common nmcli Commands
# Status
nmcli general status
nmcli device status
nmcli device show eth0
# Connections
nmcli connection show
nmcli connection up myconn
nmcli connection down myconn
nmcli connection delete myconn
# Add a static Ethernet connection
nmcli connection add type ethernet ifname eth0 con-name myconn \
ipv4.addresses 192.168.1.100/24 \
ipv4.gateway 192.168.1.1 \
ipv4.dns 8.8.8.8 \
ipv4.method manual
# Modify an existing connection
nmcli connection modify myconn ipv4.dns 1.1.1.1
# Networking on/off
nmcli networking on
nmcli networking off
# Wi-Fi
nmcli radio wifi on
nmcli device wifi list
nmcli device wifi connect "MySSID" password "MyPass"
systemd-networkd
systemd-networkd is a systemd-based network configuration daemon.
Configuration Directories
| Path | Description |
|---|---|
/lib/systemd/network/ | Shipped by packages |
/run/systemd/network/ | Runtime (generated) |
/etc/systemd/network/ | Administrator configuration (highest priority) |
.network File Format
Files must end in .network. The [Match] section selects the interface; [Network] sets the configuration.
# DHCP example: /etc/systemd/network/10-eth0.network
[Match]
Name=eth0
[Network]
DHCP=yes
# Static example
[Match]
Name=eth0
[Network]
Address=192.168.1.100/24
Gateway=192.168.1.1
DNS=8.8.8.8
Quick Reference
Interface prefixes: en (Ethernet) wl (Wi-Fi) ww (WWAN)
eno1 (onboard) ens1 (PCI slot) enp2s0 (bus) enx... (MAC)
ip link show list interfaces
ifconfig -a all interfaces (legacy)
nmcli device NetworkManager device list
/etc/network/interfaces:
auto IFACE bring up at boot
iface IFACE inet dhcp/static/loopback
address / netmask / gateway / dns-nameservers
ifup IFACE / ifdown IFACE
Hostname:
/etc/hostname static hostname file
hostnamectl set-hostname NAME set static
hostnamectl status show all types
Name resolution:
/etc/nsswitch.conf hosts: files dns
/etc/hosts IP hostname [alias]
/etc/resolv.conf nameserver / search / domain
nmcli:
nmcli general status
nmcli connection show/add/modify/up/down/delete
nmcli device status/show/wifi list
nmcli device wifi connect SSID password PASS
systemd-networkd .network file:
[Match] Name=eth0
[Network] DHCP=yes or Address=.../24 Gateway=... DNS=...
Config dir: /etc/systemd/network/
Exam Questions
- What prefix identifies a wireless LAN interface? โ
wl - What naming convention produces interface names like
enp2s0? โ PCI bus topology (bus/slot/function) - What directive in
/etc/network/interfacesbrings an interface up automatically at boot? โauto IFACE - What command brings down interface
eth0in theifupdownsystem? โifdown eth0 - Where is the static hostname stored? โ
/etc/hostname - What
hostnamectlcommand sets the static hostname towebserver? โhostnamectl set-hostname webserver - What are the three hostname types managed by
hostnamectl? โ Static, transient, and pretty. - What file controls the order in which name resolution sources are consulted? โ
/etc/nsswitch.conf - What is the format of an
/etc/hostsentry? โIP_ADDRESS hostname [alias ...] - How many
nameserverentries can/etc/resolv.confhold? โ Up to 3. - What is the difference between
searchanddomainin/etc/resolv.conf? โ They are mutually exclusive; if both are present, the last one wins. - What
nmclicommand shows all saved connections? โnmcli connection show - What
nmclicommand connects to a Wi-Fi network namedOffice? โnmcli device wifi connect "Office" password "pass" - What
nmcliobject is used to manage network interfaces? โdevice - In which directory does a system administrator place
systemd-networkdconfiguration files? โ/etc/systemd/network/ - What section in a
.networkfile selects the interface to configure? โ[Match] - What
nmclicommand disables all networking? โnmcli networking off - What tool may overwrite
/etc/resolv.confautomatically? โ NetworkManager (indicated by a comment# Generated by NetworkManagerin the file).
Exercises
Exercise 1 โ Static Interface Configuration
Write an /etc/network/interfaces stanza that configures eth1 statically with IP 10.0.0.50/24, gateway 10.0.0.1, and DNS 10.0.0.53.
Answer
auto eth1
iface eth1 inet static
address 10.0.0.50
netmask 255.255.255.0
gateway 10.0.0.1
dns-nameservers 10.0.0.53
Exercise 2 โ Hostname Change
Change the system’s static hostname to dbserver using hostnamectl, then verify the change.
Answer
hostnamectl set-hostname dbserver
hostnamectl status
Exercise 3 โ nmcli Static Connection
Use nmcli to create a static Ethernet connection named corp on eth0 with IP 192.168.10.20/24, gateway 192.168.10.1, and DNS 192.168.10.5.
Answer
nmcli connection add type ethernet ifname eth0 con-name corp \
ipv4.addresses 192.168.10.20/24 \
ipv4.gateway 192.168.10.1 \
ipv4.dns 192.168.10.5 \
ipv4.method manual
nmcli connection up corp
Exercise 4 โ systemd-networkd
Write a systemd-networkd configuration file that enables DHCP on interface ens3.
Answer
Create /etc/systemd/network/10-ens3.network:
[Match]
Name=ens3
[Network]
DHCP=yes
Exercise 5 โ nsswitch.conf
Modify the hosts line in /etc/nsswitch.conf so that /etc/hosts is checked first, and DNS is only consulted if the host is not found there.
Answer
hosts: files dns
With files listed first, /etc/hosts is checked before DNS. If the entry is found in files, DNS is not queried.
LPIC-1 Study Notes | Topic 109: Networking Fundamentals