Course: Network and System Administration

In Class Lab: 9

Name: Local networking on your development server

Objective: Look at your development server's network interfaces with ip and ethtool, take an interface down and bring it back, find where RHEL 9 keeps its network settings, and change your server from a DHCP address to a static IP address with nmcli.

Since Lab 1 your development server has been on a network. You found its IP address with ip address show, and you have connected to it with SSH, scp and a GUI client in Labs 2 to 8. You never had to set that address up. Your hypervisor handed it out for you.

In this lab you look inside: which network interfaces your server has, what state they are in, where the settings are stored, and who gave your server its address. Then you take control of that address yourself. Everything in this lab stays on one server. In later labs you will connect it to other systems, and look at how traffic finds its way from your server to the rest of the internet.

Note: This lab is done on your development server, NOT your production server. Connect with SSH from Terminal or PuTTY and log in as your own user. Some steps will drop your SSH session on purpose, so you will also need the UTM or VirtualBox console.

Warning: Never run the commands in Parts 3, 6 and 7 on your production server. Production has no console. If you lose the network there, you can't get back in.

How to use the hints

Some steps give you every command. Others give you a Goal and ask you to work out the commands yourself. If you get stuck, open the hint. Once you have an answer, or if you are really stuck, open the solution and compare it with your own.

Lab overview

  1. Part 1: Look at your interfaces with ip - Task 1
  2. Part 2: Look at the hardware with ethtool - Task 2
  3. Part 3: Take an interface down and bring it back - Task 3
  4. Part 4: NetworkManager and connection profiles - Task 4
  5. Part 5: Gather your network settings - Task 5
  6. Part 6: Set a static IP address with nmcli - Task 6
  7. Part 7: Edit a connection profile by hand - Task 7

If you get stuck, check the Troubleshooting section at the end of this lab.

What to expect on your hypervisor

Your values depend on your hypervisor. These are the ones you are most likely to see. Yours may be a little different, and that is fine. Always use your values, not the examples.

Setting UTM (Mac) VirtualBox (Windows)
Interface name enp0s1 enp0s3
IP address 192.168.64.x/24 10.0.2.15/24
Default gateway 192.168.64.1 10.0.2.2
DNS server 192.168.64.1 10.0.2.3

The examples and screenshots in this lab come from a UTM server, so they use enp0s1. If your interface has a different name, use yours everywhere you see enp0s1.


Part 1: Look at your interfaces with ip

An interface is the place where your server meets a network. A physical server has a network card with a cable plugged in. Your virtual server has a virtual network card, provided by UTM or VirtualBox. Linux treats both the same way.

List your interfaces

ip address show ip -4 address show
Command What it does
ip address show Lists every interface, with its hardware address and its IPv4 and IPv6 addresses.
ip -4 address show The same, but only IPv4 addresses. -6 shows only IPv6.

You should see two interfaces:

network interface

You see It means
1: lo The loopback interface. Every Linux system has one. It only talks to the server itself.
2: enp0s1 Your Ethernet interface, the one connected to your hypervisor's network.
state UP The interface is turned on and connected.
state UNKNOWN (on lo) Normal for loopback. There is no cable or network on the other end, so there is nothing to detect.
link/ether 52:5d:43:... The MAC address: the hardware address of the network card.
inet 192.168.64.7/24 The IPv4 address. The /24 is the size of the network, which you will use in Part 5.
dynamic This address was handed out by a DHCP server. Keep an eye on this word.
valid_lft 3581sec How long the DHCP lease has left, in seconds. Your server asks to renew it before it runs out.
inet 127.0.0.1/8 (on lo) The loopback address. It is the same on every system, and is better known by its name: localhost.

Note: Where does a name like enp0s1 come from? It describes where the card sits in the computer: en for Ethernet, p0 for PCI bus 0 and s1 for slot 1. Older systems used eth0, and VMware uses names like ens33. See Consistent Network Device Naming if you are curious.

Look at one interface

Add the name of an interface to the end to see only that interface:

ip address show lo ip address show enp0s1

Shorter commands

ip lets you shorten its words, as long as the short version still means only one thing. address can be addr, or even just a. show can be sh, or s. These all print the same thing:

ip address show lo ip addr show lo ip a s lo

You will see all of these forms in documentation and on the internet. In this lab, we use the full words so the commands are easier to read.

Task 1: The shortest command

Goal: Print only the IPv4 address of your Ethernet interface, using the shortest command you can. Then find a second option that prints a short, one line summary of every interface.

Hint
Solution
ip -4 address show enp0s1 ip -4 a s enp0s1

Both print the same thing. You can leave out show only when nothing follows it: ip a on its own works, because show is what ip address does if you don't ask for anything else. ip -4 a enp0s1 fails, because ip thinks enp0s1 is the name of a command.

The summary option is -brief, or -br:

ip -br address ip -br link
Command What it does
ip -br address One line per interface: its name, its state and its addresses.
ip -br link One line per interface: its name, its state and its MAC address.

ip -br address is a quick way to find your interface name and IP address on any Linux server.


Part 2: Look at the hardware with ethtool

ip shows how an interface is set up. ethtool shows the network card underneath it: how fast it is, whether the cable is connected, and which driver Linux uses to talk to it.

Check that ethtool is installed. If you see command not found, install it:

which ethtool sudo dnf install -y ethtool

Then look at your Ethernet interface:

sudo ethtool enp0s1
You see It means
Speed How fast the link is, for example 1000Mb/s (1 gigabit per second).
Duplex Full means the card can send and receive at the same time. Half means it takes turns.
Link detected: yes The "cable" is plugged in, and there is something on the other end.

Note: ethtool works without sudo, but some lines, such as Wake-on, need root and are left out. You may also see Speed: Unknown! on UTM. A virtual card is not limited by a real cable, so it doesn't always report a speed. VirtualBox usually pretends to be a 1000Mb/s card.

The screenshot is from a vmware based host with the interface:ens33.

ethtool output

Now look at the statistics for the card. These are counters that have been adding up since your server booted:

ethtool -S enp0s1

Run it again, a few seconds later. Some numbers went up. Your SSH session is network traffic too, and every key you type is sent through this card.

Task 2: Which driver?

A driver is the software that lets Linux talk to a piece of hardware. UTM and VirtualBox each pretend to be a different kind of network card, so they use different drivers.

Goal: Find the driver that your Ethernet interface uses. Then compare your answer with someone in class who uses the other hypervisor.

Hint

The basic ethtool output doesn't show the driver. Look through ethtool --help, or search for driver in it with grep from Lab 2. There is a one letter option for information about the driver.

Solution
ethtool --help | grep -i driver ethtool -i enp0s1

ethtool -i shows the driver on the first line:

Hypervisor Driver you are likely to see What it is
UTM virtio_net A card designed for virtual machines. It doesn't pretend to be a real piece of hardware, so it can be faster.
VirtualBox e1000 Pretends to be an Intel gigabit card that has been around for years, so almost every operating system already has a driver for it.

ethtool -i also shows the bus-info, the address of the card on the PCI bus. Compare it with your interface name from Part 1.


Part 3: Take an interface down and bring it back

In this part you change the link state of your interfaces. This is the same as unplugging a network cable, and plugging it back in.

Warning: Only do this on your development server. Taking down the wrong interface on a real server cuts everyone off, and someone may need to go to the data center to fix it.

Two ways into the same server

localhost is a name for the loopback address. It always means "this server". You can SSH to localhost from your development server and open a second session on it, without ever leaving the server. It is like having two doors into the same room: one from your laptop, through your Ethernet interface, and one from inside the server, through lo.

First check who is logged in, then try it:

who ssh localhost

ssh asks you to trust the host key for localhost. Type yes, as you did in Lab 2. Then it stops with Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Question: Why can't you log in? Think about Lab 7.

Answer

You turned off password logins on this server in Lab 7. Now you need a key to log in, even when you connect from the server to itself. A key login needs the private key on the computer you connect from, and its public key in ~/.ssh/authorized_keys on the server you connect to. Your laptop's private key is on your laptop, not on this server. Your server does have its own key pair, the dev01 key from Lab 7, but you only added its public key to production, not to your development server.

Add your dev01 public key to your own authorized_keys. Use >>, never >, or you will replace your laptop's key, as in Lab 7:

cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys ssh-keygen -l -f ~/.ssh/authorized_keys

You should now see two keys: one from your laptop, and one ending in dev01. Try again:

ssh localhost who exit who
Command What it does
ssh localhost Logs in to this server, from this server. Enter your dev01 key's passphrase.
who Now shows two sessions for your user.
exit Closes the localhost session. You are back in your first session.

Question: Look at the end of each line of the who output, in parentheses. Where did each session come from?

Answer

who shows where each session connected from.

Take the loopback interface down

Question: If you take the lo interface down, will ssh localhost still work? Will your session from your laptop still work? Decide before you run the commands.

ip link show lo sudo ip link set lo down ip link show lo sudo ethtool lo ssh localhost
Command What it does
ip link show lo Shows the link state of lo. ip link is like ip address, without the IP addresses.
sudo ip link set lo down Turns lo off. Changing an interface needs sudo. Looking at one doesn't.
sudo ethtool lo Link detected: no.
ssh localhost Fails with an error such as Network is unreachable, or just waits. Press Ctrl + C to stop it.

Your session from your laptop still works, because it comes in through your Ethernet interface, not through lo. One door is locked. The other is still open.

Now bring lo back up, and check that both doors work again:

sudo ip link set lo up ip link show lo ssh localhost who exit

Note: Changes you make with ip link set and ip address take effect straight away, but they are not saved. A reboot puts everything back the way it was. You will make a permanent change in Part 6.

Task 3: Take down the Ethernet interface

Now try the other door. This one leads to your laptop.

Goal: Before you start, log in at the UTM or VirtualBox console, so it is ready. Then, from your SSH session, take your Ethernet interface down. Explain what happens to your SSH session, then get your network back.

Hint
Solution

From your SSH session:

sudo ip link set enp0s1 down

Your SSH session freezes. You just unplugged the only cable between your server and your laptop, and SSH traffic has no other way in. After a while, your Terminal or PuTTY may say that the connection was closed or timed out.

At the console, the server still works. The console is like a keyboard and screen plugged directly into the server, so it doesn't use the network at all. Check the link and bring it back up:

ip link show enp0s1 sudo ip link set enp0s1 up ip address show enp0s1

Wait for a few seconds, then check for the inet line in ip address show enp0s1. When the link comes back, NetworkManager notices and asks the DHCP server for an address again. If you still have no inet line after a minute, ask NetworkManager to start the connection, which you will learn about in Part 4:

sudo nmcli connection up enp0s1

Now open a new SSH session from your laptop. If your old one is still frozen, close the window.

This is why you were asked to never do this on production. Production has no console, so there would be no way to type the command that fixes it.


Part 4: NetworkManager and connection profiles

ip changes things for now. Something must also remember your network settings, and set them up again every time the server boots. On RHEL 9, that is NetworkManager. It runs all the time as a service, just like sshd, and you talk to it with nmcli, the NetworkManager command line interface.

systemctl status NetworkManager

nmcli example

Look for active (running) and enabled, as you did for sshd in Lab 7. enabled means it starts every time the server boots. Press q to quit. The screenshot also shows a restart. You don't need to restart NetworkManager in this lab.

Devices and connections

NetworkManager uses two words that sound alike:

Word What it is
Device A network interface, such as enp0s1 or lo. The same thing ip calls an interface.
Connection A saved set of settings, also called a profile, that NetworkManager applies to a device: DHCP or static, which DNS servers, whether to start at boot, and so on.
nmcli device nmcli connection show
Command What it does
nmcli device Lists the devices, their state and which connection each one is using.
nmcli connection show Lists the saved connections. The NAME column is the name you use in other nmcli commands.

The RHEL installer named your connection after your device, so both are probably enp0s1. If your connection NAME is something different, such as Wired connection 1, use that name in the nmcli connection commands in this lab, in quotes because it has spaces.

Note: lo may show as connected (externally). That means something other than NetworkManager set it up, and NetworkManager leaves it alone.

Where the settings are saved

Each connection is saved as a file called a keyfile, in /etc/NetworkManager/system-connections/:

ls -l /etc/NetworkManager/system-connections/ cat /etc/NetworkManager/system-connections/enp0s1.nmconnection

Question: Why does cat say Permission denied? Look at the ls -l output, and think about Lab 6.

Answer

The file is -rw------- and owned by root. Only root can read it. A connection profile can hold secrets, such as a Wi-Fi password, so NetworkManager insists that only root can read it. If you loosen the permissions, NetworkManager ignores the file.

Read it with sudo. !! repeats your last command, so sudo !! runs it again with sudo in front:

sudo !!

It looks something like this. Your uuid and timestamp are different:

[connection] id=enp0s1 uuid=e9bee56b-c3b0-3bcf-856b-bda8614b3c5d type=ethernet autoconnect-priority=-999 interface-name=enp0s1 timestamp=1759619171 [ethernet] [ipv4] method=auto [ipv6] addr-gen-mode=eui64 method=auto [proxy]
Section or setting What it means
[connection] A section. Each section groups settings for one part of the connection.
id=enp0s1 The connection NAME you saw in nmcli connection show.
interface-name=enp0s1 The device this connection is for.
[ipv4] method=auto Get an IPv4 address automatically, with DHCP. This is where the word dynamic in Part 1 came from.

Note: Older versions of RHEL, up to RHEL 8, kept these settings in /etc/sysconfig/network-scripts/ifcfg-enp0s1, with lines such as BOOTPROTO=dhcp. You will still find that format in many guides on the internet, and on older servers at work. RHEL 9 uses keyfiles instead. See the table in the Lab summary.

Task 4: Ask nmcli for one setting

nmcli connection show with a connection name prints every setting in the connection, including the ones that aren't in the file:

nmcli connection show enp0s1

That is a lot of output. Each line is a setting name, such as ipv4.method, followed by its value.

Goal: Print only the ipv4.method setting of your connection, and only the connection.autoconnect setting. What do the values mean?

Hint
Solution
nmcli connection show enp0s1 | grep ipv4.method nmcli connection show enp0s1 | grep connection.autoconnect:

The : at the end of the second grep leaves out other settings whose names start with connection.autoconnect, such as connection.autoconnect-priority.

Another way: -g, short for --get-values, prints only the values of the settings you name, with no setting names:

nmcli -g ipv4.method connection show enp0s1 nmcli -g ipv4.method,connection.autoconnect connection show enp0s1
Setting Value Meaning
ipv4.method auto Get the IPv4 address from DHCP.
connection.autoconnect yes Start this connection automatically, for example when the server boots.

You will use -g again to check your work in Parts 6 and 7.


Part 5: Gather your network settings

Right now your server gets four pieces of information from the hypervisor's DHCP server:

Setting What it is
IP address Your server's own address on the network.
Prefix (netmask) The /24 after the address. It says how much of the address names the network, and how much names your host.
Default gateway The router your server sends traffic to when it is going anywhere outside its own network, such as the internet.
DNS server The server that turns names such as www.uw.edu into IP addresses.

To set a static address in Part 6, you will type all four in yourself. So first, write down what you have now.

Your IP address and prefix

ip -4 address show enp0s1

ip addr show

In this example the IP address is 192.168.64.7 and the prefix is /24. Write down yours.

The prefix counts how many bits of the address, from the left, belong to the network. Each of the four numbers in an IPv4 address is 8 bits, so the common prefixes line up with whole numbers:

Prefix Netmask The network part of 192.168.64.7
/8 255.0.0.0 192
/16 255.255.0.0 192.168
/24 255.255.255.0 192.168.64
/32 255.255.255.255 All of it: a single address

With /24, every address from 192.168.64.1 to 192.168.64.254 is on the same network as your server. You will learn more about networks and subnets in a later lab.

Task 5: Find your gateway and DNS server

Goal: Find your default gateway and your DNS server, and write them down next to your IP address and prefix.

Hint
Solution

The default gateway is on the default line of ip route, after the word via:

ip route

default gateway

proto dhcp on that line shows that the gateway, like the address, came from DHCP.

The DNS server is on the nameserver line of /etc/resolv.conf:

cat /etc/resolv.conf

resolv.conf

The first line of the file says Generated by NetworkManager. NetworkManager writes this file for you, so any change you make to it by hand will be lost. You change DNS servers in the connection profile instead, in Part 7. If you also see a nameserver line that starts with fe80::, that is an IPv6 DNS server. You can ignore it in this lab.

On UTM, the gateway and the DNS server are both your Mac, at 192.168.64.1. On VirtualBox, they are two different addresses, 10.0.2.2 and 10.0.2.3, both provided by VirtualBox.

You should now have all four settings written down, something like this:

Setting Example (UTM) Example (VirtualBox) Yours
IP address/prefix 192.168.64.7/24 10.0.2.15/24
Default gateway 192.168.64.1 10.0.2.2
DNS server 192.168.64.1 10.0.2.3

Part 6: Set a static IP address with nmcli

Servers usually have a static IP address, one that is set by hand and never changes. People and other servers need to find them in the same place every time. If your server's address changed, everything that points to it would break: your saved PuTTY session or ~/.ssh/config entry from Lab 7, and your WinSCP or Cyberduck site from Lab 8.

So far your address has stayed the same, but nothing promises that it will. In this part, you make the address you already have static. You keep the same address, so your saved sessions keep working, but it no longer depends on DHCP.

Note (VirtualBox users): You must keep 10.0.2.15. Your port forwarding rule from Lab 1 passes connections to the address VirtualBox handed out. If you pick a different address, you won't be able to SSH to your server.

Get ready

  1. Log in at the UTM or VirtualBox console, and leave it open. If something goes wrong, this is your safety net, just like the extra session you kept open in Lab 7.
  2. Back up the connection profile before you change it. It is good practice to back up any configuration file before you change it:
sudo cp /etc/NetworkManager/system-connections/enp0s1.nmconnection ~/enp0s1.nmconnection.backup ls -l ~/enp0s1.nmconnection.backup

The copy is in your home directory, but it is owned by root and is still -rw-------, because sudo made it. That keeps the secrets in it safe. You will need sudo to read it.

Change the connection

This one command changes four settings in your connection profile. It is long, so it is split over several lines. The \ at the end of a line tells the shell that the command continues on the next line. Use your values from Part 5:

sudo nmcli connection modify enp0s1 \ ipv4.method manual \ ipv4.addresses 192.168.64.7/24 \ ipv4.gateway 192.168.64.1 \ ipv4.dns 192.168.64.1
Part What it does
nmcli connection modify enp0s1 Change the saved settings of the connection named enp0s1.
ipv4.method manual Stop using DHCP. You will provide the settings yourself.
ipv4.addresses 192.168.64.7/24 Your IP address and prefix. Don't forget the /24.
ipv4.gateway 192.168.64.1 Your default gateway.
ipv4.dns 192.168.64.1 Your DNS server.

Nothing changes yet. nmcli connection modify only changes the saved settings. Check them:

nmcli -g ipv4.method,ipv4.addresses,ipv4.gateway,ipv4.dns connection show enp0s1 ip address show enp0s1

nmcli shows the new settings, but ip address show still shows dynamic. To use the new settings, ask NetworkManager to start the connection again:

sudo nmcli connection up enp0s1

Your SSH session may pause for a few seconds while the interface is set up again. Because your address didn't change, it should then carry on. If it is still frozen after 30 seconds, see Troubleshooting.

Check your work

ip address show enp0s1 ip route

static ip

Compare this with Part 1. The word dynamic is gone, and valid_lft says forever. There is no lease to run out, because the address no longer comes from DHCP. On the default line of ip route, proto dhcp is now proto static.

Note: The screenshot above is from a server that was also given a new address, 192.168.64.107. Yours should still show the address you had before.

nmcli can show you the same thing. nmcli device show lists what a device is using right now:

nmcli device show enp0s1 nmcli -g IP4.ADDRESS,IP4.GATEWAY,IP4.DNS device show enp0s1 nmcli -g ipv4.addresses,ipv4.gateway,ipv4.dns connection show enp0s1
Command What it shows
nmcli device show enp0s1 Everything the device is using now: its MAC address, state, IP address, gateway and DNS servers.
nmcli -g IP4.ADDRESS,... device show Settings in CAPITALS, such as IP4.ADDRESS, are what is in use now.
nmcli -g ipv4.addresses,... connection show Settings in lowercase, such as ipv4.addresses, are what is saved in the connection profile.

Right now the two match. They don't always. After nmcli connection modify, and before nmcli connection up, the saved settings had changed, but the settings in use had not. When something isn't working, compare the two: if they are different, the change you saved hasn't been used yet.

Finally, open a new SSH session from your laptop, the same way you always do. If it works, your static address is working.

Task 6: What did nmcli change?

nmcli saved your changes in the keyfile. Your backup still has the old version.

Goal: Show exactly which lines in the keyfile changed, by comparing it with your backup.

Hint

You compared two files line by line in Lab 8. Both files can only be read by root.

Solution
sudo diff ~/enp0s1.nmconnection.backup /etc/NetworkManager/system-connections/enp0s1.nmconnection

Lines starting with < are only in the backup, and lines starting with > are only in the new file. You should see method=auto replaced by lines like these:

[ipv4] address1=192.168.64.7/24 dns=192.168.64.1; gateway=192.168.64.1 method=manual

Your file may put the gateway on the address1 line instead, after a comma, such as address1=192.168.64.7/24,192.168.64.1. Both mean the same thing. The timestamp line may also be different.

You never opened the file, but nmcli changed it for you. That is how most changes to NetworkManager are made.


Part 7: Edit a connection profile by hand

nmcli is the safest way to change a connection, because it checks your values before saving them. But a keyfile is just a text file, and sometimes it is quicker to edit it. You will also see keyfiles copied from one server to another, or written by automation tools later in the course.

Editing the file is only half the job. NetworkManager reads its keyfiles when it starts, and doesn't notice when you change one. You have to tell it to reload the files.

Task 7: Add a second DNS server

If your DNS server stops answering, your server can't turn names into addresses, even though the network is working. A second DNS server is a common backup. 8.8.8.8 is a public DNS server run by Google.

Goal: Using Vim, edit your keyfile to add 8.8.8.8 as a second DNS server, after the one you already have. Get NetworkManager to use the change, and show that 8.8.8.8 appears in /etc/resolv.conf.

Hint
Solution
sudo vim /etc/NetworkManager/system-connections/enp0s1.nmconnection

Find the dns= line in the [ipv4] section, and add 8.8.8.8; to the end of it, so that it looks like this. Then save and quit with :wq:

dns=192.168.64.1;8.8.8.8;

Check what NetworkManager thinks, then reload, check again, and start the connection:

nmcli -g ipv4.dns connection show enp0s1 sudo nmcli connection reload nmcli -g ipv4.dns connection show enp0s1 sudo nmcli connection up enp0s1 cat /etc/resolv.conf
Command What it does
nmcli -g ipv4.dns ... (first) Shows only your first DNS server. NetworkManager has not read your change yet.
sudo nmcli connection reload Reads every keyfile again from /etc/NetworkManager/system-connections/.
nmcli -g ipv4.dns ... (second) Now shows both DNS servers, separated by a comma.
sudo nmcli connection up enp0s1 Starts the connection again with the new settings.
cat /etc/resolv.conf Now has two nameserver lines. NetworkManager wrote the file again for you.

Common Pitfall: If you skip reload, nothing seems to happen. Worse, the next time you change this connection with nmcli, it saves the settings it remembers and your hand edit is overwritten.

Another way: nmcli can add a value to a list with a + in front of the setting name, much like usermod -aG adds to a list of groups in Lab 6:

sudo nmcli connection modify enp0s1 +ipv4.dns 8.8.8.8

Without the +, ipv4.dns 8.8.8.8 would replace your DNS server, just like usermod -G without -a.

Keep your static address and both DNS servers. Your server's address now stays the same for the rest of the course.

Undoing this change

If your network stops working and you can't fix it, put your backup back from the console, then reload and start the connection:

sudo cp ~/enp0s1.nmconnection.backup /etc/NetworkManager/system-connections/enp0s1.nmconnection sudo nmcli connection reload sudo nmcli connection up enp0s1 ip address show enp0s1

You are back on DHCP, and ip address show says dynamic again.


Lab summary

You have now:

Task RHEL 8 and older (ifcfg) RHEL 9 (NetworkManager keyfile)
Where settings are saved /etc/sysconfig/network-scripts/ifcfg-enp0s1 /etc/NetworkManager/system-connections/enp0s1.nmconnection
File format KEY=VALUE lines, such as BOOTPROTO=dhcp [section] headings and key=value lines, such as method=auto
Change settings nmcli, or edit the file nmcli, or edit the file
Use the new settings nmcli connection reload, then nmcli connection up nmcli connection reload, then nmcli connection up

Questions to consider

Discuss these with others in class:

  1. Why does lo show state UNKNOWN, while your Ethernet interface shows state UP?
  2. When you took lo down, your SSH session from your laptop kept working. When you took your Ethernet interface down, it froze. Why?
  3. Why could you fix your Ethernet interface from the console, but not from SSH? What would you do if this happened on a server in the cloud?
  4. What is the difference between a change made with ip link set and one made with nmcli connection modify? Which one survives a reboot?
  5. Why do servers usually have static IP addresses, while laptops and phones usually use DHCP?
  6. VirtualBox users had to keep 10.0.2.15. What would have happened if they chose 10.0.2.115? How would they get their SSH connection back?
  7. Two servers on the same network are accidentally given the same static IP address. What do you think happens?

Troubleshooting

Q. My interface isn't called enp0s1.

A. That is fine. Run ip -br address and use the name of the interface that isn't lo everywhere you see enp0s1. VirtualBox usually uses enp0s3.

Q. nmcli says "Error: unknown connection 'enp0s1'".

A. Your connection name is not the same as your device name. Run nmcli connection show and use the name in the NAME column. If it has spaces, put it in quotes, such as "Wired connection 1". The keyfile in /etc/NetworkManager/system-connections/ is named after the connection too.

Q. ssh localhost still says "Permission denied (publickey,...)".

A. Check that both keys are listed with ssh-keygen -l -f ~/.ssh/authorized_keys. If you see No such file or directory for ~/.ssh/id_ed25519.pub, you don't have a dev01 key yet. Create one with ssh-keygen -t ed25519 -C "dev01", as in Lab 7, then add it with >> again. If you see bad ownership or modes, see the Lab 7 troubleshooting section.

Q. I used > instead of >>, and now I can't log in from my laptop.

A. You replaced your laptop's public key with your dev01 key. Log in at the console, and add your laptop's public key back to ~/.ssh/authorized_keys with >>, as in Lab 7. Then add the dev01 key again with >>.

Q. My SSH session froze after sudo nmcli connection up enp0s1, and didn't come back.

A. Go to the console. Run ip address show enp0s1 and ip route, and compare them with the settings you wrote down in Part 5. Then run nmcli -g ipv4.addresses,ipv4.gateway,ipv4.dns connection show enp0s1 to look for a typo, such as a missing /24. Fix it with sudo nmcli connection modify, and run sudo nmcli connection up enp0s1 again. If you can't find the problem, put your backup back, as in Undoing this change.

Q. nmcli connection up says "Error: Connection activation failed".

A. NetworkManager couldn't apply your settings. Check them for typos with the nmcli -g command in the answer above. For more detail, run sudo journalctl -u NetworkManager | tail -n 20 and look for lines that say error or warn.

Q. I edited the keyfile, but nothing changed.

A. NetworkManager doesn't notice when you edit a keyfile. Run sudo nmcli connection reload, then sudo nmcli connection up enp0s1.

Q. After editing the keyfile by hand, my connection disappeared from nmcli connection show.

A. NetworkManager couldn't read the file. Check two things:

Q. I took my Ethernet interface down, and brought it back up at the console, but it has no IP address.

A. Run sudo nmcli connection up enp0s1. If that fails, check with nmcli device that your device shows as connected.

Q. VirtualBox users: I can't find the console.

A. If you chose Start without GUI, select itfdn-rhel9-dev01 in VirtualBox and click Show.

Q. I can't log in at the console.

A. The console still accepts your password. You only turned off password logins for SSH in Lab 7. Check your username, and that Caps Lock is off. If you still can't log in, post your problem in this week's Teams channel, or reach out by email for help.


Lab complete