LPIC-1 109.2: Persistent network configuration
NetworkManager's devices, profiles and their files (netplan's on Ubuntu), a
static address that lasts, the host name, and /etc/hosts.
Before you start
The peer, at 10.99.0.2 (name peer), stands in for another machine.
The lab also adds a second network for task 2, so your own connection to
the VM is never touched: interface le-lan, with a machine at 10.98.0.1
on the far side. On the RHEL family it has the NetworkManager profile
lab-net, which gets an address by DHCP from that machine. Ubuntu Server
uses netplan with networkd and doesn't install NetworkManager, so there
le-lan starts with no address, and you do tasks 1 and 2 with netplan.
Tasks
- Find the configuration file of the main interface, and write its path
to
/root/lab-answers/1. RHEL family: readnmcli deviceandnmcli connection show, find the file of the active connection withnmcli -f NAME,FILENAME connection show, and read it withsudo. Ubuntu: read the files in/etc/netplan/andnetworkctl status, and find the netplan file that sets up the main interface. - Give
le-lanthe static address10.98.0.10/24, check withip addrandip route, and reboot to show it lasts. RHEL family: on profilelab-net, withnmcli connection modify, then bring the connection up. (The chapter then returns it to DHCP: do that after you've run the check.) Ubuntu: in a new netplan file,/etc/netplan/90-lab.yaml, applied withnetplan try. - Change the host name to
lab2.example.netwithhostnamectl, and check/etc/hostname, the prompt in a new shell, andhostname -f. - Add the name
files.lab.examplefor the peer's address,10.99.0.2, to/etc/hosts, andpingit by name.
Hints
nmcli -f NAME,DEVICE,FILENAME connection show --active. On Ubuntu,ls /etc/netplan,networkctl list,networkctl status.nmcli connection modify lab-net ipv4.method manual ipv4.addresses ..., thennmcli connection up lab-net;ip -br addr show le-lan.- In netplan, an
ethernets:entry forle-lanwithaddresses: [10.98.0.10/24];chmod 600the file;netplan try(press Enter to keep it). hostnamectl set-hostname,hostnamectl status.- One line in
/etc/hosts: the address, then the names;getent hosts.