Introduction
This lesson is about making network settings survive reboot.
The main question is:
How do you understand persistent host and network configuration files on Linux, and how do you change them without confusing runtime state with saved configuration?
What you should be able to do after this lesson:
- Understand the difference between temporary runtime changes and persistent configuration.
- Recognize the roles of
/etc/hostname,/etc/hosts,/etc/resolv.conf, and/etc/nsswitch.conf. - Understand basic NetworkManager usage with
nmcli. - Understand the idea of persistent interface configuration across reboots.
- Recognize that different Linux distributions store network config in different places.
Before you start:
- If you change network settings on a remote machine over SSH, you can disconnect yourself.
- For first practice, use a VM or a local test system.
Big Idea: Runtime State and Saved Configuration Are Not the Same
Beginners often run one command, see the network change, reboot, and then wonder why it is gone.
Keep this picture in your head:
runtime commands change the current state -> config files or network managers make the change persistent
That is the core idea of this lesson.
Hostname Configuration
The hostname is the system's own name.
Show it:
hostname
hostnamectl
Common persistent file:
/etc/hostname
Set a hostname on many modern systems:
sudo hostnamectl set-hostname web1
That usually updates the persistent setting, not just the current session.
/etc/hosts
This file provides local static hostname mappings.
Example:
127.0.0.1 localhost
127.0.1.1 web1
Key beginner idea:
/etc/hostsis local- it is checked before or alongside DNS depending on
/etc/nsswitch.conf
This file is especially useful for:
- local testing
- bootstrapping before DNS is ready
- simple static mappings
/etc/resolv.conf
This file tells the resolver where to send DNS queries.
Typical content:
nameserver 1.1.1.1
search example.com
Common meanings:
nameserver= DNS server to asksearch= domain suffixes added for short names
Important real-life note:
- on many systems,
/etc/resolv.confis generated automatically - NetworkManager or
systemd-resolvedmay overwrite manual edits
So if changes do not stick, that is not always a bug. It may be managed by another service.
/etc/nsswitch.conf
This file decides how Linux looks up names and other information.
Useful line:
hosts: files dns
That means:
- check local files such as
/etc/hosts - then ask DNS
This is why getent hosts name is often more useful than looking only at raw DNS tools.
NetworkManager and nmcli
Many desktop and server distributions use NetworkManager.
Useful commands:
nmcli device status
nmcli connection show
nmcli connection show <name>
The main idea:
- a device is the actual interface
- a connection profile is the saved configuration
That distinction matters a lot in NetworkManager-based systems.
Interface Configuration Across Distros
LPIC expects awareness that Linux networking is not configured the same way everywhere.
You may encounter:
- NetworkManager profiles
- traditional interface files
systemd-networkd- cloud-init generated config
You should also recognize older management commands such as:
ifup <iface>
ifdown <iface>
These are still useful exam vocabulary even though many modern systems use NetworkManager or other managers instead.
For the exam, do not lock yourself into one distro-specific path. Remember the broader idea:
- Linux needs interface settings
- those settings must be saved somewhere persistent
Safe Beginner Workflow
When you need to understand persistent networking:
- inspect the current runtime state with
ipandhostnamectl - inspect the saved configuration files
- identify which manager owns the network config
- change the configuration in the correct place
- verify after reconnect or reboot
Practice Step by Step
1) Inspect the hostname
- Run:
hostname - Then:
hostnamectl - If you are on a test system, set a new hostname:
sudo hostnamectl set-hostname testbox - Verify the result.
2) Inspect resolver files
- Run:
sed -n '1,80p' /etc/resolv.conf - Then:
grep '^hosts:' /etc/nsswitch.conf - Explain in plain words where host lookups go first.
3) Inspect local host mappings
- Run:
sed -n '1,80p' /etc/hosts - Then test a lookup:
getent hosts localhost - Compare the result with what is in
/etc/hosts.
4) If NetworkManager is present, inspect saved connections
- Run:
nmcli device status - Then:
nmcli connection show - Notice the difference between active devices and saved profiles.
Cheat Sheet
hostname
hostnamectl
sudo hostnamectl set-hostname web1
sed -n '1,80p' /etc/hostname
sed -n '1,80p' /etc/hosts
sed -n '1,80p' /etc/resolv.conf
grep '^hosts:' /etc/nsswitch.conf
getent hosts localhost
nmcli device status
nmcli connection show
ifup <iface>
ifdown <iface>
Test Your Knowledge
Complete the quiz to assess your understanding of this course's concepts.
