Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

Hoofdstuk 18Naam in de cursus: Managing Network Configuration

Set up the network with NetworkManager

On RHEL 10 the network is run by NetworkManager. Settings live in connection profiles; a profile is put on a device (the network card). You change profiles with nmcli (command line), nmtui (text menus) or the web console. This chapter shows how to set a fixed address, DNS, a second address and the host name, so that everything works after a reboot.

  • 9 Lessen
  • 10 Commando's
  • 1 Labs

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

Vaardigheden in dit hoofdstuk

  • Een vast adres en een hostnaam instellen met nmcli

18.1

Know devices and connection profiles

A device is the card (enp1s0). A connection (profile) is a set of settings. One device has one active profile at a time.

nmcli device status
DEVICE  TYPE      STATE                   CONNECTION
enp1s0  ethernet  connected               enp1s0
lo      loopback  connected (externally)  lo
nmcli connection show
NAME    UUID                                  TYPE      DEVICE
enp1s0  4f1c2e3a-0b9d-4c6e-8a7f-2d3e4f5a6b7c  ethernet  enp1s0
nmcli connection show --active
nmcli connection show enp1s0 | grep -E '^ipv4\.(method|addresses|gateway|dns)'
ipv4.method:                            auto
ipv4.addresses:                         --
ipv4.gateway:                           --
ipv4.dns:                               --

ipv4.method auto means DHCP. manual means a fixed address.

Onthoud

nmcli d (device) = the hardware. nmcli c (connection) = the settings. You almost always change the connection.

18.2

Set a fixed IPv4 address

Change the existing profile: method manual, the address with prefix, the gateway and DNS. Then activate the profile again.

nmcli connection modify enp1s0 \
    ipv4.method manual \
    ipv4.addresses 192.168.122.10/24 \
    ipv4.gateway 192.168.122.1 \
    ipv4.dns 192.168.122.1 \
    ipv4.dns-search example.com
nmcli connection up enp1s0

Controleer het

ip -br a show enp1s0
ip route show default
cat /etc/resolv.conf

Let op

Changing the address of the card you are connected to over SSH cuts your session. Work on the console, or make sure the new address is right before nmcli connection up.

Examentip

nmcli connection modify only saves. The change works after nmcli connection up NAME (or a reboot).

18.3

Add or remove one setting

A + before a setting adds a value, a - removes one. Without them, the value is replaced.

nmcli con mod enp1s0 +ipv4.addresses 192.168.122.110/24
nmcli con mod enp1s0 +ipv4.dns 1.1.1.1
nmcli con mod enp1s0 -ipv4.dns 1.1.1.1
nmcli con mod enp1s0 ipv4.ignore-auto-dns yes
nmcli con up enp1s0
ip -br -4 a show enp1s0
enp1s0  UP  192.168.122.10/24 192.168.122.110/24

18.4

Set an IPv6 address

IPv6 works the same way with ipv6.* settings.

nmcli con mod enp1s0 ipv6.method manual \
    ipv6.addresses 2001:db8:10::10/64 \
    ipv6.gateway 2001:db8:10::1 \
    ipv6.dns 2001:db8:10::1
nmcli con up enp1s0
ip -6 -br a show enp1s0
ping -6 -c 2 2001:db8:10::1

ipv6.method auto uses router advertisements (SLAAC) and DHCPv6. disabled turns IPv6 off on that profile.

18.5

Make a new profile

You can keep two profiles for one card (for example "office" with DHCP and "lab" with a fixed address) and switch between them.

nmcli connection add con-name lab ifname enp1s0 type ethernet \
    ipv4.method manual ipv4.addresses 10.10.10.5/24 ipv4.gateway 10.10.10.1 \
    autoconnect no
nmcli connection up lab
nmcli connection up enp1s0
nmcli connection delete lab

autoconnect no = the profile does not start by itself at boot.

Commando's in deze les

18.6

Use nmtui or the web console

nmtui is a text menu for the same settings — easy when you do not remember the nmcli names.

nmtui
nmtui edit enp1s0
nmtui connect
nmtui hostname

Use the arrow keys and Tab, <Edit…> a profile, <OK> to save. After the edit, deactivate and activate the profile in "Activate a connection" (or run nmcli con up enp1s0).

In the web console (https://server1:9090) the Networking page shows the cards, the traffic, and lets you edit addresses.

18.7

Know where the profiles are saved

RHEL 10 saves profiles as keyfiles in /etc/NetworkManager/system-connections/. The old ifcfg files in /etc/sysconfig/network-scripts/ are no longer supported.

ls /etc/NetworkManager/system-connections/
enp1s0.nmconnection
cat /etc/NetworkManager/system-connections/enp1s0.nmconnection
/etc/NetworkManager/system-connections/enp1s0.nmconnection
[connection]
id=enp1s0
type=ethernet
interface-name=enp1s0
 
[ipv4]
method=manual
address1=192.168.122.10/24,192.168.122.1
dns=192.168.122.1;
dns-search=example.com;
nmcli connection reload
nmcli connection up enp1s0

Let op

If you edit a keyfile by hand, it must be owned by root with rights 600, and you must run nmcli connection reload. Using nmcli is safer.

18.8

Set the host name

The static host name is saved in /etc/hostname. Set it with hostnamectl.

hostnamectl hostname server1.example.com
hostnamectl
hostname
server1.example.com
hostname -s
server1
cat /etc/hostname
server1.example.com

The prompt shows the new name after you log in again.

18.9

Make names work without DNS

For a few machines, or before DNS is ready, put names into /etc/hosts. It is read before DNS.

/etc/hosts
127.0.0.1        localhost localhost.localdomain
::1              localhost localhost.localdomain
192.168.122.10   server1.example.com server1
192.168.122.20   server2.example.com server2
getent hosts server2
ping -c 1 server2

Onthoud

The order is IP address, full name, short name. The search order (hosts file first, then DNS) is set by the hosts: line in /etc/nsswitch.conf.

Oefenen

Alle commando's in dit hoofdstuk