Configuring and managing networking
Managing network interfaces, firewalls, and advanced networking features
Abstract
- You can configure bonds, VLANs, bridges, tunnels and other network types to connect the host to the network.
- You can build performance-critical firewalls for the local host and the entire network. RHEL contains packet filtering software, such as the
firewalld
service, thenftables
framework, and Express Data Path (XDP). - RHEL also supports advanced networking features, such as policy-based routing and Multipath TCP (MPTCP).
Providing feedback on Red Hat documentation
We appreciate your feedback on our documentation. Let us know how we can improve it.
Submitting feedback through Jira (account required)
- Log in to the Jira website.
- Click Create in the top navigation bar.
- Enter a descriptive title in the Summary field.
- Enter your suggestion for improvement in the Description field. Include links to the relevant parts of the documentation.
- Click Create at the bottom of the dialogue.
Chapter 1. Implementing consistent network interface naming
The udev
device manager implements consistent device naming in Red Hat Enterprise Linux. The device manager supports different naming schemes and, by default, assigns fixed names based on firmware, topology, and location information.
Without consistent device naming, the Linux kernel assigns names to network interfaces by combining a fixed prefix and an index. The index increases as the kernel initializes the network devices. For example, eth0
represents the first Ethernet device being probed on start-up. If you add another network interface controller to the system, the assignment of the kernel device names is no longer fixed because, after a reboot, the devices can initialize in a different order. In that case, the kernel can name the devices differently.
To solve this problem, udev
assigns consistent device names. This has the following advantages:
- Device names are stable across reboots.
- Device names stay fixed even if you add or remove hardware.
- Defective hardware can be seamlessly replaced.
- The network naming is stateless and does not require explicit configuration files.
Generally, Red Hat does not support systems where consistent device naming is disabled. For exceptions, see the Is it safe to set net.ifnames=0 solution.
1.1. How the udev device manager renames network interfaces
To implement a consistent naming scheme for network interfaces, the udev
device manager processes the following rule files in the listed order:
Optional:
/usr/lib/udev/rules.d/60-net.rules
The
/usr/lib/udev/rules.d/60-net.rules
file defines that the deprecated/usr/lib/udev/rename_device
helper utility searches for theHWADDR
parameter in/etc/sysconfig/network-scripts/ifcfg-*
files. If the value set in the variable matches the MAC address of an interface, the helper utility renames the interface to the name set in theDEVICE
parameter of theifcfg
file.If the system uses only NetworkManager connection profiles in keyfile format,
udev
skips this step.Only on Dell systems:
/usr/lib/udev/rules.d/71-biosdevname.rules
This file exists only if the
biosdevname
package is installed, and the rules file defines that thebiosdevname
utility renames the interface according to its naming policy, if it was not renamed in the previous step.NoteInstall and use
biosdevname
only on Dell systems./usr/lib/udev/rules.d/75-net-description.rules
This file defines how
udev
examines the network interface and sets the properties inudev
-internal variables. These variables are then processed in the next step by the/usr/lib/udev/rules.d/80-net-setup-link.rules
file. Some of the properties can be undefined./usr/lib/udev/rules.d/80-net-setup-link.rules
This file calls the
net_setup_link
builtin of theudev
service, andudev
renames the interface based on the order of the policies in theNamePolicy
parameter in the/usr/lib/systemd/network/99-default.link
file. For further details, see Network interface naming policies.If none of the policies applies,
udev
does not rename the interface.
Additional resources
- Why are systemd network interface names different between major RHEL versions (Red Hat Knowledgebase)
1.2. Network interface naming policies
By default, the udev
device manager uses the /usr/lib/systemd/network/99-default.link
file to determine which device naming policies to apply when it renames interfaces. The NamePolicy
parameter in this file defines which policies udev
uses and in which order:
NamePolicy=kernel database onboard slot path
The following table describes the different actions of udev
based on which policy matches first as specified by the NamePolicy
parameter:
Policy | Description | Example name |
---|---|---|
kernel |
If the kernel indicates that a device name is predictable, |
|
database |
This policy assigns names based on mappings in the |
|
onboard | Device names incorporate firmware or BIOS-provided index numbers for onboard devices. |
|
slot | Device names incorporate firmware or BIOS-provided PCI Express (PCIe) hot-plug slot-index numbers. |
|
path | Device names incorporate the physical location of the connector of the hardware. |
|
mac | Device names incorporate the MAC address. By default, Red Hat Enterprise Linux does not use this policy, but administrators can enable it. |
|
Additional resources
- How the udev device manager renames network interfaces
-
systemd.link(5)
man page on your system
1.3. Network interface naming schemes
The udev
device manager uses certain stable interface attributes that device drivers provide to generate consistent device names.
If a new udev
version changes how the service creates names for certain interfaces, Red Hat adds a new scheme version and documents the details in the systemd.net-naming-scheme(7)
man page on your system. By default, Red Hat Enterprise Linux (RHEL) 8 uses the rhel-8.0
naming scheme, even if you install or update to a later minor version of RHEL.
If you want to use a scheme other than the default, you can switch the network interface naming scheme.
For further details about the naming schemes for different device types and platforms, see the systemd.net-naming-scheme(7)
man page on your system.
1.4. Switching to a different network interface naming scheme
By default, Red Hat Enterprise Linux (RHEL) 8 uses the rhel-8.0
naming scheme, even if you install or update to a later minor version of RHEL. While the default naming scheme fits in most scenarios, there might be reasons to switch to a different scheme version, for example:
- A new scheme can help to better identify a device if it adds additional attributes, such as a slot number, to an interface name.
-
An new scheme can prevent
udev
from falling back to the kernel-assigned device names (eth*
). This happens if the driver does not provide enough unique attributes for two or more interfaces to generate unique names for them.
Prerequisites
- You have access to the console of the server.
Procedure
List the network interfaces:
# ip link show 2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...
Record the MAC addresses of the interfaces.
Optional: Display the
ID_NET_NAMING_SCHEME
property of a network interface to identify the naming scheme that RHEL currently uses:# udevadm info --query=property --property=ID_NET_NAMING_SCHEME /sys/class/net/eno1' ID_NET_NAMING_SCHEME=rhel-8.0
Note that the property is not available on the
lo
loopback device.Append the
net.naming-scheme=<scheme>
option to the command line of all installed kernels, for example:# grubby --update-kernel=ALL --args=net.naming-scheme=rhel-8.4
Reboot the system.
# reboot
Based on the MAC addresses you recorded, identify the new names of network interfaces that have changed due to the different naming scheme:
# ip link show 2: eno1np0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...
After switching the scheme,
udev
names in this example the device with MAC address00:00:5e:00:53:1a
eno1np0
, whereas it was namedeno1
before.Identify which NetworkManager connection profile uses an interface with the previous name:
# nmcli -f device,name connection show DEVICE NAME eno1 example_profile ...
Set the
connection.interface-name
property in the connection profile to the new interface name:# nmcli connection modify example_profile connection.interface-name "eno1np0"
Reactivate the connection profile:
# nmcli connection up example_profile
Verification
Identify the naming scheme that RHEL now uses by displaying the
ID_NET_NAMING_SCHEME
property of a network interface:# udevadm info --query=property --property=ID_NET_NAMING_SCHEME /sys/class/net/eno1np0' ID_NET_NAMING_SCHEME=_rhel-8.4
Additional resources
1.5. Determining a predictable RoCE device name on the IBM Z platform
On Red Hat Enterprise Linux (RHEL) 8.7 and later, the udev
device manager sets names for RoCE interfaces on IBM Z as follows:
-
If the host enforces a unique identifier (UID) for a device,
udev
assigns a consistent device name that is based on the UID, for exampleeno<UID_in_decimal>
. If the host does not enforce a UID for a device, the behavior depends on your settings:
-
By default,
udev
uses unpredictable names for the device. -
If you set the
net.naming-scheme=rhel-8.7
kernel command line option,udev
assigns a consistent device name that is based on the function identifier (FID) of the device, for exampleens<FID_in_decimal>
.
-
By default,
Manually configure predictable device name for RoCE interfaces on IBM Z in the following cases:
Your host runs RHEL 8.6 or earlier and enforces a UID for a device, and you plan to update to RHEL 8.7 or later.
After an update to RHEL 8.7 or later,
udev
uses consistent interface names. However, if you used unpredictable device names before the update, NetworkManager connection profiles still use these names and fail to activate until you update the affected profiles.- Your host runs RHEL 8.7 or later and does not enforce a UID, and you plan to upgrade to RHEL 9.
Before you can use a udev
rule or a systemd
link file to rename an interface manually, you must determine a predictable device name.
Prerequisites
- An RoCE controller is installed in the system.
-
The
sysfsutils
package is installed.
Procedure
Display the available network devices, and note the names of the RoCE devices:
# ip link show ... 2: enP5165p0s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 ...
Display the device path in the
/sys/
file system:# systool -c net -p Class = "net" Class Device = "enP5165p0s0" Class Device path = "/sys/devices/pci142d:00/142d:00:00.0/net/enP5165p0s0" Device = "142d:00:00.0" Device path = "/sys/devices/pci142d:00/142d:00:00.0"
Use the path shown in the
Device path
field in the next steps.Display the value of the
<device_path>/uid_id_unique
file, for example:# cat /sys/devices/pci142d:00/142d:00:00.0/uid_id_unique
The displayed value indicates whether UID uniqueness is enforced or not, and you require this value in later steps.
Determine a unique identifier:
If UID uniqueness is enforced (
1
), display the UID stored in the<device_path>/uid
file, for example:# cat /sys/devices/pci142d:00/142d:00:00.0/uid
If UID uniqueness is not enforced (
0
), display the FID stored in the<device_path>/function_id
file, for example:# cat /sys/devices/pci142d:00/142d:00:00.0/function_id
The outputs of the commands display the UID and FID values in hexadecimal.
Convert the hexadecimal identifier to decimal, for example:
# printf "%d\n" 0x00001402 5122
To determine the predictable device name, append the identifier in decimal format to the corresponding prefix based on whether UID uniqueness is enforced or not:
-
If UID uniqueness is enforced, append the identifier to the
eno
prefix, for exampleeno5122
. -
If UID uniqueness is not enforced, append the identifier to the
ens
prefix, for exampleens5122
.
-
If UID uniqueness is enforced, append the identifier to the
Next steps
Use one of the following methods to rename the interface to the predictable name:
Additional resources
- IBM documentation: Network interface names
-
systemd.net-naming-scheme(7)
man page on your system
1.6. Customizing the prefix for Ethernet interfaces during installation
If you do not want to use the default device-naming policy for Ethernet interfaces, you can set a custom device prefix during the Red Hat Enterprise Linux (RHEL) installation.
Red Hat supports systems with customized Ethernet prefixes only if you set the prefix during the RHEL installation. Using the prefixdevname
utility on already deployed systems is not supported.
If you set a device prefix during the installation, the udev
service uses the <prefix><index>
format for Ethernet interfaces after the installation. For example, if you set the prefix net
, the service assigns the names net0
, net1
, and so on to the Ethernet interfaces.
The udev
service appends the index to the custom prefix, and preserves the index values of known Ethernet interfaces. If you add an interface, udev
assigns an index value that is one greater than the previously-assigned index value to the new interface.
Prerequisites
- The prefix consists of ASCII characters.
- The prefix is an alphanumeric string.
- The prefix is shorter than 16 characters.
-
The prefix does not conflict with any other well-known network interface prefix, such as
eth
,eno
,ens
, andem
.
Procedure
- Boot the Red Hat Enterprise Linux installation media.
In the boot manager, follow these steps:
-
Select the
Install Red Hat Enterprise Linux <version>
entry. - Press Tab to edit the entry.
-
Append
net.ifnames.prefix=<prefix>
to the kernel options. - Press Enter to start the installation program.
-
Select the
- Install Red Hat Enterprise Linux.
Verification
To verify the interface names, display the network interfaces:
# ip link show ... 2: net0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...
Additional resources
1.7. Configuring user-defined network interface names by using udev rules
You can use udev
rules to implement custom network interface names that reflect your organization’s requirements.
Procedure
Identify the network interface that you want to rename:
# ip link show ... enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...
Record the MAC address of the interface.
Display the device type ID of the interface:
# cat /sys/class/net/enp1s0/type 1
Create the
/etc/udev/rules.d/70-persistent-net.rules
file, and add a rule for each interface that you want to rename:SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="<MAC_address>",ATTR{type}=="<device_type_id>",NAME="<new_interface_name>"
ImportantUse only
70-persistent-net.rules
as a file name if you require consistent device names during the boot process. Thedracut
utility adds a file with this name to theinitrd
image if you regenerate the RAM disk image.For example, use the following rule to rename the interface with MAC address
00:00:5e:00:53:1a
toprovider0
:SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="00:00:5e:00:53:1a",ATTR{type}=="1",NAME="provider0"
Optional: Regenerate the
initrd
RAM disk image:# dracut -f
You require this step only if you need networking capabilities in the RAM disk. For example, this is the case if the root file system is stored on a network device, such as iSCSI.
Identify which NetworkManager connection profile uses the interface that you want to rename:
# nmcli -f device,name connection show DEVICE NAME enp1s0 example_profile ...
Unset the
connection.interface-name
property in the connection profile:# nmcli connection modify example_profile connection.interface-name ""
Temporarily, configure the connection profile to match both the new and the previous interface name:
# nmcli connection modify example_profile match.interface-name "provider0 enp1s0"
Reboot the system:
# reboot
Verify that the device with the MAC address that you specified in the link file has been renamed to
provider0
:# ip link show provider0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...
Configure the connection profile to match only the new interface name:
# nmcli connection modify example_profile match.interface-name "provider0"
You have now removed the old interface name from the connection profile.
Reactivate the connection profile:
# nmcli connection up example_profile
Additional resources
-
udev(7)
man page on your system
1.8. Configuring user-defined network interface names by using systemd link files
You can use systemd
link files to implement custom network interface names that reflect your organization’s requirements.
Prerequisites
- You must meet one of these conditions: NetworkManager does not manage this interface, or the corresponding connection profile uses the keyfile format.
Procedure
Identify the network interface that you want to rename:
# ip link show ... enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...
Record the MAC address of the interface.
If it does not already exist, create the
/etc/systemd/network/
directory:# mkdir -p /etc/systemd/network/
For each interface that you want to rename, create a
70-*.link
file in the/etc/systemd/network/
directory with the following content:[Match] MACAddress=<MAC_address> [Link] Name=<new_interface_name>
ImportantUse a file name with a
70-
prefix to keep the file names consistent with theudev
rules-based solution.For example, create the
/etc/systemd/network/70-provider0.link
file with the following content to rename the interface with MAC address00:00:5e:00:53:1a
toprovider0
:[Match] MACAddress=00:00:5e:00:53:1a [Link] Name=provider0
Optional: Regenerate the
initrd
RAM disk image:# dracut -f
You require this step only if you need networking capabilities in the RAM disk. For example, this is the case if the root file system is stored on a network device, such as iSCSI.
Identify which NetworkManager connection profile uses the interface that you want to rename:
# nmcli -f device,name connection show DEVICE NAME enp1s0 example_profile ...
Unset the
connection.interface-name
property in the connection profile:# nmcli connection modify example_profile connection.interface-name ""
Temporarily, configure the connection profile to match both the new and the previous interface name:
# nmcli connection modify example_profile match.interface-name "provider0 enp1s0"
Reboot the system:
# reboot
Verify that the device with the MAC address that you specified in the link file has been renamed to
provider0
:# ip link show provider0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...
Configure the connection profile to match only the new interface name:
# nmcli connection modify example_profile match.interface-name "provider0"
You have now removed the old interface name from the connection profile.
Reactivate the connection profile.
# nmcli connection up example_profile
Additional resources
-
systemd.link(5)
man page on your system
1.9. Assigning alternative names to a network interface by using systemd link files
With alternative interface naming, the kernel can assign additional names to network interfaces. You can use these alternative names in the same way as the normal interface names in commands that require a network interface name.
Prerequisites
- You must use ASCII characters for the alternative name.
- The alternative name must be shorter than 128 characters.
Procedure
Display the network interface names and their MAC addresses:
# ip link show ... enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...
Record the MAC address of the interface to which you want to assign an alternative name.
If it does not already exist, create the
/etc/systemd/network/
directory:# mkdir -p /etc/systemd/network/
For each interface that must have an alternative name, create a
*.link
file in the/etc/systemd/network/
directory with the following content:[Match] MACAddress=<MAC_address> [Link] AlternativeName=<alternative_interface_name_1> AlternativeName=<alternative_interface_name_2> AlternativeName=<alternative_interface_name_n>
For example, create the
/etc/systemd/network/70-altname.link
file with the following content to assignprovider
as an alternative name to the interface with MAC address00:00:5e:00:53:1a
:[Match] MACAddress=00:00:5e:00:53:1a [Link] AlternativeName=provider
Regenerate the
initrd
RAM disk image:# dracut -f
Reboot the system:
# reboot
Verification
Use the alternative interface name. For example, display the IP address settings of the device with the alternative name
provider
:# ip address show provider 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff altname provider ...
Additional resources
- What is AlternativeNamesPolicy in Interface naming scheme? (Red Hat Knowledgebase)
Chapter 2. Configuring an Ethernet connection
NetworkManager creates a connection profile for each Ethernet adapter that is installed in a host. By default, this profile uses DHCP for both IPv4 and IPv6 connections. Modify this automatically-created profile or add a new one in the following cases:
- The network requires custom settings, such as a static IP address configuration.
- You require multiple profiles because the host roams among different networks.
Red Hat Enterprise Linux provides administrators different options to configure Ethernet connections. For example:
-
Use
nmcli
to configure connections on the command line. -
Use
nmtui
to configure connections in a text-based user interface. -
Use the GNOME Settings menu or
nm-connection-editor
application to configure connections in a graphical interface. -
Use
nmstatectl
to configure connections through the Nmstate API. - Use RHEL system roles to automate the configuration of connections on one or multiple hosts.
If you want to manually configure Ethernet connections on hosts running in the Microsoft Azure cloud, disable the cloud-init
service or configure it to ignore the network settings retrieved from the cloud environment. Otherwise, cloud-init
will override on the next reboot the network settings that you have manually configured.
2.1. Configuring an Ethernet connection by using nmcli
If you connect a host to the network over Ethernet, you can manage the connection’s settings on the command line by using the nmcli
utility.
Prerequisites
- A physical or virtual Ethernet Network Interface Controller (NIC) exists in the server’s configuration.
Procedure
List the NetworkManager connection profiles:
# nmcli connection show NAME UUID TYPE DEVICE Wired connection 1 a5eb6490-cc20-3668-81f8-0314a27f3f75 ethernet enp1s0
By default, NetworkManager creates a profile for each NIC in the host. If you plan to connect this NIC only to a specific network, adapt the automatically-created profile. If you plan to connect this NIC to networks with different settings, create individual profiles for each network.
If you want to create an additional connection profile, enter:
# nmcli connection add con-name <connection-name> ifname <device-name> type ethernet
Skip this step to modify an existing profile.
Optional: Rename the connection profile:
# nmcli connection modify "Wired connection 1" connection.id "Internal-LAN"
On hosts with multiple profiles, a meaningful name makes it easier to identify the purpose of a profile.
Display the current settings of the connection profile:
# nmcli connection show Internal-LAN ... connection.interface-name: enp1s0 connection.autoconnect: yes ipv4.method: auto ipv6.method: auto ...
Configure the IPv4 settings:
To use DHCP, enter:
# nmcli connection modify Internal-LAN ipv4.method auto
Skip this step if
ipv4.method
is already set toauto
(default).To set a static IPv4 address, network mask, default gateway, DNS servers, and search domain, enter:
# nmcli connection modify Internal-LAN ipv4.method manual ipv4.addresses 192.0.2.1/24 ipv4.gateway 192.0.2.254 ipv4.dns 192.0.2.200 ipv4.dns-search example.com
Configure the IPv6 settings:
To use stateless address autoconfiguration (SLAAC), enter:
# nmcli connection modify Internal-LAN ipv6.method auto
Skip this step if
ipv6.method
is already set toauto
(default).To set a static IPv6 address, network mask, default gateway, DNS servers, and search domain, enter:
# nmcli connection modify Internal-LAN ipv6.method manual ipv6.addresses 2001:db8:1::fffe/64 ipv6.gateway 2001:db8:1::fffe ipv6.dns 2001:db8:1::ffbb ipv6.dns-search example.com
To customize other settings in the profile, use the following command:
# nmcli connection modify <connection-name> <setting> <value>
Enclose values with spaces or semicolons in quotes.
Activate the profile:
# nmcli connection up Internal-LAN
Verification
Display the IP settings of the NIC:
# ip address show enp1s0 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 52:54:00:17:b8:b6 brd ff:ff:ff:ff:ff:ff inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute enp1s0 valid_lft forever preferred_lft forever inet6 2001:db8:1::fffe/64 scope global noprefixroute valid_lft forever preferred_lft forever
Display the IPv4 default gateway:
# ip route show default default via 192.0.2.254 dev enp1s0 proto static metric 102
Display the IPv6 default gateway:
# ip -6 route show default default via 2001:db8:1::ffee dev enp1s0 proto static metric 102 pref medium
Display the DNS settings:
# cat /etc/resolv.conf search example.com nameserver 192.0.2.200 nameserver 2001:db8:1::ffbb
If multiple connection profiles are active at the same time, the order of
nameserver
entries depend on the DNS priority values in these profile and the connection types.Use the
ping
utility to verify that this host can send packets to other hosts:# ping <host-name-or-IP-address>
Troubleshooting
- Verify that the network cable is plugged-in to the host and a switch.
- Check whether the link failure exists only on this host or also on other hosts connected to the same switch.
- Verify that the network cable and the network interface are working as expected. Perform hardware diagnosis steps and replace defect cables and network interface cards.
- If the configuration on the disk does not match the configuration on the device, starting or restarting NetworkManager creates an in-memory connection that reflects the configuration of the device. For further details and how to avoid this problem, see the NetworkManager duplicates a connection after restart of NetworkManager service solution.
Additional resources
-
nm-settings(5)
man page on your system
2.2. Configuring an Ethernet connection by using the nmcli
interactive editor
If you connect a host to the network over Ethernet, you can manage the connection’s settings on the command line by using the nmcli
utility.
Prerequisites
- A physical or virtual Ethernet Network Interface Controller (NIC) exists in the server’s configuration.
Procedure
List the NetworkManager connection profiles:
# nmcli connection show NAME UUID TYPE DEVICE Wired connection 1 a5eb6490-cc20-3668-81f8-0314a27f3f75 ethernet enp1s0
By default, NetworkManager creates a profile for each NIC in the host. If you plan to connect this NIC only to a specific network, adapt the automatically-created profile. If you plan to connect this NIC to networks with different settings, create individual profiles for each network.
Start
nmcli
in interactive mode:To create an additional connection profile, enter:
# nmcli connection edit type ethernet con-name "<connection-name>"
To modify an existing connection profile, enter:
# nmcli connection edit con-name "<connection-name>"
Optional: Rename the connection profile:
nmcli> set connection.id Internal-LAN
On hosts with multiple profiles, a meaningful name makes it easier to identify the purpose of a profile.
Do not use quotes to set an ID that contains spaces to avoid that
nmcli
makes the quotes part of the name. For example, to setExample Connection
as ID, enterset connection.id Example Connection
.Display the current settings of the connection profile:
nmcli> print ... connection.interface-name: enp1s0 connection.autoconnect: yes ipv4.method: auto ipv6.method: auto ...
If you create a new connection profile, set the network interface:
nmcli> set connection.interface-name enp1s0
Configure the IPv4 settings:
To use DHCP, enter:
nmcli> set ipv4.method auto
Skip this step if
ipv4.method
is already set toauto
(default).To set a static IPv4 address, network mask, default gateway, DNS servers, and search domain, enter:
nmcli> ipv4.addresses 192.0.2.1/24 Do you also want to set 'ipv4.method' to 'manual'? [yes]: yes nmcli> ipv4.gateway 192.0.2.254 nmcli> ipv4.dns 192.0.2.200 nmcli> ipv4.dns-search example.com
Configure the IPv6 settings:
To use stateless address autoconfiguration (SLAAC), enter:
nmcli> set ipv6.method auto
Skip this step if
ipv6.method
is already set toauto
(default).To set a static IPv6 address, network mask, default gateway, DNS servers, and search domain, enter:
nmcli> ipv6.addresses 2001:db8:1::fffe/64 Do you also want to set 'ipv6.method' to 'manual'? [yes]: yes nmcli> ipv6.gateway 2001:db8:1::fffe nmcli> ipv6.dns 2001:db8:1::ffbb nmcli> ipv6.dns-search example.com
Save and activate the connection:
nmcli> save persistent
Leave the interactive mode:
nmcli> quit
Verification
Display the IP settings of the NIC:
# ip address show enp1s0 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 52:54:00:17:b8:b6 brd ff:ff:ff:ff:ff:ff inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute enp1s0 valid_lft forever preferred_lft forever inet6 2001:db8:1::fffe/64 scope global noprefixroute valid_lft forever preferred_lft forever
Display the IPv4 default gateway:
# ip route show default default via 192.0.2.254 dev enp1s0 proto static metric 102
Display the IPv6 default gateway:
# ip -6 route show default default via 2001:db8:1::ffee dev enp1s0 proto static metric 102 pref medium
Display the DNS settings:
# cat /etc/resolv.conf search example.com nameserver 192.0.2.200 nameserver 2001:db8:1::ffbb
If multiple connection profiles are active at the same time, the order of
nameserver
entries depend on the DNS priority values in these profile and the connection types.Use the
ping
utility to verify that this host can send packets to other hosts:# ping <host-name-or-IP-address>
Troubleshooting
- Verify that the network cable is plugged-in to the host and a switch.
- Check whether the link failure exists only on this host or also on other hosts connected to the same switch.
- Verify that the network cable and the network interface are working as expected. Perform hardware diagnosis steps and replace defect cables and network interface cards.
- If the configuration on the disk does not match the configuration on the device, starting or restarting NetworkManager creates an in-memory connection that reflects the configuration of the device. For further details and how to avoid this problem, see the NetworkManager duplicates a connection after restart of NetworkManager service solution
Additional resources
-
nm-settings(5)
andnmcli(1)
man pages on your system
2.3. Configuring an Ethernet connection by using nmtui
If you connect a host to the network over Ethernet, you can manage the connection’s settings in a text-based user interface by using the nmtui
application. Use nmtui
to create new profiles and to update existing ones on a host without a graphical interface.
In nmtui
:
- Navigate by using the cursor keys.
- Press a button by selecting it and hitting Enter.
- Select and clear checkboxes by using Space.
Prerequisites
- A physical or virtual Ethernet Network Interface Controller (NIC) exists in the server’s configuration.
Procedure
If you do not know the network device name you want to use in the connection, display the available devices:
# nmcli device status DEVICE TYPE STATE CONNECTION enp1s0 ethernet unavailable -- ...
Start
nmtui
:# nmtui
- Select Edit a connection, and press Enter.
Choose whether to add a new connection profile or to modify an existing one:
To create a new profile:
- Press Add.
- Select Ethernet from the list of network types, and press Enter.
- To modify an existing profile, select the profile from the list, and press Enter.
Optional: Update the name of the connection profile.
On hosts with multiple profiles, a meaningful name makes it easier to identify the purpose of a profile.
- If you create a new connection profile, enter the network device name into the Device field.
Depending on your environment, configure the IP address settings in the
IPv4 configuration
andIPv6 configuration
areas accordingly. For this, press the button next to these areas, and select:- Disabled, if this connection does not require an IP address.
- Automatic, if a DHCP server dynamically assigns an IP address to this NIC.
Manual, if the network requires static IP address settings. In this case, you must fill further fields:
- Press Show next to the protocol you want to configure to display additional fields.
Press Add next to Addresses, and enter the IP address and the subnet mask in Classless Inter-Domain Routing (CIDR) format.
If you do not specify a subnet mask, NetworkManager sets a
/32
subnet mask for IPv4 addresses and/64
for IPv6 addresses.- Enter the address of the default gateway.
- Press Add next to DNS servers, and enter the DNS server address.
- Press Add next to Search domains, and enter the DNS search domain.
Figure 2.1. Example of an Ethernet connection with static IP address settings
- Press OK to create and automatically activate the new connection.
- Press Back to return to the main menu.
-
Select Quit, and press Enter to close the
nmtui
application.
Verification
Display the IP settings of the NIC:
# ip address show enp1s0 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 52:54:00:17:b8:b6 brd ff:ff:ff:ff:ff:ff inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute enp1s0 valid_lft forever preferred_lft forever inet6 2001:db8:1::fffe/64 scope global noprefixroute valid_lft forever preferred_lft forever
Display the IPv4 default gateway:
# ip route show default default via 192.0.2.254 dev enp1s0 proto static metric 102
Display the IPv6 default gateway:
# ip -6 route show default default via 2001:db8:1::ffee dev enp1s0 proto static metric 102 pref medium
Display the DNS settings:
# cat /etc/resolv.conf search example.com nameserver 192.0.2.200 nameserver 2001:db8:1::ffbb
If multiple connection profiles are active at the same time, the order of
nameserver
entries depend on the DNS priority values in these profile and the connection types.Use the
ping
utility to verify that this host can send packets to other hosts:# ping <host-name-or-IP-address>
Troubleshooting
- Verify that the network cable is plugged-in to the host and a switch.
- Check whether the link failure exists only on this host or also on other hosts connected to the same switch.
- Verify that the network cable and the network interface are working as expected. Perform hardware diagnosis steps and replace defect cables and network interface cards.
- If the configuration on the disk does not match the configuration on the device, starting or restarting NetworkManager creates an in-memory connection that reflects the configuration of the device. For further details and how to avoid this problem, see the NetworkManager duplicates a connection after restart of NetworkManager service solution.
2.4. Configuring an Ethernet connection by using control-center
If you connect a host to the network over Ethernet, you can manage the connection’s settings with a graphical interface by using the GNOME Settings menu.
Note that control-center
does not support as many configuration options as the nm-connection-editor
application or the nmcli
utility.
Prerequisites
- A physical or virtual Ethernet Network Interface Controller (NIC) exists in the server’s configuration.
- GNOME is installed.
Procedure
-
Press the Super key, enter
Settings
, and press Enter. - Select Network in the navigation on the left.
Choose whether to add a new connection profile or to modify an existing one:
- To create a new profile, click the Ethernet entry. button next to the
- To modify an existing profile, click the gear icon next to the profile entry.
Optional: On the Identity tab, update the name of the connection profile.
On hosts with multiple profiles, a meaningful name makes it easier to identify the purpose of a profile.
Depending on your environment, configure the IP address settings on the IPv4 and IPv6 tabs accordingly:
-
To use DHCP or IPv6 stateless address autoconfiguration (SLAAC), select
Automatic (DHCP)
as method (default). To set a static IP address, network mask, default gateway, DNS servers, and search domain, select
Manual
as method, and fill the fields on the tabs:
-
To use DHCP or IPv6 stateless address autoconfiguration (SLAAC), select
Depending on whether you add or modify a connection profile, click the
or button to save the connection.The GNOME
control-center
automatically activates the connection.
Verification
Display the IP settings of the NIC:
# ip address show enp1s0 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 52:54:00:17:b8:b6 brd ff:ff:ff:ff:ff:ff inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute enp1s0 valid_lft forever preferred_lft forever inet6 2001:db8:1::fffe/64 scope global noprefixroute valid_lft forever preferred_lft forever
Display the IPv4 default gateway:
# ip route show default default via 192.0.2.254 dev enp1s0 proto static metric 102
Display the IPv6 default gateway:
# ip -6 route show default default via 2001:db8:1::ffee dev enp1s0 proto static metric 102 pref medium
Display the DNS settings:
# cat /etc/resolv.conf search example.com nameserver 192.0.2.200 nameserver 2001:db8:1::ffbb
If multiple connection profiles are active at the same time, the order of
nameserver
entries depend on the DNS priority values in these profile and the connection types.Use the
ping
utility to verify that this host can send packets to other hosts:# ping <host-name-or-IP-address>
Troubleshooting steps
- Verify that the network cable is plugged-in to the host and a switch.
- Check whether the link failure exists only on this host or also on other hosts connected to the same switch.
- Verify that the network cable and the network interface are working as expected. Perform hardware diagnosis steps and replace defect cables and network interface cards.
- If the configuration on the disk does not match the configuration on the device, starting or restarting NetworkManager creates an in-memory connection that reflects the configuration of the device. For further details and how to avoid this problem, see the NetworkManager duplicates a connection after restart of NetworkManager service solution.
2.5. Configuring an Ethernet connection by using nm-connection-editor
If you connect a host to the network over Ethernet, you can manage the connection’s settings with a graphical interface by using the nm-connection-editor application.
Prerequisites
- A physical or virtual Ethernet Network Interface Controller (NIC) exists in the server’s configuration.
- GNOME is installed.
Procedure
Open a terminal, and enter:
$ nm-connection-editor
Choose whether to add a new connection profile or to modify an existing one:
To create a new profile:
- Click the button
- Select Ethernet as connection type, and click .
- To modify an existing profile, double-click the profile entry.
Optional: Update the name of the profile in the Connection Name field.
On hosts with multiple profiles, a meaningful name makes it easier to identify the purpose of a profile.
If you create a new profile, select the device on the
Ethernet
tab:Depending on your environment, configure the IP address settings on the IPv4 Settings and IPv6 Settings tabs accordingly:
-
To use DHCP or IPv6 stateless address autoconfiguration (SLAAC), select
Automatic (DHCP)
as method (default). To set a static IP address, network mask, default gateway, DNS servers, and search domain, select
Manual
as method, and fill the fields on the tabs:
-
To use DHCP or IPv6 stateless address autoconfiguration (SLAAC), select
- Click .
- Close nm-connection-editor.
Verification
Display the IP settings of the NIC:
# ip address show enp1s0 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 52:54:00:17:b8:b6 brd ff:ff:ff:ff:ff:ff inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute enp1s0 valid_lft forever preferred_lft forever inet6 2001:db8:1::fffe/64 scope global noprefixroute valid_lft forever preferred_lft forever
Display the IPv4 default gateway:
# ip route show default default via 192.0.2.254 dev enp1s0 proto static metric 102
Display the IPv6 default gateway:
# ip -6 route show default default via 2001:db8:1::ffee dev enp1s0 proto static metric 102 pref medium
Display the DNS settings:
# cat /etc/resolv.conf search example.com nameserver 192.0.2.200 nameserver 2001:db8:1::ffbb
If multiple connection profiles are active at the same time, the order of
nameserver
entries depend on the DNS priority values in these profile and the connection types.Use the
ping
utility to verify that this host can send packets to other hosts:# ping <host-name-or-IP-address>
Troubleshooting steps
- Verify that the network cable is plugged-in to the host and a switch.
- Check whether the link failure exists only on this host or also on other hosts connected to the same switch.
- Verify that the network cable and the network interface are working as expected. Perform hardware diagnosis steps and replace defect cables and network interface cards.
- If the configuration on the disk does not match the configuration on the device, starting or restarting NetworkManager creates an in-memory connection that reflects the configuration of the device. For further details and how to avoid this problem, see the NetworkManager duplicates a connection after restart of NetworkManager service solution.
2.6. Configuring an Ethernet connection with a static IP address by using nmstatectl
Use the nmstatectl
utility to configure an Ethernet connection through the Nmstate API. The Nmstate API ensures that, after setting the configuration, the result matches the configuration file. If anything fails, nmstatectl
automatically rolls back the changes to avoid leaving the system in an incorrect state.
Prerequisites
- A physical or virtual Ethernet Network Interface Controller (NIC) exists in the server’s configuration.
-
The
nmstate
package is installed.
Procedure
Create a YAML file, for example
~/create-ethernet-profile.yml
, with the following content:--- interfaces: - name: enp1s0 type: ethernet state: up ipv4: enabled: true address: - ip: 192.0.2.1 prefix-length: 24 dhcp: false ipv6: enabled: true address: - ip: 2001:db8:1::1 prefix-length: 64 autoconf: false dhcp: false routes: config: - destination: 0.0.0.0/0 next-hop-address: 192.0.2.254 next-hop-interface: enp1s0 - destination: ::/0 next-hop-address: 2001:db8:1::fffe next-hop-interface: enp1s0 dns-resolver: config: search: - example.com server: - 192.0.2.200 - 2001:db8:1::ffbb
These settings define an Ethernet connection profile for the
enp1s0
device with the following settings:-
A static IPv4 address -
192.0.2.1
with the/24
subnet mask -
A static IPv6 address -
2001:db8:1::1
with the/64
subnet mask -
An IPv4 default gateway -
192.0.2.254
-
An IPv6 default gateway -
2001:db8:1::fffe
-
An IPv4 DNS server -
192.0.2.200
-
An IPv6 DNS server -
2001:db8:1::ffbb
-
A DNS search domain -
example.com
-
A static IPv4 address -
Apply the settings to the system:
# nmstatectl apply ~/create-ethernet-profile.yml
Verification
Display the current state in YAML format:
# nmstatectl show enp1s0
Display the IP settings of the NIC:
# ip address show enp1s0 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 52:54:00:17:b8:b6 brd ff:ff:ff:ff:ff:ff inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute enp1s0 valid_lft forever preferred_lft forever inet6 2001:db8:1::fffe/64 scope global noprefixroute valid_lft forever preferred_lft forever
Display the IPv4 default gateway:
# ip route show default default via 192.0.2.254 dev enp1s0 proto static metric 102
Display the IPv6 default gateway:
# ip -6 route show default default via 2001:db8:1::ffee dev enp1s0 proto static metric 102 pref medium
Display the DNS settings:
# cat /etc/resolv.conf search example.com nameserver 192.0.2.200 nameserver 2001:db8:1::ffbb
If multiple connection profiles are active at the same time, the order of
nameserver
entries depend on the DNS priority values in these profile and the connection types.Use the
ping
utility to verify that this host can send packets to other hosts:# ping <host-name-or-IP-address>
Additional resources
-
nmstatectl(8)
man page on your system -
/usr/share/doc/nmstate/examples/
directory
2.7. Configuring an Ethernet connection with a static IP address by using the network
RHEL system role with an interface name
To connect a Red Hat Enterprise Linux host to an Ethernet network, create a NetworkManager connection profile for the network device. By using Ansible and the network
RHEL system role, you can automate this process and remotely configure connection profiles on the hosts defined in a playbook.
You can use the network
RHEL system role to configure an Ethernet connection with static IP addresses, gateways, and DNS settings, and assign them to a specified interface name.
Typically, administrators want to reuse a playbook and not maintain individual playbooks for each host to which Ansible should assign static IP addresses. In this case, you can use variables in the playbook and maintain the settings in the inventory. As a result, you need only one playbook to dynamically assign individual settings to multiple hosts.
Prerequisites
- You have prepared the control node and the managed nodes
- You are logged in to the control node as a user who can run playbooks on the managed nodes.
-
The account you use to connect to the managed nodes has
sudo
permissions on them. - A physical or virtual Ethernet device exists in the server configuration.
- The managed nodes use NetworkManager to configure the network.
Procedure
Edit the
~/inventory
file, and append the host-specific settings to the host entries:managed-node-01.example.com interface=enp1s0 ip_v4=192.0.2.1/24 ip_v6=2001:db8:1::1/64 gateway_v4=192.0.2.254 gateway_v6=2001:db8:1::fffe managed-node-02.example.com interface=enp1s0 ip_v4=192.0.2.2/24 ip_v6=2001:db8:1::2/64 gateway_v4=192.0.2.254 gateway_v6=2001:db8:1::fffe
Create a playbook file, for example
~/playbook.yml
, with the following content:--- - name: Configure the network hosts: managed-node-01.example.com,managed-node-02.example.com tasks: - name: Ethernet connection profile with static IP address settings ansible.builtin.include_role: name: rhel-system-roles.network vars: network_connections: - name: "{{ interface }}" interface_name: "{{ interface }}" type: ethernet autoconnect: yes ip: address: - "{{ ip_v4 }}" - "{{ ip_v6 }}" gateway4: "{{ gateway_v4 }}" gateway6: "{{ gateway_v6 }}" dns: - 192.0.2.200 - 2001:db8:1::ffbb dns_search: - example.com state: up
This playbook reads certain values dynamically for each host from the inventory file and uses static values in the playbook for settings which are the same for all hosts.
For details about all variables used in the playbook, see the
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file on the control node.Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/playbook.yml
Note that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook ~/playbook.yml
Verification
Query the Ansible facts of the managed node and verify the active network settings:
# ansible managed-node-01.example.com -m ansible.builtin.setup ... "ansible_default_ipv4": { "address": "192.0.2.1", "alias": "enp1s0", "broadcast": "192.0.2.255", "gateway": "192.0.2.254", "interface": "enp1s0", "macaddress": "52:54:00:17:b8:b6", "mtu": 1500, "netmask": "255.255.255.0", "network": "192.0.2.0", "prefix": "24", "type": "ether" }, "ansible_default_ipv6": { "address": "2001:db8:1::1", "gateway": "2001:db8:1::fffe", "interface": "enp1s0", "macaddress": "52:54:00:17:b8:b6", "mtu": 1500, "prefix": "64", "scope": "global", "type": "ether" }, ... "ansible_dns": { "nameservers": [ "192.0.2.1", "2001:db8:1::ffbb" ], "search": [ "example.com" ] }, ...
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
/usr/share/doc/rhel-system-roles/network/
directory
2.8. Configuring an Ethernet connection with a static IP address by using the network
RHEL system role with a device path
To connect a Red Hat Enterprise Linux host to an Ethernet network, create a NetworkManager connection profile for the network device. By using Ansible and the network
RHEL system role, you can automate this process and remotely configure connection profiles on the hosts defined in a playbook.
You can use the network
RHEL system role to configure an Ethernet connection with static IP addresses, gateways, and DNS settings, and assign them to a device based on its path instead of its name.
Prerequisites
- You have prepared the control node and the managed nodes
- You are logged in to the control node as a user who can run playbooks on the managed nodes.
-
The account you use to connect to the managed nodes has
sudo
permissions on them. - A physical or virtual Ethernet device exists in the servers configuration.
- The managed nodes use NetworkManager to configure the network.
-
You know the path of the device. You can display the device path by using the
udevadm info /sys/class/net/<device_name> | grep ID_PATH=
command.
Procedure
Create a playbook file, for example
~/playbook.yml
, with the following content:--- - name: Configure the network hosts: managed-node-01.example.com tasks: - name: Ethernet connection profile with static IP address settings ansible.builtin.include_role: name: rhel-system-roles.network vars: network_connections: - name: example match: path: - pci-0000:00:0[1-3].0 - &!pci-0000:00:02.0 type: ethernet autoconnect: yes ip: address: - 192.0.2.1/24 - 2001:db8:1::1/64 gateway4: 192.0.2.254 gateway6: 2001:db8:1::fffe dns: - 192.0.2.200 - 2001:db8:1::ffbb dns_search: - example.com state: up
The settings specified in the example playbook include the following:
match
-
Defines that a condition must be met in order to apply the settings. You can only use this variable with the
path
option. path
-
Defines the persistent path of a device. You can set it as a fixed path or an expression. Its value can contain modifiers and wildcards. The example applies the settings to devices that match PCI ID
0000:00:0[1-3].0
, but not0000:00:02.0
.
For details about all variables used in the playbook, see the
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file on the control node.Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/playbook.yml
Note that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook ~/playbook.yml
Verification
Query the Ansible facts of the managed node and verify the active network settings:
# ansible managed-node-01.example.com -m ansible.builtin.setup ... "ansible_default_ipv4": { "address": "192.0.2.1", "alias": "enp1s0", "broadcast": "192.0.2.255", "gateway": "192.0.2.254", "interface": "enp1s0", "macaddress": "52:54:00:17:b8:b6", "mtu": 1500, "netmask": "255.255.255.0", "network": "192.0.2.0", "prefix": "24", "type": "ether" }, "ansible_default_ipv6": { "address": "2001:db8:1::1", "gateway": "2001:db8:1::fffe", "interface": "enp1s0", "macaddress": "52:54:00:17:b8:b6", "mtu": 1500, "prefix": "64", "scope": "global", "type": "ether" }, ... "ansible_dns": { "nameservers": [ "192.0.2.1", "2001:db8:1::ffbb" ], "search": [ "example.com" ] }, ...
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
/usr/share/doc/rhel-system-roles/network/
directory
2.9. Configuring an Ethernet connection with a dynamic IP address by using nmstatectl
Use the nmstatectl
utility to configure an Ethernet connection through the Nmstate API. The Nmstate API ensures that, after setting the configuration, the result matches the configuration file. If anything fails, nmstatectl
automatically rolls back the changes to avoid leaving the system in an incorrect state.
Prerequisites
- A physical or virtual Ethernet Network Interface Controller (NIC) exists in the server’s configuration.
- A DHCP server is available in the network.
-
The
nmstate
package is installed.
Procedure
Create a YAML file, for example
~/create-ethernet-profile.yml
, with the following content:--- interfaces: - name: enp1s0 type: ethernet state: up ipv4: enabled: true auto-dns: true auto-gateway: true auto-routes: true dhcp: true ipv6: enabled: true auto-dns: true auto-gateway: true auto-routes: true autoconf: true dhcp: true
These settings define an Ethernet connection profile for the
enp1s0
device. The connection retrieves IPv4 addresses, IPv6 addresses, default gateway, routes, DNS servers, and search domains from a DHCP server and IPv6 stateless address autoconfiguration (SLAAC).Apply the settings to the system:
# nmstatectl apply ~/create-ethernet-profile.yml
Verification
Display the current state in YAML format:
# nmstatectl show enp1s0
Display the IP settings of the NIC:
# ip address show enp1s0 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 52:54:00:17:b8:b6 brd ff:ff:ff:ff:ff:ff inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute enp1s0 valid_lft forever preferred_lft forever inet6 2001:db8:1::fffe/64 scope global noprefixroute valid_lft forever preferred_lft forever
Display the IPv4 default gateway:
# ip route show default default via 192.0.2.254 dev enp1s0 proto static metric 102
Display the IPv6 default gateway:
# ip -6 route show default default via 2001:db8:1::ffee dev enp1s0 proto static metric 102 pref medium
Display the DNS settings:
# cat /etc/resolv.conf search example.com nameserver 192.0.2.200 nameserver 2001:db8:1::ffbb
If multiple connection profiles are active at the same time, the order of
nameserver
entries depend on the DNS priority values in these profile and the connection types.Use the
ping
utility to verify that this host can send packets to other hosts:# ping <host-name-or-IP-address>
Additional resources
-
nmstatectl(8)
man page on your system -
/usr/share/doc/nmstate/examples/
directory
2.10. Configuring an Ethernet connection with a dynamic IP address by using the network
RHEL system role with an interface name
To connect a Red Hat Enterprise Linux host to an Ethernet network, create a NetworkManager connection profile for the network device. By using Ansible and the network
RHEL system role, you can automate this process and remotely configure connection profiles on the hosts defined in a playbook.
You can use the network
RHEL system role to configure an Ethernet connection that retrieves its IP addresses, gateways, and DNS settings from a DHCP server and IPv6 stateless address autoconfiguration (SLAAC). With this role you can assign the connection profile to the specified interface name.
Prerequisites
- You have prepared the control node and the managed nodes
- You are logged in to the control node as a user who can run playbooks on the managed nodes.
-
The account you use to connect to the managed nodes has
sudo
permissions on them. - A physical or virtual Ethernet device exists in the servers configuration.
- A DHCP server and SLAAC are available in the network.
- The managed nodes use the NetworkManager service to configure the network.
Procedure
Create a playbook file, for example
~/playbook.yml
, with the following content:--- - name: Configure the network hosts: managed-node-01.example.com tasks: - name: Ethernet connection profile with dynamic IP address settings ansible.builtin.include_role: name: rhel-system-roles.network vars: network_connections: - name: enp1s0 interface_name: enp1s0 type: ethernet autoconnect: yes ip: dhcp4: yes auto6: yes state: up
The settings specified in the example playbook include the following:
dhcp4: yes
- Enables automatic IPv4 address assignment from DHCP, PPP, or similar services.
auto6: yes
-
Enables IPv6 auto-configuration. By default, NetworkManager uses Router Advertisements. If the router announces the
managed
flag, NetworkManager requests an IPv6 address and prefix from a DHCPv6 server.
For details about all variables used in the playbook, see the
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file on the control node.Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/playbook.yml
Note that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook ~/playbook.yml
Verification
Query the Ansible facts of the managed node and verify that the interface received IP addresses and DNS settings:
# ansible managed-node-01.example.com -m ansible.builtin.setup ... "ansible_default_ipv4": { "address": "192.0.2.1", "alias": "enp1s0", "broadcast": "192.0.2.255", "gateway": "192.0.2.254", "interface": "enp1s0", "macaddress": "52:54:00:17:b8:b6", "mtu": 1500, "netmask": "255.255.255.0", "network": "192.0.2.0", "prefix": "24", "type": "ether" }, "ansible_default_ipv6": { "address": "2001:db8:1::1", "gateway": "2001:db8:1::fffe", "interface": "enp1s0", "macaddress": "52:54:00:17:b8:b6", "mtu": 1500, "prefix": "64", "scope": "global", "type": "ether" }, ... "ansible_dns": { "nameservers": [ "192.0.2.1", "2001:db8:1::ffbb" ], "search": [ "example.com" ] }, ...
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
/usr/share/doc/rhel-system-roles/network/
directory
2.11. Configuring an Ethernet connection with a dynamic IP address by using the network
RHEL system role with a device path
To connect a Red Hat Enterprise Linux host to an Ethernet network, create a NetworkManager connection profile for the network device. By using Ansible and the network
RHEL system role, you can automate this process and remotely configure connection profiles on the hosts defined in a playbook.
You can use the network
RHEL system role to configure an Ethernet connection that retrieves its IP addresses, gateways, and DNS settings from a DHCP server and IPv6 stateless address autoconfiguration (SLAAC). The role can assign the connection profile to a device based on its path instead of an interface name.
Prerequisites
- You have prepared the control node and the managed nodes
- You are logged in to the control node as a user who can run playbooks on the managed nodes.
-
The account you use to connect to the managed nodes has
sudo
permissions on them. - A physical or virtual Ethernet device exists in the servers configuration.
- A DHCP server and SLAAC are available in the network.
- The managed hosts use NetworkManager to configure the network.
-
You know the path of the device. You can display the device path by using the
udevadm info /sys/class/net/<device_name> | grep ID_PATH=
command.
Procedure
Create a playbook file, for example
~/playbook.yml
, with the following content:--- - name: Configure the network hosts: managed-node-01.example.com tasks: - name: Ethernet connection profile with dynamic IP address settings ansible.builtin.include_role: name: rhel-system-roles.network vars: network_connections: - name: example match: path: - pci-0000:00:0[1-3].0 - &!pci-0000:00:02.0 type: ethernet autoconnect: yes ip: dhcp4: yes auto6: yes state: up
The settings specified in the example playbook include the following:
match: path
-
Defines that a condition must be met in order to apply the settings. You can only use this variable with the
path
option. path: <path_and_expressions>
-
Defines the persistent path of a device. You can set it as a fixed path or an expression. Its value can contain modifiers and wildcards. The example applies the settings to devices that match PCI ID
0000:00:0[1-3].0
, but not0000:00:02.0
. dhcp4: yes
- Enables automatic IPv4 address assignment from DHCP, PPP, or similar services.
auto6: yes
-
Enables IPv6 auto-configuration. By default, NetworkManager uses Router Advertisements. If the router announces the
managed
flag, NetworkManager requests an IPv6 address and prefix from a DHCPv6 server.
For details about all variables used in the playbook, see the
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file on the control node.Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/playbook.yml
Note that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook ~/playbook.yml
Verification
Query the Ansible facts of the managed node and verify that the interface received IP addresses and DNS settings:
# ansible managed-node-01.example.com -m ansible.builtin.setup ... "ansible_default_ipv4": { "address": "192.0.2.1", "alias": "enp1s0", "broadcast": "192.0.2.255", "gateway": "192.0.2.254", "interface": "enp1s0", "macaddress": "52:54:00:17:b8:b6", "mtu": 1500, "netmask": "255.255.255.0", "network": "192.0.2.0", "prefix": "24", "type": "ether" }, "ansible_default_ipv6": { "address": "2001:db8:1::1", "gateway": "2001:db8:1::fffe", "interface": "enp1s0", "macaddress": "52:54:00:17:b8:b6", "mtu": 1500, "prefix": "64", "scope": "global", "type": "ether" }, ... "ansible_dns": { "nameservers": [ "192.0.2.1", "2001:db8:1::ffbb" ], "search": [ "example.com" ] }, ...
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
/usr/share/doc/rhel-system-roles/network/
directory
2.12. Configuring multiple Ethernet interfaces by using a single connection profile by interface name
In most cases, one connection profile contains the settings of one network device. However, NetworkManager also supports wildcards when you set the interface name in connection profiles. If a host roams between Ethernet networks with dynamic IP address assignment, you can use this feature to create a single connection profile that you can use for multiple Ethernet interfaces.
Prerequisites
- Multiple physical or virtual Ethernet devices exist in the server’s configuration.
- A DHCP server is available in the network.
- No connection profile exists on the host.
Procedure
Add a connection profile that applies to all interface names starting with
enp
:# nmcli connection add con-name "Wired connection 1" connection.multi-connect multiple match.interface-name enp* type ethernet
Verification
Display all settings of the single connection profile:
# nmcli connection show "Wired connection 1" connection.id: Wired connection 1 ... connection.multi-connect: 3 (multiple) match.interface-name:
enp*
...3
indicates the number of interfaces active on the connection profile at the same time, and not the number of network interfaces in the connection profile. The connection profile uses all devices that match the pattern in thematch.interface-name
parameter and, therefore, the connection profiles have the same Universally Unique Identifier (UUID).Display the status of the connections:
# nmcli connection show NAME UUID TYPE DEVICE ... Wired connection 1 6f22402e-c0cc-49cf-b702-eaf0cd5ea7d1 ethernet enp7s0 Wired connection 1 6f22402e-c0cc-49cf-b702-eaf0cd5ea7d1 ethernet enp8s0 Wired connection 1 6f22402e-c0cc-49cf-b702-eaf0cd5ea7d1 ethernet enp9s0
Additional resources
-
nmcli(1)
man page on your system -
nm-settings(5)
man page
2.13. Configuring a single connection profile for multiple Ethernet interfaces using PCI IDs
The PCI ID is a unique identifier of the devices connected to the system. The connection profile adds multiple devices by matching interfaces based on a list of PCI IDs. You can use this procedure to connect multiple device PCI IDs to the single connection profile.
Prerequisites
- Multiple physical or virtual Ethernet devices exist in the server’s configuration.
- A DHCP server is available in the network.
- No connection profile exists on the host.
Procedure
Identify the device path. For example, to display the device paths of all interfaces starting with
enp
, enter :# udevadm info /sys/class/net/enp | grep ID_PATH=* ... E: ID_PATH=pci-0000:07:00.0 E: ID_PATH=pci-0000:08:00.0
Add a connection profile that applies to all PCI IDs matching the
0000:00:0[7-8].0
expression:# nmcli connection add type ethernet connection.multi-connect multiple match.path "pci-0000:07:00.0 pci-0000:08:00.0" con-name "Wired connection 1"
Verification
Display the status of the connection:
# nmcli connection show NAME UUID TYPE DEVICE Wired connection 1 9cee0958-512f-4203-9d3d-b57af1d88466 ethernet enp7s0 Wired connection 1 9cee0958-512f-4203-9d3d-b57af1d88466 ethernet enp8s0 ...
To display all settings of the connection profile:
# nmcli connection show "Wired connection 1" connection.id: Wired connection 1 ... connection.multi-connect: 3 (multiple) match.path: pci-0000:07:00.0,pci-0000:08:00.0 ...
This connection profile uses all devices with a PCI ID which match the pattern in the
match.path
parameter and, therefore, the connection profiles have the same Universally Unique Identifier (UUID).
Additional resources
-
nmcli(1)
man page on your system -
nm-settings(5)
man page
Chapter 3. Configuring a network bond
A network bond is a method to combine or aggregate physical and virtual network interfaces to provide a logical interface with higher throughput or redundancy. In a bond, the kernel handles all operations exclusively. You can create bonds on different types of devices, such as Ethernet devices or VLANs.
Red Hat Enterprise Linux provides administrators different options to configure team devices. For example:
-
Use
nmcli
to configure bond connections using the command line. - Use the RHEL web console to configure bond connections using a web browser.
-
Use
nmtui
to configure bond connections in a text-based user interface. -
Use the
nm-connection-editor
application to configure bond connections in a graphical interface. -
Use
nmstatectl
to configure bond connections through the Nmstate API. - Use RHEL system roles to automate the bond configuration on one or multiple hosts.
3.1. Understanding the default behavior of controller and port interfaces
Consider the following default behavior when managing or troubleshooting team or bond port interfaces using the NetworkManager
service:
- Starting the controller interface does not automatically start the port interfaces.
- Starting a port interface always starts the controller interface.
- Stopping the controller interface also stops the port interface.
- A controller without ports can start static IP connections.
- A controller without ports waits for ports when starting DHCP connections.
- A controller with a DHCP connection waiting for ports completes when you add a port with a carrier.
- A controller with a DHCP connection waiting for ports continues waiting when you add a port without carrier.
3.2. Upstream switch configuration depending on the bonding modes
Depending on the bonding mode you want to use, you must configure the ports on the switch:
Bonding mode | Configuration on the switch |
---|---|
| Requires static EtherChannel enabled, not Link Aggregation Control Protocol (LACP)-negotiated. |
| No configuration required on the switch. |
| Requires static EtherChannel enabled, not LACP-negotiated. |
| Requires static EtherChannel enabled, not LACP-negotiated. |
| Requires LACP-negotiated EtherChannel enabled. |
| No configuration required on the switch. |
| No configuration required on the switch. |
For details how to configure your switch, see the documentation of the switch.
Certain network bonding features, such as the fail-over mechanism, do not support direct cable connections without a network switch. For further details, see the Is bonding supported with direct connection using crossover cables? KCS solution.
3.3. Configuring a network bond by using nmcli
To configure a network bond on the command line, use the nmcli
utility.
Prerequisites
- Two or more physical or virtual network devices are installed on the server.
- To use Ethernet devices as ports of the bond, the physical or virtual Ethernet devices must be installed on the server.
To use team, bridge, or VLAN devices as ports of the bond, you can either create these devices while you create the bond or you can create them in advance as described in:
Procedure
Create a bond interface:
# nmcli connection add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup"
This command creates a bond named
bond0
that uses theactive-backup
mode.To additionally set a Media Independent Interface (MII) monitoring interval, add the
miimon=interval
option to thebond.options
property, for example:# nmcli connection add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup,miimon=1000"
Display the network interfaces, and note names of interfaces you plan to add to the bond:
# nmcli device status DEVICE TYPE STATE CONNECTION enp7s0 ethernet disconnected -- enp8s0 ethernet disconnected -- bridge0 bridge connected bridge0 bridge1 bridge connected bridge1 ...
In this example:
-
enp7s0
andenp8s0
are not configured. To use these devices as ports, add connection profiles in the next step. -
bridge0
andbridge1
have existing connection profiles. To use these devices as ports, modify their profiles in the next step.
-
Assign interfaces to the bond:
If the interfaces you want to assign to the bond are not configured, create new connection profiles for them:
# nmcli connection add type ethernet slave-type bond con-name bond0-port1 ifname enp7s0 master bond0 # nmcli connection add type ethernet slave-type bond con-name bond0-port2 ifname enp8s0 master bond0
These commands create profiles for
enp7s0
andenp8s0
, and add them to thebond0
connection.To assign an existing connection profile to the bond:
Set the
master
parameter of these connections tobond0
:# nmcli connection modify bridge0 master bond0 # nmcli connection modify bridge1 master bond0
These commands assign the existing connection profiles named
bridge0
andbridge1
to thebond0
connection.Reactivate the connections:
# nmcli connection up bridge0 # nmcli connection up bridge1
Configure the IPv4 settings:
To use this bond device as a port of other devices, enter:
# nmcli connection modify bond0 ipv4.method disabled
- To use DHCP, no action is required.
To set a static IPv4 address, network mask, default gateway, and DNS server to the
bond0
connection, enter:# nmcli connection modify bond0 ipv4.addresses '192.0.2.1/24' ipv4.gateway '192.0.2.254' ipv4.dns '192.0.2.253' ipv4.dns-search 'example.com' ipv4.method manual
Configure the IPv6 settings:
To use this bond device as a port of other devices, enter:
# nmcli connection modify bond0 ipv6.method disabled
- To use stateless address autoconfiguration (SLAAC), no action is required.
To set a static IPv6 address, network mask, default gateway, and DNS server to the
bond0
connection, enter:# nmcli connection modify bond0 ipv6.addresses '2001:db8:1::1/64' ipv6.gateway '2001:db8:1::fffe' ipv6.dns '2001:db8:1::fffd' ipv6.dns-search 'example.com' ipv6.method manual
Optional: If you want to set any parameters on the bond ports, use the following command:
# nmcli connection modify bond0-port1 bond-port.<parameter> <value>
Activate the connection:
# nmcli connection up bond0
Verify that the ports are connected, and the
CONNECTION
column displays the port’s connection name:# nmcli device DEVICE TYPE STATE CONNECTION ... enp7s0 ethernet connected bond0-port1 enp8s0 ethernet connected bond0-port2
When you activate any port of the connection, NetworkManager also activates the bond, but not the other ports of it. You can configure that Red Hat Enterprise Linux enables all ports automatically when the bond is enabled:
Enable the
connection.autoconnect-slaves
parameter of the bond’s connection:# nmcli connection modify bond0 connection.autoconnect-slaves 1
Reactivate the bridge:
# nmcli connection up bond0
Verification
Temporarily remove the network cable from one of the network devices and check if the other device in the bond handling the traffic.
Note that there is no method to properly test link failure events using software utilities. Tools that deactivate connections, such as
nmcli
, show only the bonding driver’s ability to handle port configuration changes and not actual link failure events.Display the status of the bond:
# cat /proc/net/bonding/bond0
3.4. Configuring a network bond by using the RHEL web console
Use the RHEL web console to configure a network bond if you prefer to manage network settings using a web browser-based interface.
Prerequisites
- Two or more physical or virtual network devices are installed on the server.
- To use Ethernet devices as members of the bond, the physical or virtual Ethernet devices must be installed on the server.
To use team, bridge, or VLAN devices as members of the bond, create them in advance as described in:
You have installed the RHEL 8 web console.
For instructions, see Installing and enabling the web console.
Procedure
Log in to the RHEL 8 web console.
For details, see Logging in to the web console.
- Select the Networking tab in the navigation on the left side of the screen.
- Click Interfaces section. in the
- Enter the name of the bond device you want to create.
- Select the interfaces that should be members of the bond.
Select the mode of the bond.
If you select Active backup, the web console shows the additional field Primary in which you can select the preferred active device.
-
Set the link monitoring mode. For example, when you use the Adaptive load balancing mode, set it to
ARP
. Optional: Adjust the monitoring interval, link up delay, and link down delay settings. Typically, you only change the defaults for troubleshooting purposes.
- Click .
By default, the bond uses a dynamic IP address. If you want to set a static IP address:
- Click the name of the bond in the Interfaces section.
- Click Edit next to the protocol you want to configure.
- Select Manual next to Addresses, and enter the IP address, prefix, and default gateway.
- In the DNS section, click the button, and enter the IP address of the DNS server. Repeat this step to set multiple DNS servers.
- In the DNS search domains section, click the button, and enter the search domain.
If the interface requires static routes, configure them in the Routes section.
- Click
Verification
Select the Networking tab in the navigation on the left side of the screen, and check if there is incoming and outgoing traffic on the interface:
Temporarily remove the network cable from one of the network devices and check if the other device in the bond handling the traffic.
Note that there is no method to properly test link failure events using software utilities. Tools that deactivate connections, such as the web console, show only the bonding driver’s ability to handle member configuration changes and not actual link failure events.
Display the status of the bond:
# cat /proc/net/bonding/bond0
3.5. Configuring a network bond by using nmtui
The nmtui
application provides a text-based user interface for NetworkManager. You can use nmtui
to configure a network bond on a host without a graphical interface.
In nmtui
:
- Navigate by using the cursor keys.
- Press a button by selecting it and hitting Enter.
- Select and clear checkboxes by using Space.
Prerequisites
- Two or more physical or virtual network devices are installed on the server.
- To use Ethernet devices as ports of the bond, the physical or virtual Ethernet devices must be installed on the server.
Procedure
If you do not know the network device names on which you want configure a network bond, display the available devices:
# nmcli device status DEVICE TYPE STATE CONNECTION enp7s0 ethernet unavailable -- enp8s0 ethernet unavailable -- ...
Start
nmtui
:# nmtui
- Select Edit a connection, and press Enter.
- Press Add.
- Select Bond from the list of network types, and press Enter.
Optional: Enter a name for the NetworkManager profile to be created.
On hosts with multiple profiles, a meaningful name makes it easier to identify the purpose of a profile.
- Enter the bond device name to be created into the Device field.
Add ports to the bond to be created:
- Press Add next to the Slaves list.
- Select the type of the interface you want to add as port to the bond, for example, Ethernet.
- Optional: Enter a name for the NetworkManager profile to be created for this bond port.
- Enter the port’s device name into the Device field.
Press OK to return to the window with the bond settings.
Figure 3.1. Adding an Ethernet device as port to a bond
- Repeat these steps to add more ports to the bond.
-
Set the bond mode. Depending on the value you set,
nmtui
displays additional fields for settings that are related to the selected mode. Depending on your environment, configure the IP address settings in the IPv4 configuration and IPv6 configuration areas accordingly. For this, press the button next to these areas, and select:
-
Disabled
, if the bond does not require an IP address. -
Automatic
, if a DHCP server or stateless address autoconfiguration (SLAAC) dynamically assigns an IP address to the bond. Manual
, if the network requires static IP address settings. In this case, you must fill further fields:- Press Show next to the protocol you want to configure to display additional fields.
Press Add next to Addresses, and enter the IP address and the subnet mask in Classless Inter-Domain Routing (CIDR) format.
If you do not specify a subnet mask, NetworkManager sets a
/32
subnet mask for IPv4 addresses and/64
for IPv6 addresses.- Enter the address of the default gateway.
- Press Add next to DNS servers, and enter the DNS server address.
- Press Add next to Search domains, and enter the DNS search domain.
Figure 3.2. Example of a bond connection with static IP address settings
-
- Press OK to create and automatically activate the new connection.
- Press Back to return to the main menu.
-
Select Quit, and press Enter to close the
nmtui
application.
Verification
Temporarily remove the network cable from one of the network devices and check if the other device in the bond handling the traffic.
Note that there is no method to properly test link failure events using software utilities. Tools that deactivate connections, such as
nmcli
, show only the bonding driver’s ability to handle port configuration changes and not actual link failure events.Display the status of the bond:
# cat /proc/net/bonding/bond0
3.6. Configuring a network bond by using nm-connection-editor
If you use Red Hat Enterprise Linux with a graphical interface, you can configure network bonds using the nm-connection-editor
application.
Note that nm-connection-editor
can add only new ports to a bond. To use an existing connection profile as a port, create the bond by using the nmcli
utility as described in Configuring a network bond by using nmcli.
Prerequisites
- Two or more physical or virtual network devices are installed on the server.
- To use Ethernet devices as ports of the bond, the physical or virtual Ethernet devices must be installed on the server.
- To use team, bond, or VLAN devices as ports of the bond, ensure that these devices are not already configured.
Procedure
Open a terminal, and enter
nm-connection-editor
:$ nm-connection-editor
- Click the button to add a new connection.
- Select the Bond connection type, and click .
On the Bond tab:
- Optional: Set the name of the bond interface in the Interface name field.
Click the
button to add a network interface as a port to the bond.- Select the connection type of the interface. For example, select Ethernet for a wired connection.
- Optional: Set a connection name for the port.
- If you create a connection profile for an Ethernet device, open the Ethernet tab, and select in the Device field the network interface you want to add as a port to the bond. If you selected a different device type, configure it accordingly. Note that you can only use Ethernet interfaces in a bond that are not configured.
- Click .
Repeat the previous step for each interface you want to add to the bond:
- Optional: Set other options, such as the Media Independent Interface (MII) monitoring interval.
Configure the IP address settings on both the IPv4 Settings and IPv6 Settings tabs:
- To use this bridge device as a port of other devices, set the Method field to Disabled.
- To use DHCP, leave the Method field at its default, Automatic (DHCP).
To use static IP settings, set the Method field to Manual and fill the fields accordingly:
- Click .
-
Close
nm-connection-editor
.
Verification
Temporarily remove the network cable from one of the network devices and check if the other device in the bond handling the traffic.
Note that there is no method to properly test link failure events using software utilities. Tools that deactivate connections, such as
nmcli
, show only the bonding driver’s ability to handle port configuration changes and not actual link failure events.Display the status of the bond:
# cat /proc/net/bonding/bond0
3.7. Configuring a network bond by using nmstatectl
Use the nmstatectl
utility to configure a network bond through the Nmstate API. The Nmstate API ensures that, after setting the configuration, the result matches the configuration file. If anything fails, nmstatectl
automatically rolls back the changes to avoid leaving the system in an incorrect state.
Depending on your environment, adjust the YAML file accordingly. For example, to use different devices than Ethernet adapters in the bond, adapt the base-iface
attribute and type
attributes of the ports you use in the bond.
Prerequisites
- Two or more physical or virtual network devices are installed on the server.
- To use Ethernet devices as ports in the bond, the physical or virtual Ethernet devices must be installed on the server.
-
To use team, bridge, or VLAN devices as ports in the bond, set the interface name in the
port
list, and define the corresponding interfaces. -
The
nmstate
package is installed.
Procedure
Create a YAML file, for example
~/create-bond.yml
, with the following content:--- interfaces: - name: bond0 type: bond state: up ipv4: enabled: true address: - ip: 192.0.2.1 prefix-length: 24 dhcp: false ipv6: enabled: true address: - ip: 2001:db8:1::1 prefix-length: 64 autoconf: false dhcp: false link-aggregation: mode: active-backup port: - enp1s0 - enp7s0 - name: enp1s0 type: ethernet state: up - name: enp7s0 type: ethernet state: up routes: config: - destination: 0.0.0.0/0 next-hop-address: 192.0.2.254 next-hop-interface: bond0 - destination: ::/0 next-hop-address: 2001:db8:1::fffe next-hop-interface: bond0 dns-resolver: config: search: - example.com server: - 192.0.2.200 - 2001:db8:1::ffbb
These settings define a network bond with the following settings:
-
Network interfaces in the bond:
enp1s0
andenp7s0
-
Mode:
active-backup
-
Static IPv4 address:
192.0.2.1
with a/24
subnet mask -
Static IPv6 address:
2001:db8:1::1
with a/64
subnet mask -
IPv4 default gateway:
192.0.2.254
-
IPv6 default gateway:
2001:db8:1::fffe
-
IPv4 DNS server:
192.0.2.200
-
IPv6 DNS server:
2001:db8:1::ffbb
-
DNS search domain:
example.com
-
Network interfaces in the bond:
Apply the settings to the system:
# nmstatectl apply ~/create-bond.yml
Verification
Display the status of the devices and connections:
# nmcli device status DEVICE TYPE STATE CONNECTION bond0 bond connected bond0
Display all settings of the connection profile:
# nmcli connection show bond0 connection.id: bond0 connection.uuid: 79cbc3bd-302e-4b1f-ad89-f12533b818ee connection.stable-id: -- connection.type: bond connection.interface-name: bond0 ...
Display the connection settings in YAML format:
# nmstatectl show bond0
Additional resources
-
nmstatectl(8)
man page on your system -
/usr/share/doc/nmstate/examples/
directory
3.8. Configuring a network bond by using the network
RHEL system role
You can combine network interfaces in a bond to provide a logical interface with higher throughput or redundancy. To configure a bond, create a NetworkManager connection profile. By using Ansible and the network
RHEL system role, you can automate this process and remotely configure connection profiles on the hosts defined in a playbook.
You can use the network
RHEL system role to configure a network bond and, if a connection profile for the bond’s parent device does not exist, the role can create it as well.
Prerequisites
- You have prepared the control node and the managed nodes
- You are logged in to the control node as a user who can run playbooks on the managed nodes.
-
The account you use to connect to the managed nodes has
sudo
permissions on them. - Two or more physical or virtual network devices are installed on the server.
Procedure
Create a playbook file, for example
~/playbook.yml
, with the following content:--- - name: Configure the network hosts: managed-node-01.example.com tasks: - name: Bond connection profile with two Ethernet ports ansible.builtin.include_role: name: rhel-system-roles.network vars: network_connections: # Bond profile - name: bond0 type: bond interface_name: bond0 ip: dhcp4: yes auto6: yes bond: mode: active-backup state: up # Port profile for the 1st Ethernet device - name: bond0-port1 interface_name: enp7s0 type: ethernet controller: bond0 state: up # Port profile for the 2nd Ethernet device - name: bond0-port2 interface_name: enp8s0 type: ethernet controller: bond0 state: up
The settings specified in the example playbook include the following:
type: <profile_type>
- Sets the type of the profile to create. The example playbook creates three connection profiles: One for the bond and two for the Ethernet devices.
dhcp4: yes
- Enables automatic IPv4 address assignment from DHCP, PPP, or similar services.
auto6: yes
-
Enables IPv6 auto-configuration. By default, NetworkManager uses Router Advertisements. If the router announces the
managed
flag, NetworkManager requests an IPv6 address and prefix from a DHCPv6 server. mode: <bond_mode>
Sets the bonding mode. Possible values are:
-
balance-rr
(default) -
active-backup
-
balance-xor
-
broadcast
-
802.3ad
-
balance-tlb
-
balance-alb
.
Depending on the mode you set, you need to set additional variables in the playbook.
-
For details about all variables used in the playbook, see the
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file on the control node.Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/playbook.yml
Note that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook ~/playbook.yml
Verification
Temporarily remove the network cable from one of the network devices and check if the other device in the bond handling the traffic.
Note that there is no method to properly test link failure events using software utilities. Tools that deactivate connections, such as
nmcli
, show only the bonding driver’s ability to handle port configuration changes and not actual link failure events.
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
/usr/share/doc/rhel-system-roles/network/
directory
3.9. Creating a network bond to enable switching between an Ethernet and wireless connection without interrupting the VPN
RHEL users who connect their workstation to their company’s network typically use a VPN to access remote resources. However, if the workstation switches between an Ethernet and Wi-Fi connection, for example, if you release a laptop from a docking station with an Ethernet connection, the VPN connection is interrupted. To avoid this problem, you can create a network bond that uses the Ethernet and Wi-Fi connection in active-backup
mode.
Prerequisites
- The host contains an Ethernet and a Wi-Fi device.
An Ethernet and Wi-Fi NetworkManager connection profile has been created and both connections work independently.
This procedure uses the following connection profiles to create a network bond named
bond0
:-
Docking_station
associated with theenp11s0u1
Ethernet device -
Wi-Fi
associated with thewlp1s0
Wi-Fi device
-
Procedure
Create a bond interface in
active-backup
mode:# nmcli connection add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup"
This command names both the interface and connection profile
bond0
.Configure the IPv4 settings of the bond:
- If a DHCP server in your network assigns IPv4 addresses to hosts, no action is required.
If your local network requires static IPv4 addresses, set the address, network mask, default gateway, DNS server, and DNS search domain to the
bond0
connection:# nmcli connection modify bond0 ipv4.addresses '192.0.2.1/24' # nmcli connection modify bond0 ipv4.gateway '192.0.2.254' # nmcli connection modify bond0 ipv4.dns '192.0.2.253' # nmcli connection modify bond0 ipv4.dns-search 'example.com' # nmcli connection modify bond0 ipv4.method manual
Configure the IPv6 settings of the bond:
- If your router or a DHCP server in your network assigns IPv6 addresses to hosts, no action is required.
If your local network requires static IPv6 addresses, set the address, network mask, default gateway, DNS server, and DNS search domain to the
bond0
connection:# nmcli connection modify bond0 ipv6.addresses '2001:db8:1::1/64' # nmcli connection modify bond0 ipv6.gateway '2001:db8:1::fffe' # nmcli connection modify bond0 ipv6.dns '2001:db8:1::fffd' # nmcli connection modify bond0 ipv6.dns-search 'example.com' # nmcli connection modify bond0 ipv6.method manual
Display the connection profiles:
# nmcli connection show NAME UUID TYPE DEVICE Docking_station 256dd073-fecc-339d-91ae-9834a00407f9 ethernet enp11s0u1 Wi-Fi 1f1531c7-8737-4c60-91af-2d21164417e8 wifi wlp1s0 ...
You require the names of the connection profiles and the Ethernet device name in the next steps.
Assign the connection profile of the Ethernet connection to the bond:
# nmcli connection modify Docking_station master bond0
Assign the connection profile of the Wi-Fi connection to the bond:
# nmcli connection modify Wi-Fi master bond0
If your Wi-Fi network uses MAC filtering to allow only MAC addresses on a allow list to access the network, configure that NetworkManager dynamically assigns the MAC address of the active port to the bond:
# nmcli connection modify bond0 +bond.options fail_over_mac=1
With this setting, you must set only the MAC address of the Wi-Fi device to the allow list instead of the MAC address of both the Ethernet and Wi-Fi device.
Set the device associated with the Ethernet connection as primary device of the bond:
# nmcli con modify bond0 +bond.options "primary=enp11s0u1"
With this setting, the bond always uses the Ethernet connection if it is available.
Configure that NetworkManager automatically activates ports when the
bond0
device is activated:# nmcli connection modify bond0 connection.autoconnect-slaves 1
Activate the
bond0
connection:# nmcli connection up bond0
Verification
Display the currently active device, the status of the bond and its ports:
# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: fault-tolerance (active-backup) (fail_over_mac active) Primary Slave: enp11s0u1 (primary_reselect always) Currently Active Slave: enp11s0u1 MII Status: up MII Polling Interval (ms): 1 Up Delay (ms): 0 Down Delay (ms): 0 Peer Notification Delay (ms): 0 Slave Interface: enp11s0u1 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:53:00:59:da:b7 Slave queue ID: 0 Slave Interface: wlp1s0 MII Status: up Speed: Unknown Duplex: Unknown Link Failure Count: 2 Permanent HW addr: 00:53:00:b3:22:ba Slave queue ID: 0
Additional resources
3.10. The different network bonding modes
The Linux bonding driver provides link aggregation. Bonding is the process of aggregating multiple network interfaces in parallel to provide a single logical bonded interface. The actions of a bonded interface depend on the bonding policy that is also known as mode. The different modes provide either load-balancing or hot standby services.
The Linux bonding driver supports the following modes:
- Balance-rr (Mode 0)
Balance-rr
uses the round-robin algorithm that sequentially transmits packets from the first available port to the last one. This mode provides load balancing and fault tolerance.This mode requires switch configuration of a port aggregation group, also called EtherChannel or similar port grouping. An EtherChannel is a port link aggregation technology to group multiple physical Ethernet links to one logical Ethernet link.
The drawback of this mode is that it is not suitable for heavy workloads and if TCP throughput or ordered packet delivery is essential.
- Active-backup (Mode 1)
Active-backup
uses the policy that determines that only one port is active in the bond. This mode provides fault tolerance and does not require any switch configuration.If the active port fails, an alternate port becomes active. The bond sends a gratuitous address resolution protocol (ARP) response to the network. The gratuitous ARP forces the receiver of the ARP frame to update their forwarding table. The
Active-backup
mode transmits a gratuitous ARP to announce the new path to maintain connectivity for the host.The
primary
option defines the preferred port of the bonding interface.- Balance-xor (Mode 2)
Balance-xor
uses the selected transmit hash policy to send the packets. This mode provides load balancing, fault tolerance, and requires switch configuration to set up an Etherchannel or similar port grouping.To alter packet transmission and balance transmit, this mode uses the
xmit_hash_policy
option. Depending on the source or destination of traffic on the interface, the interface requires an additional load-balancing configuration. See description xmit_hash_policy bonding parameter.- Broadcast (Mode 3)
Broadcast
uses a policy that transmits every packet on all interfaces. This mode provides fault tolerance and requires a switch configuration to set up an EtherChannel or similar port grouping.The drawback of this mode is that it is not suitable for heavy workloads and if TCP throughput or ordered packet delivery is essential.
- 802.3ad (Mode 4)
802.3ad
uses the same-named IEEE standard dynamic link aggregation policy. This mode provides fault tolerance. This mode requires switch configuration to set up a Link Aggregation Control Protocol (LACP) port grouping.This mode creates aggregation groups that share the same speed and duplex settings and utilizes all ports in the active aggregator. Depending on the source or destination of traffic on the interface, this mode requires an additional load-balancing configuration.
By default, the port selection for outgoing traffic depends on the transmit hash policy. Use the
xmit_hash_policy
option of the transmit hash policy to change the port selection and balance transmit.The difference between the
802.3ad
and theBalance-xor
is compliance. The802.3ad
policy negotiates LACP between the port aggregation groups. See description xmit_hash_policy bonding parameter- Balance-tlb (Mode 5)
Balance-tlb
uses the transmit load balancing policy. This mode provides fault tolerance, load balancing, and establishes channel bonding that does not require any switch support.The active port receives the incoming traffic. In case of failure of the active port, another one takes over the MAC address of the failed port. To decide which interface processes the outgoing traffic, use one of the following modes:
-
Value
0
: Uses the hash distribution policy to distribute traffic without load balancing Value
1
: Distributes traffic to each port by using load balancingWith the bonding option
tlb_dynamic_lb=0
, this bonding mode uses thexmit_hash_policy
bonding option to balance transmit. Theprimary
option defines the preferred port of the bonding interface.
See description xmit_hash_policy bonding parameter.
-
Value
- Balance-alb (Mode 6)
Balance-alb
uses an adaptive load balancing policy. This mode provides fault tolerance, load balancing, and does not require any special switch support.This mode includes balance-transmit load balancing (
balance-tlb
) and receive-load balancing for IPv4 and IPv6 traffic. The bonding intercepts ARP replies sent by the local system and overwrites the source hardware address of one of the ports in the bond. ARP negotiation manages the receive-load balancing. Therefore, different ports use different hardware addresses for the server.The
primary
option defines the preferred port of the bonding interface. With the bonding optiontlb_dynamic_lb=0
, this bonding mode uses thexmit_hash_policy
bonding option to balance transmit. See description xmit_hash_policy bonding parameter.
Additional resources
-
/usr/share/doc/kernel-doc-<version>/Documentation/networking/bonding.rst
provided by thekernel-doc
package -
/usr/share/doc/kernel-doc-<version>/Documentation/networking/bonding.txt
provided by thekernel-doc
package - Which bonding modes work when used with a bridge that virtual machine guests or containers connect to? (Red Hat Knowledgebase)
- How are the values for different policies in "xmit_hash_policy" bonding parameter calculated? (Red Hat Knowledgebase)
3.11. The xmit_hash_policy bonding parameter
The xmit_hash_policy
load balancing parameter selects the transmit hash policy for a node selection in the balance-xor
, 802.3ad
, balance-alb
, and balance-tlb
modes. It is only applicable to mode 5 and 6 if the tlb_dynamic_lb parameter is 0
. The possible values of this parameter are layer2
, layer2+3
, layer3+4
, encap2+3
, encap3+4
, and vlan+srcmac
.
Refer the table for details:
Policy or Network layers | Layer2 | Layer2+3 | Layer3+4 | encap2+3 | encap3+4 | VLAN+srcmac |
Uses | XOR of source and destination MAC addresses and Ethernet protocol type | XOR of source and destination MAC addresses and IP addresses | XOR of source and destination ports and IP addresses |
XOR of source and destination MAC addresses and IP addresses inside a supported tunnel, for example, Virtual Extensible LAN (VXLAN). This mode relies on |
XOR of source and destination ports and IP addresses inside a supported tunnel, for example, VXLAN. This mode relies on | XOR of VLAN ID and source MAC vendor and source MAC device |
Placement of traffic | All traffic to a particular network peer on the same underlying network interface | All traffic to a particular IP address on the same underlying network interface | All traffic to a particular IP address and port on the same underlying network interface | |||
Primary choice | If network traffic is between this system and multiple other systems in the same broadcast domain | If network traffic between this system and multiple other systems goes through a default gateway | If network traffic between this system and another system uses the same IP addresses but goes through multiple ports | The encapsulated traffic is between the source system and multiple other systems using multiple IP addresses | The encapsulated traffic is between the source system and other systems using multiple port numbers | If the bond carries network traffic, from multiple containers or virtual machines (VM), that expose their MAC address directly to the external network such as the bridge network, and you can not configure a switch for Mode 2 or Mode 4 |
Secondary choice | If network traffic is mostly between this system and multiple other systems behind a default gateway | If network traffic is mostly between this system and another system | ||||
Compliant | 802.3ad | 802.3ad | Not 802.3ad | |||
Default policy | This is the default policy if no configuration is provided |
For non-IP traffic, the formula is the same as for the |
For non-IP traffic, the formula is the same as for the |
Chapter 4. Configuring a NIC team
Network interface controller (NIC) teaming is a method to combine or aggregate physical and virtual network interfaces to provide a logical interface with higher throughput or redundancy. NIC teaming uses a small kernel module to implement fast handling of packet flows and a user-space service for other tasks. This way, NIC teaming is an easily extensible and scalable solution for load-balancing and redundancy requirements.
Red Hat Enterprise Linux provides administrators different options to configure team devices. For example:
-
Use
nmcli
to configure teams connections using the command line. - Use the RHEL web console to configure team connections using a web browser.
-
Use the
nm-connection-editor
application to configure team connections in a graphical interface.
NIC teaming is deprecated in Red Hat Enterprise Linux 9. If you plan to upgrade your server to a future version of RHEL, consider using the kernel bonding driver as an alternative. For details, see Configuring a network bond.
4.1. Understanding the default behavior of controller and port interfaces
Consider the following default behavior when managing or troubleshooting team or bond port interfaces using the NetworkManager
service:
- Starting the controller interface does not automatically start the port interfaces.
- Starting a port interface always starts the controller interface.
- Stopping the controller interface also stops the port interface.
- A controller without ports can start static IP connections.
- A controller without ports waits for ports when starting DHCP connections.
- A controller with a DHCP connection waiting for ports completes when you add a port with a carrier.
- A controller with a DHCP connection waiting for ports continues waiting when you add a port without carrier.
4.2. Understanding the teamd service, runners, and link-watchers
The team service, teamd
, controls one instance of the team driver. This instance of the driver adds instances of a hardware device driver to form a team of network interfaces. The team driver presents a network interface, for example team0
, to the kernel.
The teamd
service implements the common logic to all methods of teaming. Those functions are unique to the different load sharing and backup methods, such as round-robin, and implemented by separate units of code referred to as runners
. Administrators specify runners in JavaScript Object Notation (JSON) format, and the JSON code is compiled into an instance of teamd
when the instance is created. Alternatively, when using NetworkManager
, you can set the runner in the team.runner
parameter, and NetworkManager
auto-creates the corresponding JSON code.
The following runners are available:
-
broadcast
: Transmits data over all ports. -
roundrobin
: Transmits data over all ports in turn. -
activebackup
: Transmits data over one port while the others are kept as a backup. -
loadbalance
: Transmits data over all ports with active Tx load balancing and Berkeley Packet Filter (BPF)-based Tx port selectors. -
random
: Transmits data on a randomly selected port. -
lacp
: Implements the 802.3ad Link Aggregation Control Protocol (LACP).
The teamd
services uses a link watcher to monitor the state of subordinate devices. The following link-watchers are available:
-
ethtool
: Thelibteam
library uses theethtool
utility to watch for link state changes. This is the default link-watcher. -
arp_ping
: Thelibteam
library uses thearp_ping
utility to monitor the presence of a far-end hardware address using Address Resolution Protocol (ARP). -
nsna_ping
: On IPv6 connections, thelibteam
library uses the Neighbor Advertisement and Neighbor Solicitation features from the IPv6 Neighbor Discovery protocol to monitor the presence of a neighbor’s interface.
Each runner can use any link watcher, with the exception of lacp
. This runner can only use the ethtool
link watcher.
4.3. Configuring a NIC team by using nmcli
To configure a network interface controller (NIC) team on the command line, use the nmcli
utility.
NIC teaming is deprecated in Red Hat Enterprise Linux 9. If you plan to upgrade your server to a future version of RHEL, consider using the kernel bonding driver as an alternative. For details, see Configuring a network bond.
Prerequisites
-
The
teamd
andNetworkManager-team
packages are installed. - Two or more physical or virtual network devices are installed on the server.
- To use Ethernet devices as ports of the team, the physical or virtual Ethernet devices must be installed on the server and connected to a switch.
To use bond, bridge, or VLAN devices as ports of the team, you can either create these devices while you create the team or you can create them in advance as described in:
Procedure
Create a team interface:
# nmcli connection add type team con-name team0 ifname team0 team.runner activebackup
This command creates a NIC team named
team0
that uses theactivebackup
runner.Optional: Set a link watcher. For example, to set the
ethtool
link watcher in theteam0
connection profile:# nmcli connection modify team0 team.link-watchers "name=ethtool"
Link watchers support different parameters. To set parameters for a link watcher, specify them space-separated in the
name
property. Note that the name property must be surrounded by quotation marks. For example, to use theethtool
link watcher and set itsdelay-up
parameter to2500
milliseconds (2.5 seconds):# nmcli connection modify team0 team.link-watchers "name=ethtool delay-up=2500"
To set multiple link watchers and each of them with specific parameters, the link watchers must be separated by a comma. The following example sets the
ethtool
link watcher with thedelay-up
parameter and thearp_ping
link watcher with thesource-host
andtarget-host
parameter:# nmcli connection modify team0 team.link-watchers "name=ethtool delay-up=2, name=arp_ping source-host=192.0.2.1 target-host=192.0.2.2"
Display the network interfaces, and note the names of the interfaces you want to add to the team:
# nmcli device status DEVICE TYPE STATE CONNECTION enp7s0 ethernet disconnected -- enp8s0 ethernet disconnected -- bond0 bond connected bond0 bond1 bond connected bond1 ...
In this example:
-
enp7s0
andenp8s0
are not configured. To use these devices as ports, add connection profiles in the next step. Note that you can only use Ethernet interfaces in a team that are not assigned to any connection. -
bond0
andbond1
have existing connection profiles. To use these devices as ports, modify their profiles in the next step.
-
Assign the port interfaces to the team:
If the interfaces you want to assign to the team are not configured, create new connection profiles for them:
# nmcli connection add type ethernet slave-type team con-name team0-port1 ifname enp7s0 master team0 # nmcli connection add type ethernet slave--type team con-name team0-port2 ifname enp8s0 master team0
These commands create profiles for
enp7s0
andenp8s0
, and add them to theteam0
connection.To assign an existing connection profile to the team:
Set the
master
parameter of these connections toteam0
:# nmcli connection modify bond0 master team0 # nmcli connection modify bond1 master team0
These commands assign the existing connection profiles named
bond0
andbond1
to theteam0
connection.Reactivate the connections:
# nmcli connection up bond0 # nmcli connection up bond1
Configure the IPv4 settings:
To use this team device as a port of other devices, enter:
# nmcli connection modify team0 ipv4.method disabled
- To use DHCP, no action is required.
To set a static IPv4 address, network mask, default gateway, and DNS server to the
team0
connection, enter:# nmcli connection modify team0 ipv4.addresses '192.0.2.1/24' ipv4.gateway '192.0.2.254' ipv4.dns '192.0.2.253' ipv4.dns-search 'example.com' ipv4.method manual
Configure the IPv6 settings:
To use this team device as a port of other devices, enter:
# nmcli connection modify team0 ipv6.method disabled
- To use stateless address autoconfiguration (SLAAC), no action is required.
To set a static IPv6 address, network mask, default gateway, and DNS server to the
team0
connection, enter:# nmcli connection modify team0 ipv6.addresses '2001:db8:1::1/64' ipv6.gateway '2001:db8:1::fffe' ipv6.dns '2001:db8:1::fffd' ipv6.dns-search 'example.com' ipv6.method manual
Activate the connection:
# nmcli connection up team0
Verification
Display the status of the team:
# teamdctl team0 state setup: runner: activebackup ports: enp7s0 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 enp8s0 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 runner: active port: enp7s0
In this example, both ports are up.
Additional resources
- Configuring NetworkManager to avoid using a specific profile to provide a default gateway
- Understanding the teamd service, runners, and link-watchers
-
nm-settings(5)
andteamd.conf(5)
man pages on your system
4.4. Configuring a NIC team by using the RHEL web console
Use the RHEL web console to configure a network interface controller (NIC) team if you prefer to manage network settings using a web browser-based interface.
NIC teaming is deprecated in Red Hat Enterprise Linux 9. If you plan to upgrade your server to a future version of RHEL, consider using the kernel bonding driver as an alternative. For details, see Configuring a network bond.
Prerequisites
-
The
teamd
andNetworkManager-team
packages are installed. - Two or more physical or virtual network devices are installed on the server.
- To use Ethernet devices as ports of the team, the physical or virtual Ethernet devices must be installed on the server and connected to a switch.
To use bond, bridge, or VLAN devices as ports of the team, create them in advance as described in:
You have installed the RHEL 8 web console.
For instructions, see Installing and enabling the web console.
Procedure
Log in to the RHEL 8 web console.
For details, see Logging in to the web console.
-
Select the
Networking
tab in the navigation on the left side of the screen. -
Click
Interfaces
section. in the - Enter the name of the team device you want to create.
- Select the interfaces that should be ports of the team.
Select the runner of the team.
If you select
Load balancing
or802.3ad LACP
, the web console shows the additional fieldBalancer
.Set the link watcher:
-
If you select
Ethtool
, additionally, set a link up and link down delay. -
If you set
ARP ping
orNSNA ping
, additionally, set a ping interval and ping target.
-
If you select
- Click .
By default, the team uses a dynamic IP address. If you want to set a static IP address:
-
Click the name of the team in the
Interfaces
section. -
Click
Edit
next to the protocol you want to configure. -
Select
Manual
next toAddresses
, and enter the IP address, prefix, and default gateway. -
In the
DNS
section, click the button, and enter the IP address of the DNS server. Repeat this step to set multiple DNS servers. -
In the
DNS search domains
section, click the button, and enter the search domain. If the interface requires static routes, configure them in the
Routes
section.- Click
-
Click the name of the team in the
Verification
Select the
Networking
tab in the navigation on the left side of the screen, and check if there is incoming and outgoing traffic on the interface.Display the status of the team:
# teamdctl team0 state setup: runner: activebackup ports: enp7s0 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 enp8s0 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 runner: active port: enp7s0
In this example, both ports are up.
Additional resources
4.5. Configuring a NIC team by using nm-connection-editor
If you use Red Hat Enterprise Linux with a graphical interface, you can configure network interface controller (NIC) teams using the nm-connection-editor
application.
Note that nm-connection-editor
can add only new ports to a team. To use an existing connection profile as a port, create the team using the nmcli
utility as described in Configuring a NIC team by using nmcli.
NIC teaming is deprecated in Red Hat Enterprise Linux 9. If you plan to upgrade your server to a future version of RHEL, consider using the kernel bonding driver as an alternative. For details, see Configuring a network bond.
Prerequisites
-
The
teamd
andNetworkManager-team
packages are installed. - Two or more physical or virtual network devices are installed on the server.
- To use Ethernet devices as ports of the team, the physical or virtual Ethernet devices must be installed on the server.
- To use team, bond, or VLAN devices as ports of the team, ensure that these devices are not already configured.
Procedure
Open a terminal, and enter
nm-connection-editor
:$ nm-connection-editor
- Click the button to add a new connection.
- Select the Team connection type, and click .
On the Team tab:
- Optional: Set the name of the team interface in the Interface name field.
Click the
button to add a new connection profile for a network interface and adding the profile as a port to the team.- Select the connection type of the interface. For example, select Ethernet for a wired connection.
- Optional: Set a connection name for the port.
- If you create a connection profile for an Ethernet device, open the Ethernet tab, and select in the Device field the network interface you want to add as a port to the team. If you selected a different device type, configure it accordingly. Note that you can only use Ethernet interfaces in a team that are not assigned to any connection.
- Click .
Repeat the previous step for each interface you want to add to the team.
Click the
button to set advanced options to the team connection.- On the Runner tab, select the runner.
- On the Link Watcher tab, set the link watcher and its optional settings.
- Click .
Configure the IP address settings on both the IPv4 Settings and IPv6 Settings tabs:
- To use this bridge device as a port of other devices, set the Method field to Disabled.
- To use DHCP, leave the Method field at its default, Automatic (DHCP).
To use static IP settings, set the Method field to Manual and fill the fields accordingly:
- Click .
-
Close
nm-connection-editor
.
Verification
Display the status of the team:
# teamdctl team0 state setup: runner: activebackup ports: enp7s0 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 enp8s0 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 runner: active port: enp7s0
Additional resources
- Configuring a network bond by using nm-connection-editor
- Configuring a NIC team by using nm-connection-editor
- Configuring VLAN tagging by using nm-connection-editor
- Configuring NetworkManager to avoid using a specific profile to provide a default gateway
- Understanding the teamd service, runners, and link-watchers
- NetworkManager duplicates a connection after restart of NetworkManager service (Red Hat Knowledgebase)
Chapter 5. Configuring VLAN tagging
A Virtual Local Area Network (VLAN) is a logical network within a physical network. The VLAN interface tags packets with the VLAN ID as they pass through the interface, and removes tags of returning packets. You create VLAN interfaces on top of another interface, such as Ethernet, bond, team, or bridge devices. These interfaces are called the parent interface
.
Red Hat Enterprise Linux provides administrators different options to configure VLAN devices. For example:
-
Use
nmcli
to configure VLAN tagging using the command line. - Use the RHEL web console to configure VLAN tagging using a web browser.
-
Use
nmtui
to configure VLAN tagging in a text-based user interface. -
Use the
nm-connection-editor
application to configure connections in a graphical interface. -
Use
nmstatectl
to configure connections through the Nmstate API. - Use RHEL system roles to automate the VLAN configuration on one or multiple hosts.
5.1. Configuring VLAN tagging by using nmcli
You can configure Virtual Local Area Network (VLAN) tagging on the command line using the nmcli
utility.
Prerequisites
- The interface you plan to use as a parent to the virtual VLAN interface supports VLAN tags.
If you configure the VLAN on top of a bond interface:
- The ports of the bond are up.
-
The bond is not configured with the
fail_over_mac=follow
option. A VLAN virtual device cannot change its MAC address to match the parent’s new MAC address. In such a case, the traffic would still be sent with the incorrect source MAC address. -
The bond is usually not expected to get IP addresses from a DHCP server or IPv6 auto-configuration. Ensure it by setting the
ipv4.method=disable
andipv6.method=ignore
options while creating the bond. Otherwise, if DHCP or IPv6 auto-configuration fails after some time, the interface might be brought down.
- The switch, the host is connected to, is configured to support VLAN tags. For details, see the documentation of your switch.
Procedure
Display the network interfaces:
# nmcli device status DEVICE TYPE STATE CONNECTION enp1s0 ethernet disconnected enp1s0 bridge0 bridge connected bridge0 bond0 bond connected bond0 ...
Create the VLAN interface. For example, to create a VLAN interface named
vlan10
that usesenp1s0
as its parent interface and that tags packets with VLAN ID10
, enter:# nmcli connection add type vlan con-name vlan10 ifname vlan10 vlan.parent enp1s0 vlan.id 10
Note that the VLAN must be within the range from
0
to4094
.By default, the VLAN connection inherits the maximum transmission unit (MTU) from the parent interface. Optionally, set a different MTU value:
# nmcli connection modify vlan10 ethernet.mtu 2000
Configure the IPv4 settings:
To use this VLAN device as a port of other devices, enter:
# nmcli connection modify vlan10 ipv4.method disabled
- To use DHCP, no action is required.
To set a static IPv4 address, network mask, default gateway, and DNS server to the
vlan10
connection, enter:# nmcli connection modify vlan10 ipv4.addresses '192.0.2.1/24' ipv4.gateway '192.0.2.254' ipv4.dns '192.0.2.253' ipv4.method manual
Configure the IPv6 settings:
To use this VLAN device as a port of other devices, enter:
# nmcli connection modify vlan10 ipv6.method disabled
- To use stateless address autoconfiguration (SLAAC), no action is required.
To set a static IPv6 address, network mask, default gateway, and DNS server to the
vlan10
connection, enter:# nmcli connection modify vlan10 ipv6.addresses '2001:db8:1::1/32' ipv6.gateway '2001:db8:1::fffe' ipv6.dns '2001:db8:1::fffd' ipv6.method manual
Activate the connection:
# nmcli connection up vlan10
Verification
Verify the settings:
# ip -d addr show vlan10 4: vlan10@enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 52:54:00:72:2f:6e brd ff:ff:ff:ff:ff:ff promiscuity 0 vlan protocol 802.1Q id 10 <REORDER_HDR> numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute vlan10 valid_lft forever preferred_lft forever inet6 2001:db8:1::1/32 scope global noprefixroute valid_lft forever preferred_lft forever inet6 fe80::8dd7:9030:6f8e:89e6/64 scope link noprefixroute valid_lft forever preferred_lft forever
Additional resources
-
nm-settings(5)
man page on your system
5.2. Configuring VLAN tagging by using the RHEL web console
You can configure VLAN tagging if you prefer to manage network settings using a web browser-based interface in the RHEL web console.
Prerequisites
- The interface you plan to use as a parent to the virtual VLAN interface supports VLAN tags.
If you configure the VLAN on top of a bond interface:
- The ports of the bond are up.
-
The bond is not configured with the
fail_over_mac=follow
option. A VLAN virtual device cannot change its MAC address to match the parent’s new MAC address. In such a case, the traffic would still be sent with the incorrect source MAC address. - The bond is usually not expected to get IP addresses from a DHCP server or IPv6 auto-configuration. Ensure it by disabling the IPv4 and IPv6 protocol creating the bond. Otherwise, if DHCP or IPv6 auto-configuration fails after some time, the interface might be brought down.
- The switch, the host is connected to, is configured to support VLAN tags. For details, see the documentation of your switch.
You have installed the RHEL 8 web console.
For instructions, see Installing and enabling the web console.
Procedure
Log in to the RHEL 8 web console.
For details, see Logging in to the web console.
-
Select the
Networking
tab in the navigation on the left side of the screen. -
Click
Interfaces
section. in the - Select the parent device.
- Enter the VLAN ID.
Enter the name of the VLAN device or keep the automatically-generated name.
- Click .
By default, the VLAN device uses a dynamic IP address. If you want to set a static IP address:
-
Click the name of the VLAN device in the
Interfaces
section. -
Click
Edit
next to the protocol you want to configure. -
Select
Manual
next toAddresses
, and enter the IP address, prefix, and default gateway. -
In the
DNS
section, click the button, and enter the IP address of the DNS server. Repeat this step to set multiple DNS servers. -
In the
DNS search domains
section, click the button, and enter the search domain. If the interface requires static routes, configure them in the
Routes
section.- Click
-
Click the name of the VLAN device in the
Verification
Select the
Networking
tab in the navigation on the left side of the screen, and check if there is incoming and outgoing traffic on the interface:
5.3. Configuring VLAN tagging by using nmtui
The nmtui
application provides a text-based user interface for NetworkManager. You can use nmtui
to configure VLAN tagging on a host without a graphical interface.
In nmtui
:
- Navigate by using the cursor keys.
- Press a button by selecting it and hitting Enter.
- Select and clear checkboxes by using Space.
Prerequisites
- The interface you plan to use as a parent to the virtual VLAN interface supports VLAN tags.
If you configure the VLAN on top of a bond interface:
- The ports of the bond are up.
-
The bond is not configured with the
fail_over_mac=follow
option. A VLAN virtual device cannot change its MAC address to match the parent’s new MAC address. In such a case, the traffic would still be sent with the then incorrect source MAC address. -
The bond is usually not expected to get IP addresses from a DHCP server or IPv6 auto-configuration. Ensure it by setting the
ipv4.method=disable
andipv6.method=ignore
options while creating the bond. Otherwise, if DHCP or IPv6 auto-configuration fails after some time, the interface might be brought down.
- The switch the host is connected to is configured to support VLAN tags. For details, see the documentation of your switch.
Procedure
If you do not know the network device name on which you want configure VLAN tagging, display the available devices:
# nmcli device status DEVICE TYPE STATE CONNECTION enp1s0 ethernet unavailable -- ...
Start
nmtui
:# nmtui
- Select Edit a connection, and press Enter.
- Press Add.
- Select VLAN from the list of network types, and press Enter.
Optional: Enter a name for the NetworkManager profile to be created.
On hosts with multiple profiles, a meaningful name makes it easier to identify the purpose of a profile.
- Enter the VLAN device name to be created into the Device field.
- Enter the name of the device on which you want to configure VLAN tagging into the Parent field.
-
Enter the VLAN ID. The ID must be within the range from
0
to4094
. Depending on your environment, configure the IP address settings in the IPv4 configuration and IPv6 configuration areas accordingly. For this, press the button next to these areas, and select:
-
Disabled
, if this VLAN device does not require an IP address or you want to use it as a port of other devices. -
Automatic
, if a DHCP server or stateless address autoconfiguration (SLAAC) dynamically assigns an IP address to the VLAN device. Manual
, if the network requires static IP address settings. In this case, you must fill further fields:- Press Show next to the protocol you want to configure to display additional fields.
Press Add next to Addresses, and enter the IP address and the subnet mask in Classless Inter-Domain Routing (CIDR) format.
If you do not specify a subnet mask, NetworkManager sets a
/32
subnet mask for IPv4 addresses and/64
for IPv6 addresses.- Enter the address of the default gateway.
- Press Add next to DNS servers, and enter the DNS server address.
- Press Add next to Search domains, and enter the DNS search domain.
Figure 5.1. Example of a VLAN connection with static IP address settings
-
- Press OK to create and automatically activate the new connection.
- Press Back to return to the main menu.
-
Select Quit, and press Enter to close the
nmtui
application.
Verification
Verify the settings:
# ip -d addr show vlan10 4: vlan10@enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 52:54:00:72:2f:6e brd ff:ff:ff:ff:ff:ff promiscuity 0 vlan protocol 802.1Q id 10 <REORDER_HDR> numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute vlan10 valid_lft forever preferred_lft forever inet6 2001:db8:1::1/32 scope global noprefixroute valid_lft forever preferred_lft forever inet6 fe80::8dd7:9030:6f8e:89e6/64 scope link noprefixroute valid_lft forever preferred_lft forever
5.4. Configuring VLAN tagging by using nm-connection-editor
You can configure Virtual Local Area Network (VLAN) tagging in a graphical interface using the nm-connection-editor
application.
Prerequisites
- The interface you plan to use as a parent to the virtual VLAN interface supports VLAN tags.
If you configure the VLAN on top of a bond interface:
- The ports of the bond are up.
-
The bond is not configured with the
fail_over_mac=follow
option. A VLAN virtual device cannot change its MAC address to match the parent’s new MAC address. In such a case, the traffic would still be sent with the incorrect source MAC address.
- The switch, the host is connected, to is configured to support VLAN tags. For details, see the documentation of your switch.
Procedure
Open a terminal, and enter
nm-connection-editor
:$ nm-connection-editor
- Click the button to add a new connection.
- Select the VLAN connection type, and click .
On the VLAN tab:
- Select the parent interface.
- Select the VLAN id. Note that the VLAN must be within the range from 0 to 4094.
- By default, the VLAN connection inherits the maximum transmission unit (MTU) from the parent interface. Optionally, set a different MTU value.
Optional: Set the name of the VLAN interface and further VLAN-specific options.
Configure the IP address settings on both the IPv4 Settings and IPv6 Settings tabs:
- To use this bridge device as a port of other devices, set the Method field to Disabled.
- To use DHCP, leave the Method field at its default, Automatic (DHCP).
To use static IP settings, set the Method field to Manual and fill the fields accordingly:
- Click .
-
Close
nm-connection-editor
.
Verification
Verify the settings:
# ip -d addr show vlan10 4: vlan10@enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 52:54:00:d5:e0:fb brd ff:ff:ff:ff:ff:ff promiscuity 0 vlan protocol 802.1Q id 10 <REORDER_HDR> numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute vlan10 valid_lft forever preferred_lft forever inet6 2001:db8:1::1/32 scope global noprefixroute valid_lft forever preferred_lft forever inet6 fe80::8dd7:9030:6f8e:89e6/64 scope link noprefixroute valid_lft forever preferred_lft forever
5.5. Configuring VLAN tagging by using nmstatectl
Use the nmstatectl
utility to configure Virtual Local Area Network VLAN through the Nmstate API. The Nmstate API ensures that, after setting the configuration, the result matches the configuration file. If anything fails, nmstatectl
automatically rolls back the changes to avoid leaving the system in an incorrect state.
Depending on your environment, adjust the YAML file accordingly. For example, to use different devices than Ethernet adapters in the VLAN, adapt the base-iface
attribute and type
attributes of the ports you use in the VLAN.
Prerequisites
- To use Ethernet devices as ports in the VLAN, the physical or virtual Ethernet devices must be installed on the server.
-
The
nmstate
package is installed.
Procedure
Create a YAML file, for example
~/create-vlan.yml
, with the following content:--- interfaces: - name: vlan10 type: vlan state: up ipv4: enabled: true address: - ip: 192.0.2.1 prefix-length: 24 dhcp: false ipv6: enabled: true address: - ip: 2001:db8:1::1 prefix-length: 64 autoconf: false dhcp: false vlan: base-iface: enp1s0 id: 10 - name: enp1s0 type: ethernet state: up routes: config: - destination: 0.0.0.0/0 next-hop-address: 192.0.2.254 next-hop-interface: vlan10 - destination: ::/0 next-hop-address: 2001:db8:1::fffe next-hop-interface: vlan10 dns-resolver: config: search: - example.com server: - 192.0.2.200 - 2001:db8:1::ffbb
These settings define a VLAN with ID 10 that uses the
enp1s0
device. As the child device, the VLAN connection has the following settings:-
A static IPv4 address -
192.0.2.1
with the/24
subnet mask -
A static IPv6 address -
2001:db8:1::1
with the/64
subnet mask -
An IPv4 default gateway -
192.0.2.254
-
An IPv6 default gateway -
2001:db8:1::fffe
-
An IPv4 DNS server -
192.0.2.200
-
An IPv6 DNS server -
2001:db8:1::ffbb
-
A DNS search domain -
example.com
-
A static IPv4 address -
Apply the settings to the system:
# nmstatectl apply ~/create-vlan.yml
Verification
Display the status of the devices and connections:
# nmcli device status DEVICE TYPE STATE CONNECTION vlan10 vlan connected vlan10
Display all settings of the connection profile:
# nmcli connection show vlan10 connection.id: vlan10 connection.uuid: 1722970f-788e-4f81-bd7d-a86bf21c9df5 connection.stable-id: -- connection.type: vlan connection.interface-name: vlan10 ...
Display the connection settings in YAML format:
# nmstatectl show vlan0
Additional resources
-
nmstatectl(8)
man page on your system -
/usr/share/doc/nmstate/examples/
directory
5.6. Configuring VLAN tagging by using the network
RHEL system role
If your network uses Virtual Local Area Networks (VLANs) to separate network traffic into logical networks, create a NetworkManager connection profile to configure VLAN tagging. By using Ansible and the network
RHEL system role, you can automate this process and remotely configure connection profiles on the hosts defined in a playbook.
You can use the network
RHEL system role to configure VLAN tagging and, if a connection profile for the VLAN’s parent device does not exists, the role can create it as well.
If the VLAN device requires an IP address, default gateway, and DNS settings, configure them on the VLAN device and not on the parent device.
Prerequisites
- You have prepared the control node and the managed nodes
- You are logged in to the control node as a user who can run playbooks on the managed nodes.
-
The account you use to connect to the managed nodes has
sudo
permissions on them.
Procedure
Create a playbook file, for example
~/playbook.yml
, with the following content:--- - name: Configure the network hosts: managed-node-01.example.com tasks: - name: VLAN connection profile with Ethernet port ansible.builtin.include_role: name: rhel-system-roles.network vars: network_connections: # Ethernet profile - name: enp1s0 type: ethernet interface_name: enp1s0 autoconnect: yes state: up ip: dhcp4: no auto6: no # VLAN profile - name: enp1s0.10 type: vlan vlan: id: 10 ip: dhcp4: yes auto6: yes parent: enp1s0 state: up
e settings specified in the example playbook include the following:
type: <profile_type>
- Sets the type of the profile to create. The example playbook creates two connection profiles: One for the parent Ethernet device and one for the VLAN device.
dhcp4: <value>
-
If set to
yes
, automatic IPv4 address assignment from DHCP, PPP, or similar services is enabled. Disable the IP address configuration on the parent device. auto6: <value>
-
If set to
yes
, IPv6 auto-configuration is enabled. In this case, by default, NetworkManager uses Router Advertisements and, if the router announces themanaged
flag, NetworkManager requests an IPv6 address and prefix from a DHCPv6 server. Disable the IP address configuration on the parent device. parent: <parent_device>
- Sets the parent device of the VLAN connection profile. In the example, the parent is the Ethernet interface.
For details about all variables used in the playbook, see the
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file on the control node.Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/playbook.yml
Note that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook ~/playbook.yml
Verification
Verify the VLAN settings:
# ansible managed-node-01.example.com -m command -a 'ip -d addr show enp1s0.10' managed-node-01.example.com | CHANGED | rc=0 >> 4: vlan10@enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 52:54:00:72:2f:6e brd ff:ff:ff:ff:ff:ff promiscuity 0 vlan protocol 802.1Q id 10 <REORDER_HDR> numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 ...
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
/usr/share/doc/rhel-system-roles/network/
directory
Chapter 6. Configuring a network bridge
A network bridge is a link-layer device which forwards traffic between networks based on a table of MAC addresses. The bridge builds the MAC addresses table by listening to network traffic and thereby learning what hosts are connected to each network. For example, you can use a software bridge on a Red Hat Enterprise Linux host to emulate a hardware bridge or in virtualization environments, to integrate virtual machines (VM) to the same network as the host.
A bridge requires a network device in each network the bridge should connect. When you configure a bridge, the bridge is called controller
and the devices it uses ports
.
You can create bridges on different types of devices, such as:
- Physical and virtual Ethernet devices
- Network bonds
- Network teams
- VLAN devices
Due to the IEEE 802.11 standard which specifies the use of 3-address frames in Wi-Fi for the efficient use of airtime, you cannot configure a bridge over Wi-Fi networks operating in Ad-Hoc or Infrastructure modes.
6.1. Configuring a network bridge by using nmcli
To configure a network bridge on the command line, use the nmcli
utility.
Prerequisites
- Two or more physical or virtual network devices are installed on the server.
- To use Ethernet devices as ports of the bridge, the physical or virtual Ethernet devices must be installed on the server.
To use team, bond, or VLAN devices as ports of the bridge, you can either create these devices while you create the bridge or you can create them in advance as described in:
Procedure
Create a bridge interface:
# nmcli connection add type bridge con-name bridge0 ifname bridge0
This command creates a bridge named
bridge0
, enter:Display the network interfaces, and note the names of the interfaces you want to add to the bridge:
# nmcli device status DEVICE TYPE STATE CONNECTION enp7s0 ethernet disconnected -- enp8s0 ethernet disconnected -- bond0 bond connected bond0 bond1 bond connected bond1 ...
In this example:
-
enp7s0
andenp8s0
are not configured. To use these devices as ports, add connection profiles in the next step. -
bond0
andbond1
have existing connection profiles. To use these devices as ports, modify their profiles in the next step.
-
Assign the interfaces to the bridge.
If the interfaces you want to assign to the bridge are not configured, create new connection profiles for them:
# nmcli connection add type ethernet slave-type bridge con-name bridge0-port1 ifname enp7s0 master bridge0 # nmcli connection add type ethernet slave-type bridge con-name bridge0-port2 ifname enp8s0 master bridge0
These commands create profiles for
enp7s0
andenp8s0
, and add them to thebridge0
connection.If you want to assign an existing connection profile to the bridge:
Set the
master
parameter of these connections tobridge0
:# nmcli connection modify bond0 master bridge0 # nmcli connection modify bond1 master bridge0
These commands assign the existing connection profiles named
bond0
andbond1
to thebridge0
connection.Reactivate the connections:
# nmcli connection up bond0 # nmcli connection up bond1
Configure the IPv4 settings:
To use this bridge device as a port of other devices, enter:
# nmcli connection modify bridge0 ipv4.method disabled
- To use DHCP, no action is required.
To set a static IPv4 address, network mask, default gateway, and DNS server to the
bridge0
connection, enter:# nmcli connection modify bridge0 ipv4.addresses '192.0.2.1/24' ipv4.gateway '192.0.2.254' ipv4.dns '192.0.2.253' ipv4.dns-search 'example.com' ipv4.method manual
Configure the IPv6 settings:
To use this bridge device as a port of other devices, enter:
# nmcli connection modify bridge0 ipv6.method disabled
- To use stateless address autoconfiguration (SLAAC), no action is required.
To set a static IPv6 address, network mask, default gateway, and DNS server to the
bridge0
connection, enter:# nmcli connection modify bridge0 ipv6.addresses '2001:db8:1::1/64' ipv6.gateway '2001:db8:1::fffe' ipv6.dns '2001:db8:1::fffd' ipv6.dns-search 'example.com' ipv6.method manual
Optional: Configure further properties of the bridge. For example, to set the Spanning Tree Protocol (STP) priority of
bridge0
to16384
, enter:# nmcli connection modify bridge0 bridge.priority '16384'
By default, STP is enabled.
Activate the connection:
# nmcli connection up bridge0
Verify that the ports are connected, and the
CONNECTION
column displays the port’s connection name:# nmcli device DEVICE TYPE STATE CONNECTION ... enp7s0 ethernet connected bridge0-port1 enp8s0 ethernet connected bridge0-port2
When you activate any port of the connection, NetworkManager also activates the bridge, but not the other ports of it. You can configure that Red Hat Enterprise Linux enables all ports automatically when the bridge is enabled:
Enable the
connection.autoconnect-slaves
parameter of the bridge connection:# nmcli connection modify bridge0 connection.autoconnect-slaves 1
Reactivate the bridge:
# nmcli connection up bridge0
Verification
Use the
ip
utility to display the link status of Ethernet devices that are ports of a specific bridge:# ip link show master bridge0 3: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bridge0 state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:62:61:0e brd ff:ff:ff:ff:ff:ff 4: enp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bridge0 state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:9e:f1:ce brd ff:ff:ff:ff:ff:ff
Use the
bridge
utility to display the status of Ethernet devices that are ports of any bridge device:# bridge link show 3: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge0 state forwarding priority 32 cost 100 4: enp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge0 state listening priority 32 cost 100 5: enp9s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge1 state forwarding priority 32 cost 100 6: enp11s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge1 state blocking priority 32 cost 100 ...
To display the status for a specific Ethernet device, use the
bridge link show dev <ethernet_device_name>
command.
Additional resources
-
bridge(8)
andnm-settings(5)
man pages on your system - NetworkManager duplicates a connection after restart of NetworkManager service (Red Hat Knowledgebase)
- How to configure a bridge with VLAN information? (Red Hat Knowledgebase)
6.2. Configuring a network bridge by using the RHEL web console
Use the RHEL web console to configure a network bridge if you prefer to manage network settings using a web browser-based interface.
Prerequisites
- Two or more physical or virtual network devices are installed on the server.
- To use Ethernet devices as ports of the bridge, the physical or virtual Ethernet devices must be installed on the server.
To use team, bond, or VLAN devices as ports of the bridge, you can either create these devices while you create the bridge or you can create them in advance as described in:
You have installed the RHEL 8 web console.
For instructions, see Installing and enabling the web console.
Procedure
Log in to the RHEL 8 web console.
For details, see Logging in to the web console.
- Select the Networking tab in the navigation on the left side of the screen.
- Click Interfaces section. in the
- Enter the name of the bridge device you want to create.
- Select the interfaces that should be ports of the bridge.
Optional: Enable the Spanning tree protocol (STP) feature to avoid bridge loops and broadcast radiation.
- Click .
By default, the bridge uses a dynamic IP address. If you want to set a static IP address:
- Click the name of the bridge in the Interfaces section.
- Click Edit next to the protocol you want to configure.
- Select Manual next to Addresses, and enter the IP address, prefix, and default gateway.
- In the DNS section, click the button, and enter the IP address of the DNS server. Repeat this step to set multiple DNS servers.
- In the DNS search domains section, click the button, and enter the search domain.
If the interface requires static routes, configure them in the Routes section.
- Click
Verification
Select the Networking tab in the navigation on the left side of the screen, and check if there is incoming and outgoing traffic on the interface:
6.3. Configuring a network bridge by using nmtui
The nmtui
application provides a text-based user interface for NetworkManager. You can use nmtui
to configure a network bridge on a host without a graphical interface.
In nmtui
:
- Navigate by using the cursor keys.
- Press a button by selecting it and hitting Enter.
- Select and clear checkboxes by using Space.
Prerequisites
- Two or more physical or virtual network devices are installed on the server.
- To use Ethernet devices as ports of the bridge, the physical or virtual Ethernet devices must be installed on the server.
Procedure
If you do not know the network device names on which you want configure a network bridge, display the available devices:
# nmcli device status DEVICE TYPE STATE CONNECTION enp7s0 ethernet unavailable -- enp8s0 ethernet unavailable -- ...
Start
nmtui
:# nmtui
-
Select
Edit a connection
, and press Enter. -
Press
Add
. -
Select
Bridge
from the list of network types, and press Enter. Optional: Enter a name for the NetworkManager profile to be created.
On hosts with multiple profiles, a meaningful name makes it easier to identify the purpose of a profile.
-
Enter the bridge device name to be created into the
Device
field. Add ports to the bridge to be created:
-
Press
Add
next to theSlaves
list. -
Select the type of the interface you want to add as port to the bridge, for example,
Ethernet
. - Optional: Enter a name for the NetworkManager profile to be created for this bridge port.
-
Enter the port’s device name into the
Device
field. Press
OK
to return to the window with the bridge settings.Figure 6.1. Adding an Ethernet device as port to a bridge
- Repeat these steps to add more ports to the bridge.
-
Press
Depending on your environment, configure the IP address settings in the
IPv4 configuration
andIPv6 configuration
areas accordingly. For this, press the button next to these areas, and select:-
Disabled
, if the bridge does not require an IP address. -
Automatic
, if a DHCP server or stateless address autoconfiguration (SLAAC) dynamically assigns an IP address to the bridge. Manual
, if the network requires static IP address settings. In this case, you must fill further fields:-
Press
Show
next to the protocol you want to configure to display additional fields. Press
Add
next toAddresses
, and enter the IP address and the subnet mask in Classless Inter-Domain Routing (CIDR) format.If you do not specify a subnet mask, NetworkManager sets a
/32
subnet mask for IPv4 addresses and/64
for IPv6 addresses.- Enter the address of the default gateway.
-
Press
Add
next toDNS servers
, and enter the DNS server address. -
Press
Add
next toSearch domains
, and enter the DNS search domain.
-
Press
Figure 6.2. Example of a bridge connection without IP address settings
-
-
Press
OK
to create and automatically activate the new connection. -
Press
Back
to return to the main menu. -
Select
Quit
, and press Enter to close thenmtui
application.
Verification
Use the
ip
utility to display the link status of Ethernet devices that are ports of a specific bridge:# ip link show master bridge0 3: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bridge0 state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:62:61:0e brd ff:ff:ff:ff:ff:ff 4: enp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bridge0 state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:9e:f1:ce brd ff:ff:ff:ff:ff:ff
Use the
bridge
utility to display the status of Ethernet devices that are ports of any bridge device:# bridge link show 3: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge0 state forwarding priority 32 cost 100 4: enp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge0 state listening priority 32 cost 100 ...
To display the status for a specific Ethernet device, use the
bridge link show dev <ethernet_device_name>
command.
6.4. Configuring a network bridge by using nm-connection-editor
If you use Red Hat Enterprise Linux with a graphical interface, you can configure network bridges using the nm-connection-editor
application.
Note that nm-connection-editor
can add only new ports to a bridge. To use an existing connection profile as a port, create the bridge using the nmcli
utility as described in Configuring a network bridge by using nmcli.
Prerequisites
- Two or more physical or virtual network devices are installed on the server.
- To use Ethernet devices as ports of the bridge, the physical or virtual Ethernet devices must be installed on the server.
- To use team, bond, or VLAN devices as ports of the bridge, ensure that these devices are not already configured.
Procedure
Open a terminal, and enter
nm-connection-editor
:$ nm-connection-editor
- Click the button to add a new connection.
- Select the Bridge connection type, and click .
On the Bridge tab:
- Optional: Set the name of the bridge interface in the Interface name field.
Click the
button to create a new connection profile for a network interface and adding the profile as a port to the bridge.- Select the connection type of the interface. For example, select Ethernet for a wired connection.
- Optional: Set a connection name for the port device.
- If you create a connection profile for an Ethernet device, open the Ethernet tab, and select in the Device field the network interface you want to add as a port to the bridge. If you selected a different device type, configure it accordingly.
- Click .
Repeat the previous step for each interface you want to add to the bridge.
- Optional: Configure further bridge settings, such as Spanning Tree Protocol (STP) options.
Configure the IP address settings on both the IPv4 Settings and IPv6 Settings tabs:
- To use this bridge device as a port of other devices, set the Method field to Disabled.
- To use DHCP, leave the Method field at its default, Automatic (DHCP).
To use static IP settings, set the Method field to Manual and fill the fields accordingly:
- Click .
-
Close
nm-connection-editor
.
Verification
Use the
ip
utility to display the link status of Ethernet devices that are ports of a specific bridge.# ip link show master bridge0 3: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bridge0 state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:62:61:0e brd ff:ff:ff:ff:ff:ff 4: enp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bridge0 state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:9e:f1:ce brd ff:ff:ff:ff:ff:ff
Use the
bridge
utility to display the status of Ethernet devices that are ports in any bridge device:# bridge link show 3: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge0 state forwarding priority 32 cost 100 4: enp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge0 state listening priority 32 cost 100 5: enp9s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge1 state forwarding priority 32 cost 100 6: enp11s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge1 state blocking priority 32 cost 100 ...
To display the status for a specific Ethernet device, use the
bridge link show dev ethernet_device_name
command.
Additional resources
- Configuring a network bond by using nm-connection-editor
- Configuring a network team by using nm-connection-editor
- Configuring VLAN tagging by using nm-connection-editor
- Configuring NetworkManager to avoid using a specific profile to provide a default gateway
- How to configure a bridge with VLAN information? (Red Hat Knowledgebase)
6.5. Configuring a network bridge by using nmstatectl
Use the nmstatectl
utility to configure a network bridge through the Nmstate API. The Nmstate API ensures that, after setting the configuration, the result matches the configuration file. If anything fails, nmstatectl
automatically rolls back the changes to avoid leaving the system in an incorrect state.
Depending on your environment, adjust the YAML file accordingly. For example, to use different devices than Ethernet adapters in the bridge, adapt the base-iface
attribute and type
attributes of the ports you use in the bridge.
Prerequisites
- Two or more physical or virtual network devices are installed on the server.
- To use Ethernet devices as ports in the bridge, the physical or virtual Ethernet devices must be installed on the server.
-
To use team, bond, or VLAN devices as ports in the bridge, set the interface name in the
port
list, and define the corresponding interfaces. -
The
nmstate
package is installed.
Procedure
Create a YAML file, for example
~/create-bridge.yml
, with the following content:--- interfaces: - name: bridge0 type: linux-bridge state: up ipv4: enabled: true address: - ip: 192.0.2.1 prefix-length: 24 dhcp: false ipv6: enabled: true address: - ip: 2001:db8:1::1 prefix-length: 64 autoconf: false dhcp: false bridge: options: stp: enabled: true port: - name: enp1s0 - name: enp7s0 - name: enp1s0 type: ethernet state: up - name: enp7s0 type: ethernet state: up routes: config: - destination: 0.0.0.0/0 next-hop-address: 192.0.2.254 next-hop-interface: bridge0 - destination: ::/0 next-hop-address: 2001:db8:1::fffe next-hop-interface: bridge0 dns-resolver: config: search: - example.com server: - 192.0.2.200 - 2001:db8:1::ffbb
These settings define a network bridge with the following settings:
-
Network interfaces in the bridge:
enp1s0
andenp7s0
- Spanning Tree Protocol (STP): Enabled
-
Static IPv4 address:
192.0.2.1
with the/24
subnet mask -
Static IPv6 address:
2001:db8:1::1
with the/64
subnet mask -
IPv4 default gateway:
192.0.2.254
-
IPv6 default gateway:
2001:db8:1::fffe
-
IPv4 DNS server:
192.0.2.200
-
IPv6 DNS server:
2001:db8:1::ffbb
-
DNS search domain:
example.com
-
Network interfaces in the bridge:
Apply the settings to the system:
# nmstatectl apply ~/create-bridge.yml
Verification
Display the status of the devices and connections:
# nmcli device status DEVICE TYPE STATE CONNECTION bridge0 bridge connected bridge0
Display all settings of the connection profile:
# nmcli connection show bridge0 connection.id: bridge0_ connection.uuid: e2cc9206-75a2-4622-89cf-1252926060a9 connection.stable-id: -- connection.type: bridge connection.interface-name: bridge0 ...
Display the connection settings in YAML format:
# nmstatectl show bridge0
Additional resources
-
nmstatectl(8)
man page on your system -
/usr/share/doc/nmstate/examples/
directory - How to configure a bridge with VLAN information? (Red Hat Knowledgebase)
6.6. Configuring a network bridge by using the network
RHEL system role
You can connect multiple networks on layer 2 of the Open Systems Interconnection (OSI) model by creating a network bridge. To configure a bridge, create a connection profile in NetworkManager. By using Ansible and the network
RHEL system role, you can automate this process and remotely configure connection profiles on the hosts defined in a playbook.
You can use the network
RHEL system role to configure a bridge and, if a connection profile for the bridge’s parent device does not exists, the role can create it as well.
If you want to assign IP addresses, gateways, and DNS settings to a bridge, configure them on the bridge and not on its ports.
Prerequisites
- You have prepared the control node and the managed nodes
- You are logged in to the control node as a user who can run playbooks on the managed nodes.
-
The account you use to connect to the managed nodes has
sudo
permissions on them. - Two or more physical or virtual network devices are installed on the server.
Procedure
Create a playbook file, for example
~/playbook.yml
, with the following content:--- - name: Configure the network hosts: managed-node-01.example.com tasks: - name: Bridge connection profile with two Ethernet ports ansible.builtin.include_role: name: rhel-system-roles.network vars: network_connections: # Bridge profile - name: bridge0 type: bridge interface_name: bridge0 ip: dhcp4: yes auto6: yes state: up # Port profile for the 1st Ethernet device - name: bridge0-port1 interface_name: enp7s0 type: ethernet controller: bridge0 port_type: bridge state: up # Port profile for the 2nd Ethernet device - name: bridge0-port2 interface_name: enp8s0 type: ethernet controller: bridge0 port_type: bridge state: up
The settings specified in the example playbook include the following:
type: <profile_type>
- Sets the type of the profile to create. The example playbook creates three connection profiles: One for the bridge and two for the Ethernet devices.
dhcp4: yes
- Enables automatic IPv4 address assignment from DHCP, PPP, or similar services.
auto6: yes
-
Enables IPv6 auto-configuration. By default, NetworkManager uses Router Advertisements. If the router announces the
managed
flag, NetworkManager requests an IPv6 address and prefix from a DHCPv6 server.
For details about all variables used in the playbook, see the
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file on the control node.Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/playbook.yml
Note that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook ~/playbook.yml
Verification
Display the link status of Ethernet devices that are ports of a specific bridge:
# ansible managed-node-01.example.com -m command -a 'ip link show master bridge0' managed-node-01.example.com | CHANGED | rc=0 >> 3: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bridge0 state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:62:61:0e brd ff:ff:ff:ff:ff:ff 4: enp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bridge0 state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:9e:f1:ce brd ff:ff:ff:ff:ff:ff
Display the status of Ethernet devices that are ports of any bridge device:
# ansible managed-node-01.example.com -m command -a 'bridge link show' managed-node-01.example.com | CHANGED | rc=0 >> 3: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge0 state forwarding priority 32 cost 100 4: enp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge0 state listening priority 32 cost 100
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
/usr/share/doc/rhel-system-roles/network/
directory
Chapter 7. Setting up an IPsec VPN
A virtual private network (VPN) is a way of connecting to a local network over the internet. IPsec
provided by Libreswan
is the preferred method for creating a VPN. Libreswan
is a user-space IPsec
implementation for VPN. A VPN enables the communication between your LAN, and another, remote LAN by setting up a tunnel across an intermediate network such as the internet. For security reasons, a VPN tunnel always uses authentication and encryption. For cryptographic operations, Libreswan
uses the NSS
library.
7.1. Libreswan as an IPsec VPN implementation
In RHEL, you can configure a Virtual Private Network (VPN) by using the IPsec protocol, which is supported by the Libreswan application. Libreswan is a continuation of the Openswan application, and many examples from the Openswan documentation are interchangeable with Libreswan.
The IPsec protocol for a VPN is configured using the Internet Key Exchange (IKE) protocol. The terms IPsec and IKE are used interchangeably. An IPsec VPN is also called an IKE VPN, IKEv2 VPN, XAUTH VPN, Cisco VPN or IKE/IPsec VPN. A variant of an IPsec VPN that also uses the Layer 2 Tunneling Protocol (L2TP) is usually called an L2TP/IPsec VPN, which requires the xl2tpd
package provided by the optional
repository.
Libreswan is an open-source, user-space IKE implementation. IKE v1 and v2 are implemented as a user-level daemon. The IKE protocol is also encrypted. The IPsec protocol is implemented by the Linux kernel, and Libreswan configures the kernel to add and remove VPN tunnel configurations.
The IKE protocol uses UDP port 500 and 4500. The IPsec protocol consists of two protocols:
- Encapsulated Security Payload (ESP), which has protocol number 50.
- Authenticated Header (AH), which has protocol number 51.
The AH protocol is not recommended for use. Users of AH are recommended to migrate to ESP with null encryption.
The IPsec protocol provides two modes of operation:
- Tunnel Mode (the default)
- Transport Mode.
You can configure the kernel with IPsec without IKE. This is called manual keying. You can also configure manual keying using the ip xfrm
commands, however, this is strongly discouraged for security reasons. Libreswan communicates with the Linux kernel using the Netlink interface. The kernel performs packet encryption and decryption.
Libreswan uses the Network Security Services (NSS) cryptographic library. NSS is certified for use with the Federal Information Processing Standard (FIPS) Publication 140-2.
IKE/IPsec VPNs, implemented by Libreswan and the Linux kernel, is the only VPN technology recommended for use in RHEL. Do not use any other VPN technology without understanding the risks of doing so.
In RHEL, Libreswan follows system-wide cryptographic policies by default. This ensures that Libreswan uses secure settings for current threat models including IKEv2 as a default protocol. See Using system-wide crypto policies for more information.
Libreswan does not use the terms "source" and "destination" or "server" and "client" because IKE/IPsec are peer to peer protocols. Instead, it uses the terms "left" and "right" to refer to end points (the hosts). This also allows you to use the same configuration on both end points in most cases. However, administrators usually choose to always use "left" for the local host and "right" for the remote host.
The leftid
and rightid
options serve as identification of the respective hosts in the authentication process. See the ipsec.conf(5)
man page for more information.
7.2. Authentication methods in Libreswan
Libreswan supports several authentication methods, each of which fits a different scenario.
Pre-Shared key (PSK)
Pre-Shared Key (PSK) is the simplest authentication method. For security reasons, do not use PSKs shorter than 64 random characters. In FIPS mode, PSKs must comply with a minimum-strength requirement depending on the integrity algorithm used. You can set PSK by using the authby=secret
connection.
Raw RSA keys
Raw RSA keys are commonly used for static host-to-host or subnet-to-subnet IPsec configurations. Each host is manually configured with the public RSA keys of all other hosts, and Libreswan sets up an IPsec tunnel between each pair of hosts. This method does not scale well for large numbers of hosts.
You can generate a raw RSA key on a host using the ipsec newhostkey
command. You can list generated keys by using the ipsec showhostkey
command. The leftrsasigkey=
line is required for connection configurations that use CKA ID keys. Use the authby=rsasig
connection option for raw RSA keys.
X.509 certificates
X.509 certificates are commonly used for large-scale deployments with hosts that connect to a common IPsec gateway. A central certificate authority (CA) signs RSA certificates for hosts or users. This central CA is responsible for relaying trust, including the revocations of individual hosts or users.
For example, you can generate X.509 certificates using the openssl
command and the NSS certutil
command. Because Libreswan reads user certificates from the NSS database using the certificates' nickname in the leftcert=
configuration option, provide a nickname when you create a certificate.
If you use a custom CA certificate, you must import it to the Network Security Services (NSS) database. You can import any certificate in the PKCS #12 format to the Libreswan NSS database by using the ipsec import
command.
Libreswan requires an Internet Key Exchange (IKE) peer ID as a subject alternative name (SAN) for every peer certificate as described in section 3.1 of RFC 4945. Disabling this check by changing the require-id-on-certificated=
option can make the system vulnerable to man-in-the-middle attacks.
Use the authby=rsasig
connection option for authentication based on X.509 certificates using RSA with SHA-1 and SHA-2. You can further limit it for ECDSA digital signatures using SHA-2 by setting authby=
to ecdsa
and RSA Probabilistic Signature Scheme (RSASSA-PSS) digital signatures based authentication with SHA-2 through authby=rsa-sha2
. The default value is authby=rsasig,ecdsa
.
The certificates and the authby=
signature methods should match. This increases interoperability and preserves authentication in one digital signature system.
NULL authentication
NULL authentication is used to gain mesh encryption without authentication. It protects against passive attacks but not against active attacks. However, because IKEv2 allows asymmetric authentication methods, NULL authentication can also be used for internet-scale opportunistic IPsec. In this model, clients authenticate the server, but servers do not authenticate the client. This model is similar to secure websites using TLS. Use authby=null
for NULL authentication.
Protection against quantum computers
In addition to the previously mentioned authentication methods, you can use the Post-quantum Pre-shared Key (PPK) method to protect against possible attacks by quantum computers. Individual clients or groups of clients can use their own PPK by specifying a PPK ID that corresponds to an out-of-band configured pre-shared key.
Using IKEv1 with pre-shared keys protects against quantum attackers. The redesign of IKEv2 does not offer this protection natively. Libreswan offers the use of a Post-quantum Pre-shared Key (PPK) to protect IKEv2 connections against quantum attacks.
To enable optional PPK support, add ppk=yes
to the connection definition. To require PPK, add ppk=insist
. Then, each client can be given a PPK ID with a secret value that is communicated out-of-band (and preferably quantum-safe). The PPK’s should be very strong in randomness and not based on dictionary words. The PPK ID and PPK data are stored in the ipsec.secrets
file, for example:
@west @east : PPKS "user1" "thestringismeanttobearandomstr"
The PPKS
option refers to static PPKs. This experimental function uses one-time-pad-based Dynamic PPKs. Upon each connection, a new part of the one-time pad is used as the PPK. When used, that part of the dynamic PPK inside the file is overwritten with zeros to prevent re-use. If there is no more one-time-pad material left, the connection fails. See the ipsec.secrets(5)
man page for more information.
The implementation of dynamic PPKs is provided as an unsupported Technology Preview. Use with caution.
7.3. Installing Libreswan
Before you can set a VPN through the Libreswan IPsec/IKE implementation, you must install the corresponding packages, start the ipsec
service, and allow the service in your firewall.
Prerequisites
-
The
AppStream
repository is enabled.
Procedure
Install the
libreswan
packages:# yum install libreswan
If you are re-installing Libreswan, remove its old database files and create a new database:
# systemctl stop ipsec # rm /etc/ipsec.d/*db # ipsec initnss
Start the
ipsec
service, and enable the service to be started automatically on boot:# systemctl enable ipsec --now
Configure the firewall to allow 500 and 4500/UDP ports for the IKE, ESP, and AH protocols by adding the
ipsec
service:# firewall-cmd --add-service="ipsec" # firewall-cmd --runtime-to-permanent
7.4. Creating a host-to-host VPN
You can configure Libreswan to create a host-to-host IPsec VPN between two hosts referred to as left and right using authentication by raw RSA keys.
Prerequisites
-
Libreswan is installed and the
ipsec
service is started on each node.
Procedure
Generate a raw RSA key pair on each host:
# ipsec newhostkey
The previous step returned the generated key’s
ckaid
. Use thatckaid
with the following command on left, for example:# ipsec showhostkey --left --ckaid 2d3ea57b61c9419dfd6cf43a1eb6cb306c0e857d
The output of the previous command generated the
leftrsasigkey=
line required for the configuration. Do the same on the second host (right):# ipsec showhostkey --right --ckaid a9e1f6ce9ecd3608c24e8f701318383f41798f03
In the
/etc/ipsec.d/
directory, create a newmy_host-to-host.conf
file. Write the RSA host keys from the output of theipsec showhostkey
commands in the previous step to the new file. For example:conn mytunnel leftid=@west left=192.1.2.23 leftrsasigkey=0sAQOrlo+hOafUZDlCQmXFrje/oZm [...] W2n417C/4urYHQkCvuIQ== rightid=@east right=192.1.2.45 rightrsasigkey=0sAQO3fwC6nSSGgt64DWiYZzuHbc4 [...] D/v8t5YTQ== authby=rsasig
After importing keys, restart the
ipsec
service:# systemctl restart ipsec
Load the connection:
# ipsec auto --add mytunnel
Establish the tunnel:
# ipsec auto --up mytunnel
To automatically start the tunnel when the
ipsec
service is started, add the following line to the connection definition:auto=start
7.5. Configuring a site-to-site VPN
To create a site-to-site IPsec VPN, by joining two networks, an IPsec tunnel between the two hosts, is created. The hosts thus act as the end points, which are configured to permit traffic from one or more subnets to pass through. Therefore you can think of the host as gateways to the remote portion of the network.
The configuration of the site-to-site VPN only differs from the host-to-host VPN in that one or more networks or subnets must be specified in the configuration file.
Prerequisites
- A host-to-host VPN is already configured.
Procedure
Copy the file with the configuration of your host-to-host VPN to a new file, for example:
# cp /etc/ipsec.d/my_host-to-host.conf /etc/ipsec.d/my_site-to-site.conf
Add the subnet configuration to the file created in the previous step, for example:
conn mysubnet also=mytunnel leftsubnet=192.0.1.0/24 rightsubnet=192.0.2.0/24 auto=start conn mysubnet6 also=mytunnel leftsubnet=2001:db8:0:1::/64 rightsubnet=2001:db8:0:2::/64 auto=start # the following part of the configuration file is the same for both host-to-host and site-to-site connections: conn mytunnel leftid=@west left=192.1.2.23 leftrsasigkey=0sAQOrlo+hOafUZDlCQmXFrje/oZm [...] W2n417C/4urYHQkCvuIQ== rightid=@east right=192.1.2.45 rightrsasigkey=0sAQO3fwC6nSSGgt64DWiYZzuHbc4 [...] D/v8t5YTQ== authby=rsasig
7.6. Configuring a remote access VPN
Road warriors are traveling users with mobile clients and a dynamically assigned IP address. The mobile clients authenticate using X.509 certificates.
The following example shows configuration for IKEv2
, and it avoids using the IKEv1
XAUTH protocol.
On the server:
conn roadwarriors ikev2=insist # support (roaming) MOBIKE clients (RFC 4555) mobike=yes fragmentation=yes left=1.2.3.4 # if access to the LAN is given, enable this, otherwise use 0.0.0.0/0 # leftsubnet=10.10.0.0/16 leftsubnet=0.0.0.0/0 leftcert=gw.example.com leftid=%fromcert leftxauthserver=yes leftmodecfgserver=yes right=%any # trust our own Certificate Agency rightca=%same # pick an IP address pool to assign to remote users # 100.64.0.0/16 prevents RFC1918 clashes when remote users are behind NAT rightaddresspool=100.64.13.100-100.64.13.254 # if you want remote clients to use some local DNS zones and servers modecfgdns="1.2.3.4, 5.6.7.8" modecfgdomains="internal.company.com, corp" rightxauthclient=yes rightmodecfgclient=yes authby=rsasig # optionally, run the client X.509 ID through pam to allow or deny client # pam-authorize=yes # load connection, do not initiate auto=add # kill vanished roadwarriors dpddelay=1m dpdtimeout=5m dpdaction=clear
On the mobile client, the road warrior’s device, use a slight variation of the previous configuration:
conn to-vpn-server ikev2=insist # pick up our dynamic IP left=%defaultroute leftsubnet=0.0.0.0/0 leftcert=myname.example.com leftid=%fromcert leftmodecfgclient=yes # right can also be a DNS hostname right=1.2.3.4 # if access to the remote LAN is required, enable this, otherwise use 0.0.0.0/0 # rightsubnet=10.10.0.0/16 rightsubnet=0.0.0.0/0 fragmentation=yes # trust our own Certificate Agency rightca=%same authby=rsasig # allow narrowing to the server’s suggested assigned IP and remote subnet narrowing=yes # support (roaming) MOBIKE clients (RFC 4555) mobike=yes # initiate connection auto=start
7.7. Configuring a mesh VPN
A mesh VPN network, which is also known as an any-to-any VPN, is a network where all nodes communicate using IPsec. The configuration allows for exceptions for nodes that cannot use IPsec. The mesh VPN network can be configured in two ways:
- To require IPsec.
- To prefer IPsec but allow a fallback to clear-text communication.
Authentication between the nodes can be based on X.509 certificates or on DNS Security Extensions (DNSSEC).
You can use any regular IKEv2 authentication method for opportunistic IPsec, because these connections are regular Libreswan configurations, except for the opportunistic IPsec that is defined by right=%opportunisticgroup
entry. A common authentication method is for hosts to authenticate each other based on X.509 certificates using a commonly shared certification authority (CA). Cloud deployments typically issue certificates for each node in the cloud as part of the standard procedure.
Do not use PreSharedKey (PSK) authentication because one compromised host would result in group PSK secret being compromised as well.
You can use NULL authentication to deploy encryption between nodes without authentication, which protects only against passive attackers.
The following procedure uses X.509 certificates. You can generate these certificates by using any kind of CA management system, such as the Dogtag Certificate System. Dogtag assumes that the certificates for each node are available in the PKCS #12 format (.p12
files), which contain the private key, the node certificate, and the Root CA certificate used to validate other nodes' X.509 certificates.
Each node has an identical configuration with the exception of its X.509 certificate. This allows for adding new nodes without reconfiguring any of the existing nodes in the network. The PKCS #12 files require a "friendly name", for which we use the name "node" so that the configuration files referencing the friendly name can be identical for all nodes.
Prerequisites
-
Libreswan is installed, and the
ipsec
service is started on each node. A new NSS database is initialized.
If you already have an old NSS database, remove the old database files:
# systemctl stop ipsec # rm /etc/ipsec.d/*db
You can initialize a new database with the following command:
# ipsec initnss
Procedure
On each node, import PKCS #12 files. This step requires the password used to generate the PKCS #12 files:
# ipsec import nodeXXX.p12
Create the following three connection definitions for the
IPsec required
(private),IPsec optional
(private-or-clear), andNo IPsec
(clear) profiles:# cat /etc/ipsec.d/mesh.conf conn clear auto=ondemand 1 type=passthrough authby=never left=%defaultroute right=%group conn private auto=ondemand type=transport authby=rsasig failureshunt=drop negotiationshunt=drop ikev2=insist left=%defaultroute leftcert=nodeXXXX leftid=%fromcert 2 rightid=%fromcert right=%opportunisticgroup conn private-or-clear auto=ondemand type=transport authby=rsasig failureshunt=passthrough negotiationshunt=passthrough # left left=%defaultroute leftcert=nodeXXXX 3 leftid=%fromcert leftrsasigkey=%cert # right rightrsasigkey=%cert rightid=%fromcert right=%opportunisticgroup
- 1
- The
auto
variable has several options:You can use the
ondemand
connection option with opportunistic IPsec to initiate the IPsec connection, or for explicitly configured connections that do not need to be active all the time. This option sets up a trap XFRM policy in the kernel, enabling the IPsec connection to begin when it receives the first packet that matches that policy.You can effectively configure and manage your IPsec connections, whether you use Opportunistic IPsec or explicitly configured connections, by using the following options:
- The
add
option -
Loads the connection configuration and prepares it for responding to remote initiations. However, the connection is not automatically initiated from the local side. You can manually start the IPsec connection by using the command
ipsec auto --up
. - The
start
option - Loads the connection configuration and prepares it for responding to remote initiations. Additionally, it immediately initiates a connection to the remote peer. You can use this option for permanent and always active connections.
- The
- 2
- The
leftid
andrightid
variables identify the right and the left channel of the IPsec tunnel connection. You can use these variables to obtain the value of the local IP address or the subject DN of the local certificate, if you have configured one. - 3
- The
leftcert
variable defines the nickname of the NSS database that you want to use.Add the IP address of the network to the corresponding category. For example, if all nodes reside in the
10.15.0.0/16
network, and all nodes must use IPsec encryption:# echo "10.15.0.0/16" >> /etc/ipsec.d/policies/private
To allow certain nodes, for example,
10.15.34.0/24
, to work with and without IPsec, add those nodes to the private-or-clear group:# echo "10.15.34.0/24" >> /etc/ipsec.d/policies/private-or-clear
To define a host, for example,
10.15.1.2
, which is not capable of IPsec into the clear group, use:# echo "10.15.1.2/32" >> /etc/ipsec.d/policies/clear
You can create the files in the
/etc/ipsec.d/policies
directory from a template for each new node, or you can provision them by using Puppet or Ansible.Note that every node has the same list of exceptions or different traffic flow expectations. Two nodes, therefore, might not be able to communicate because one requires IPsec and the other cannot use IPsec.
Restart the node to add it to the configured mesh:
# systemctl restart ipsec
Verification
Open an IPsec tunnel by using the
ping
command:# ping <nodeYYY>
Display the NSS database with the imported certification:
# certutil -L -d sql:/etc/ipsec.d Certificate Nickname Trust Attributes SSL,S/MIME,JAR/XPI west u,u,u ca CT,,
See which tunnels are open on the node:
# ipsec trafficstatus 006 #2: "private#10.15.0.0/16"[1] ...<nodeYYY>, type=ESP, add_time=1691399301, inBytes=512, outBytes=512, maxBytes=2^63B, id='C=US, ST=NC, O=Example Organization, CN=east'
Additional resources
-
ipsec.conf(5)
man page on your system -
For more information about the
authby
variable, see 6.2. Authentication methods in Libreswan.
7.8. Deploying a FIPS-compliant IPsec VPN
You can deploy a FIPS-compliant IPsec VPN solution with Libreswan. To do so, you can identify which cryptographic algorithms are available and which are disabled for Libreswan in FIPS mode.
Prerequisites
-
The
AppStream
repository is enabled.
Procedure
Install the
libreswan
packages:# yum install libreswan
If you are re-installing Libreswan, remove its old NSS database:
# systemctl stop ipsec # rm /etc/ipsec.d/*db
Start the
ipsec
service, and enable the service to be started automatically on boot:# systemctl enable ipsec --now
Configure the firewall to allow
500
and4500
UDP ports for the IKE, ESP, and AH protocols by adding theipsec
service:# firewall-cmd --add-service="ipsec" # firewall-cmd --runtime-to-permanent
Switch the system to FIPS mode:
# fips-mode-setup --enable
Restart your system to allow the kernel to switch to FIPS mode:
# reboot
Verification
Confirm Libreswan is running in FIPS mode:
# ipsec whack --fipsstatus 000 FIPS mode enabled
Alternatively, check entries for the
ipsec
unit in thesystemd
journal:$ journalctl -u ipsec ... Jan 22 11:26:50 localhost.localdomain pluto[3076]: FIPS Product: YES Jan 22 11:26:50 localhost.localdomain pluto[3076]: FIPS Kernel: YES Jan 22 11:26:50 localhost.localdomain pluto[3076]: FIPS Mode: YES
To see the available algorithms in FIPS mode:
# ipsec pluto --selftest 2>&1 | head -11 FIPS Product: YES FIPS Kernel: YES FIPS Mode: YES NSS DB directory: sql:/etc/ipsec.d Initializing NSS Opening NSS database "sql:/etc/ipsec.d" read-only NSS initialized NSS crypto library initialized FIPS HMAC integrity support [enabled] FIPS mode enabled for pluto daemon NSS library is running in FIPS mode FIPS HMAC integrity verification self-test passed
To query disabled algorithms in FIPS mode:
# ipsec pluto --selftest 2>&1 | grep disabled Encryption algorithm CAMELLIA_CTR disabled; not FIPS compliant Encryption algorithm CAMELLIA_CBC disabled; not FIPS compliant Encryption algorithm SERPENT_CBC disabled; not FIPS compliant Encryption algorithm TWOFISH_CBC disabled; not FIPS compliant Encryption algorithm TWOFISH_SSH disabled; not FIPS compliant Encryption algorithm NULL disabled; not FIPS compliant Encryption algorithm CHACHA20_POLY1305 disabled; not FIPS compliant Hash algorithm MD5 disabled; not FIPS compliant PRF algorithm HMAC_MD5 disabled; not FIPS compliant PRF algorithm AES_XCBC disabled; not FIPS compliant Integrity algorithm HMAC_MD5_96 disabled; not FIPS compliant Integrity algorithm HMAC_SHA2_256_TRUNCBUG disabled; not FIPS compliant Integrity algorithm AES_XCBC_96 disabled; not FIPS compliant DH algorithm MODP1024 disabled; not FIPS compliant DH algorithm MODP1536 disabled; not FIPS compliant DH algorithm DH31 disabled; not FIPS compliant
To list all allowed algorithms and ciphers in FIPS mode:
# ipsec pluto --selftest 2>&1 | grep ESP | grep FIPS | sed "s/^.*FIPS//" {256,192,*128} aes_ccm, aes_ccm_c {256,192,*128} aes_ccm_b {256,192,*128} aes_ccm_a [*192] 3des {256,192,*128} aes_gcm, aes_gcm_c {256,192,*128} aes_gcm_b {256,192,*128} aes_gcm_a {256,192,*128} aesctr {256,192,*128} aes {256,192,*128} aes_gmac sha, sha1, sha1_96, hmac_sha1 sha512, sha2_512, sha2_512_256, hmac_sha2_512 sha384, sha2_384, sha2_384_192, hmac_sha2_384 sha2, sha256, sha2_256, sha2_256_128, hmac_sha2_256 aes_cmac null null, dh0 dh14 dh15 dh16 dh17 dh18 ecp_256, ecp256 ecp_384, ecp384 ecp_521, ecp521
Additional resources
7.9. Protecting the IPsec NSS database by a password
By default, the IPsec service creates its Network Security Services (NSS) database with an empty password during the first start. To enhance security, you can add password protection.
In the previous releases of RHEL up to version 6.6, you had to protect the IPsec NSS database with a password to meet the FIPS 140-2 requirements because the NSS cryptographic libraries were certified for the FIPS 140-2 Level 2 standard. In RHEL 8, NIST certified NSS to Level 1 of this standard, and this status does not require password protection for the database.
Prerequisites
-
The
/etc/ipsec.d/
directory contains NSS database files.
Procedure
Enable password protection for the
NSS
database for Libreswan:# certutil -N -d sql:/etc/ipsec.d Enter Password or Pin for "NSS Certificate DB": Enter a password which will be used to encrypt your keys. The password should be at least 8 characters long, and should contain at least one non-alphabetic character. Enter new password:
Create the
/etc/ipsec.d/nsspassword
file that containins the password you have set in the previous step, for example:# cat /etc/ipsec.d/nsspassword NSS Certificate DB:_<password>_
The
nsspassword
file use the following syntax:<token_1>:<password1> <token_2>:<password2>
The default NSS software token is
NSS Certificate DB
. If your system is running in FIPS mode, the name of the token isNSS FIPS 140-2 Certificate DB
.Depending on your scenario, either start or restart the
ipsec
service after you finish thensspassword
file:# systemctl restart ipsec
Verification
Check that the
ipsec
service is running after you have added a non-empty password to its NSS database:# systemctl status ipsec ● ipsec.service - Internet Key Exchange (IKE) Protocol Daemon for IPsec Loaded: loaded (/usr/lib/systemd/system/ipsec.service; enabled; vendor preset: disable> Active: active (running)...
Verification
Check that the
Journal
log contains entries that confirm a successful initialization:# journalctl -u ipsec ... pluto[6214]: Initializing NSS using read-write database "sql:/etc/ipsec.d" pluto[6214]: NSS Password from file "/etc/ipsec.d/nsspassword" for token "NSS Certificate DB" with length 20 passed to NSS pluto[6214]: NSS crypto library initialized ...
Additional resources
-
certutil(1)
man page on your system - FIPS 140-2 and FIPS 140-3 in the Compliance Activities and Government Standards Knowledgebase article.
7.10. Configuring an IPsec VPN to use TCP
Libreswan supports TCP encapsulation of IKE and IPsec packets as described in RFC 8229. With this feature, you can establish IPsec VPNs on networks that prevent traffic transmitted via UDP and Encapsulating Security Payload (ESP). You can configure VPN servers and clients to use TCP either as a fallback or as the main VPN transport protocol. Because TCP encapsulation has bigger performance costs, use TCP as the main VPN protocol only if UDP is permanently blocked in your scenario.
Prerequisites
- A remote-access VPN is already configured.
Procedure
Add the following option to the
/etc/ipsec.conf
file in theconfig setup
section:listen-tcp=yes
To use TCP encapsulation as a fallback option when the first attempt over UDP fails, add the following two options to the client’s connection definition:
enable-tcp=fallback tcp-remoteport=4500
Alternatively, if you know that UDP is permanently blocked, use the following options in the client’s connection configuration:
enable-tcp=yes tcp-remoteport=4500
Additional resources
7.11. Configuring automatic detection and usage of ESP hardware offload to accelerate an IPsec connection
Offloading Encapsulating Security Payload (ESP) to the hardware accelerates IPsec connections over Ethernet. By default, Libreswan detects if hardware supports this feature and, as a result, enables ESP hardware offload. In case that the feature was disabled or explicitly enabled, you can switch back to automatic detection.
Prerequisites
- The network card supports ESP hardware offload.
- The network driver supports ESP hardware offload.
- The IPsec connection is configured and works.
Procedure
-
Edit the Libreswan configuration file in the
/etc/ipsec.d/
directory of the connection that should use automatic detection of ESP hardware offload support. -
Ensure the
nic-offload
parameter is not set in the connection’s settings. If you removed
nic-offload
, restart theipsec
service:# systemctl restart ipsec
Verification
Display the
tx_ipsec
andrx_ipsec
counters of the Ethernet device the IPsec connection uses:# ethtool -S enp1s0 | egrep "_ipsec" tx_ipsec: 10 rx_ipsec: 10
Send traffic through the IPsec tunnel. For example, ping a remote IP address:
# ping -c 5 remote_ip_address
Display the
tx_ipsec
andrx_ipsec
counters of the Ethernet device again:# ethtool -S enp1s0 | egrep "_ipsec" tx_ipsec: 15 rx_ipsec: 15
If the counter values have increased, ESP hardware offload works.
Additional resources
7.12. Configuring ESP hardware offload on a bond to accelerate an IPsec connection
Offloading Encapsulating Security Payload (ESP) to the hardware accelerates IPsec connections. If you use a network bond for fail-over reasons, the requirements and the procedure to configure ESP hardware offload are different from those using a regular Ethernet device. For example, in this scenario, you enable the offload support on the bond, and the kernel applies the settings to the ports of the bond.
Prerequisites
-
All network cards in the bond support ESP hardware offload. Use the
ethtool -k <interface_name> | grep "esp-hw-offload"
command to verify whether each bond port supports this feature. - The bond is configured and works.
-
The bond uses the
active-backup
mode. The bonding driver does not support any other modes for this feature. - The IPsec connection is configured and works.
Procedure
Enable ESP hardware offload support on the network bond:
# nmcli connection modify bond0 ethtool.feature-esp-hw-offload on
This command enables ESP hardware offload support on the
bond0
connection.Reactivate the
bond0
connection:# nmcli connection up bond0
Edit the Libreswan configuration file in the
/etc/ipsec.d/
directory of the connection that should use ESP hardware offload, and append thenic-offload=yes
statement to the connection entry:conn example ... nic-offload=yes
Restart the
ipsec
service:# systemctl restart ipsec
Verification
The verification methods depend on various aspects, such as the kernel version and driver. For example, certain drivers provide counters, but their names can vary. See the documentation of your network driver for details.
The following verification steps work for the ixgbe
driver on Red Hat Enterprise Linux 8:
Display the active port of the bond:
# grep "Currently Active Slave" /proc/net/bonding/bond0 Currently Active Slave: enp1s0
Display the
tx_ipsec
andrx_ipsec
counters of the active port:# ethtool -S enp1s0 | egrep "_ipsec" tx_ipsec: 10 rx_ipsec: 10
Send traffic through the IPsec tunnel. For example, ping a remote IP address:
# ping -c 5 remote_ip_address
Display the
tx_ipsec
andrx_ipsec
counters of the active port again:# ethtool -S enp1s0 | egrep "_ipsec" tx_ipsec: 15 rx_ipsec: 15
If the counter values have increased, ESP hardware offload works.
Additional resources
7.13. Configuring VPN connections with IPsec by using RHEL system roles
With the vpn
system role, you can configure VPN connections on RHEL systems by using Red Hat Ansible Automation Platform. You can use it to set up host-to-host, network-to-network, VPN Remote Access Server, and mesh configurations.
For host-to-host connections, the role sets up a VPN tunnel between each pair of hosts in the list of vpn_connections
using the default parameters, including generating keys as needed. Alternatively, you can configure it to create an opportunistic mesh configuration between all hosts listed. The role assumes that the names of the hosts under hosts
are the same as the names of the hosts used in the Ansible inventory, and that you can use those names to configure the tunnels.
The vpn
RHEL system role currently supports only Libreswan, which is an IPsec implementation, as the VPN provider.
7.13.1. Creating a host-to-host VPN with IPsec by using the vpn
RHEL system role
You can use the vpn
system role to configure host-to-host connections by running an Ansible playbook on the control node, which configures all managed nodes listed in an inventory file.
Prerequisites
- You have prepared the control node and the managed nodes
- You are logged in to the control node as a user who can run playbooks on the managed nodes.
-
The account you use to connect to the managed nodes has
sudo
permissions on them.
Procedure
Create a playbook file, for example
~/playbook.yml
, with the following content:- name: Host to host VPN hosts: managed-node-01.example.com, managed-node-02.example.com roles: - rhel-system-roles.vpn vars: vpn_connections: - hosts: managed-node-01.example.com: managed-node-02.example.com: vpn_manage_firewall: true vpn_manage_selinux: true
This playbook configures the connection
managed-node-01.example.com-to-managed-node-02.example.com
by using pre-shared key authentication with keys auto-generated by the system role. Becausevpn_manage_firewall
andvpn_manage_selinux
are both set totrue
, thevpn
role uses thefirewall
andselinux
roles to manage the ports used by thevpn
role.To configure connections from managed hosts to external hosts that are not listed in the inventory file, add the following section to the
vpn_connections
list of hosts:vpn_connections: - hosts: managed-node-01.example.com: <external_node>: hostname: <IP_address_or_hostname>
This configures one additional connection:
managed-node-01.example.com-to-<external_node>
NoteThe connections are configured only on the managed nodes and not on the external node.
Optional: You can specify multiple VPN connections for the managed nodes by using additional sections within
vpn_connections
, for example, a control plane and a data plane:- name: Multiple VPN hosts: managed-node-01.example.com, managed-node-02.example.com roles: - rhel-system-roles.vpn vars: vpn_connections: - name: control_plane_vpn hosts: managed-node-01.example.com: hostname: 192.0.2.0 # IP for the control plane managed-node-02.example.com: hostname: 192.0.2.1 - name: data_plane_vpn hosts: managed-node-01.example.com: hostname: 10.0.0.1 # IP for the data plane managed-node-02.example.com: hostname: 10.0.0.2
Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/playbook.yml
Note that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook ~/playbook.yml
Verification
On the managed nodes, confirm that the connection is successfully loaded:
# ipsec status | grep <connection_name>
Replace
<connection_name>
with the name of the connection from this node, for examplemanaged_node1-to-managed_node2
.NoteBy default, the role generates a descriptive name for each connection it creates from the perspective of each system. For example, when creating a connection between
managed_node1
andmanaged_node2
, the descriptive name of this connection onmanaged_node1
ismanaged_node1-to-managed_node2
but onmanaged_node2
the connection is namedmanaged_node2-to-managed_node1
.On the managed nodes, confirm that the connection is successfully started:
# ipsec trafficstatus | grep <connection_name>
Optional: If a connection does not successfully load, manually add the connection by entering the following command. This provides more specific information indicating why the connection failed to establish:
# ipsec auto --add <connection_name>
NoteAny errors that may occur during the process of loading and starting the connection are reported in the
/var/log/pluto.log
file. Because these logs are hard to parse, manually add the connection to obtain log messages from the standard output instead.
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.vpn/README.md
file -
/usr/share/doc/rhel-system-roles/vpn/
directory
7.13.2. Creating an opportunistic mesh VPN connection with IPsec by using the vpn
RHEL system role
You can use the vpn
system role to configure an opportunistic mesh VPN connection that uses certificates for authentication by running an Ansible playbook on the control node, which will configure all the managed nodes listed in an inventory file.
Prerequisites
- You have prepared the control node and the managed nodes
- You are logged in to the control node as a user who can run playbooks on the managed nodes.
-
The account you use to connect to the managed nodes has
sudo
permissions on them. -
The IPsec Network Security Services (NSS) crypto library in the
/etc/ipsec.d/
directory contains the necessary certificates.
Procedure
Create a playbook file, for example
~/playbook.yml
, with the following content:- name: Mesh VPN hosts: managed-node-01.example.com, managed-node-02.example.com, managed-node-03.example.com roles: - rhel-system-roles.vpn vars: vpn_connections: - opportunistic: true auth_method: cert policies: - policy: private cidr: default - policy: private-or-clear cidr: 198.51.100.0/24 - policy: private cidr: 192.0.2.0/24 - policy: clear cidr: 192.0.2.7/32 vpn_manage_firewall: true vpn_manage_selinux: true
Authentication with certificates is configured by defining the
auth_method: cert
parameter in the playbook. By default, the node name is used as the certificate nickname. In this example, this ismanaged-node-01.example.com
. You can define different certificate names by using thecert_name
attribute in your inventory.In this example procedure, the control node, which is the system from which you will run the Ansible playbook, shares the same classless inter-domain routing (CIDR) number as both of the managed nodes (192.0.2.0/24) and has the IP address 192.0.2.7. Therefore, the control node falls under the private policy which is automatically created for CIDR 192.0.2.0/24.
To prevent SSH connection loss during the play, a clear policy for the control node is included in the list of policies. Note that there is also an item in the policies list where the CIDR is equal to default. This is because this playbook overrides the rule from the default policy to make it private instead of private-or-clear.
Because
vpn_manage_firewall
andvpn_manage_selinux
are both set totrue
, thevpn
role uses thefirewall
andselinux
roles to manage the ports used by thevpn
role.Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/playbook.yml
Note that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook ~/playbook.yml
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.vpn/README.md
file -
/usr/share/doc/rhel-system-roles/vpn/
directory
7.14. Configuring IPsec connections that opt out of the system-wide crypto policies
Overriding system-wide crypto-policies for a connection
The RHEL system-wide cryptographic policies create a special connection called %default
. This connection contains the default values for the ikev2
, esp
, and ike
options. However, you can override the default values by specifying the mentioned option in the connection configuration file.
For example, the following configuration allows connections that use IKEv1 with AES and SHA-1 or SHA-2, and IPsec (ESP) with either AES-GCM or AES-CBC:
conn MyExample ... ikev2=never ike=aes-sha2,aes-sha1;modp2048 esp=aes_gcm,aes-sha2,aes-sha1 ...
Note that AES-GCM is available for IPsec (ESP) and for IKEv2, but not for IKEv1.
Disabling system-wide crypto policies for all connections
To disable system-wide crypto policies for all IPsec connections, comment out the following line in the /etc/ipsec.conf
file:
include /etc/crypto-policies/back-ends/libreswan.config
Then add the ikev2=never
option to your connection configuration file.
Additional resources
7.15. Troubleshooting IPsec VPN configurations
Problems related to IPsec VPN configurations most commonly occur due to several main reasons. If you are encountering such problems, you can check if the cause of the problem corresponds to any of the following scenarios, and apply the corresponding solution.
Basic connection troubleshooting
Most problems with VPN connections occur in new deployments, where administrators configured endpoints with mismatched configuration options. Also, a working configuration can suddenly stop working, often due to newly introduced incompatible values. This could be the result of an administrator changing the configuration. Alternatively, an administrator may have installed a firmware update or a package update with different default values for certain options, such as encryption algorithms.
To confirm that an IPsec VPN connection is established:
# ipsec trafficstatus
006 #8: "vpn.example.com"[1] 192.0.2.1, type=ESP, add_time=1595296930, inBytes=5999, outBytes=3231, id='@vpn.example.com', lease=100.64.13.5/32
If the output is empty or does not show an entry with the connection name, the tunnel is broken.
To check that the problem is in the connection:
Reload the vpn.example.com connection:
# ipsec auto --add vpn.example.com 002 added connection description "vpn.example.com"
Next, initiate the VPN connection:
# ipsec auto --up vpn.example.com
Firewall-related problems
The most common problem is that a firewall on one of the IPsec endpoints or on a router between the endpoints is dropping all Internet Key Exchange (IKE) packets.
For IKEv2, an output similar to the following example indicates a problem with a firewall:
# ipsec auto --up vpn.example.com 181 "vpn.example.com"[1] 192.0.2.2 #15: initiating IKEv2 IKE SA 181 "vpn.example.com"[1] 192.0.2.2 #15: STATE_PARENT_I1: sent v2I1, expected v2R1 010 "vpn.example.com"[1] 192.0.2.2 #15: STATE_PARENT_I1: retransmission; will wait 0.5 seconds for response 010 "vpn.example.com"[1] 192.0.2.2 #15: STATE_PARENT_I1: retransmission; will wait 1 seconds for response 010 "vpn.example.com"[1] 192.0.2.2 #15: STATE_PARENT_I1: retransmission; will wait 2 seconds for ...
For IKEv1, the output of the initiating command looks like:
# ipsec auto --up vpn.example.com 002 "vpn.example.com" #9: initiating Main Mode 102 "vpn.example.com" #9: STATE_MAIN_I1: sent MI1, expecting MR1 010 "vpn.example.com" #9: STATE_MAIN_I1: retransmission; will wait 0.5 seconds for response 010 "vpn.example.com" #9: STATE_MAIN_I1: retransmission; will wait 1 seconds for response 010 "vpn.example.com" #9: STATE_MAIN_I1: retransmission; will wait 2 seconds for response ...
Because the IKE protocol, which is used to set up IPsec, is encrypted, you can troubleshoot only a limited subset of problems using the tcpdump
tool. If a firewall is dropping IKE or IPsec packets, you can try to find the cause using the tcpdump
utility. However, tcpdump
cannot diagnose other problems with IPsec VPN connections.
To capture the negotiation of the VPN and all encrypted data on the
eth0
interface:# tcpdump -i eth0 -n -n esp or udp port 500 or udp port 4500 or tcp port 4500
Mismatched algorithms, protocols, and policies
VPN connections require that the endpoints have matching IKE algorithms, IPsec algorithms, and IP address ranges. If a mismatch occurs, the connection fails. If you identify a mismatch by using one of the following methods, fix it by aligning algorithms, protocols, or policies.
If the remote endpoint is not running IKE/IPsec, you can see an ICMP packet indicating it. For example:
# ipsec auto --up vpn.example.com ... 000 "vpn.example.com"[1] 192.0.2.2 #16: ERROR: asynchronous network error report on wlp2s0 (192.0.2.2:500), complainant 198.51.100.1: Connection refused [errno 111, origin ICMP type 3 code 3 (not authenticated)] ...
Example of mismatched IKE algorithms:
# ipsec auto --up vpn.example.com ... 003 "vpn.example.com"[1] 193.110.157.148 #3: dropping unexpected IKE_SA_INIT message containing NO_PROPOSAL_CHOSEN notification; message payloads: N; missing payloads: SA,KE,Ni
Example of mismatched IPsec algorithms:
# ipsec auto --up vpn.example.com ... 182 "vpn.example.com"[1] 193.110.157.148 #5: STATE_PARENT_I2: sent v2I2, expected v2R2 {auth=IKEv2 cipher=AES_GCM_16_256 integ=n/a prf=HMAC_SHA2_256 group=MODP2048} 002 "vpn.example.com"[1] 193.110.157.148 #6: IKE_AUTH response contained the error notification NO_PROPOSAL_CHOSEN
A mismatched IKE version could also result in the remote endpoint dropping the request without a response. This looks identical to a firewall dropping all IKE packets.
Example of mismatched IP address ranges for IKEv2 (called Traffic Selectors - TS):
# ipsec auto --up vpn.example.com ... 1v2 "vpn.example.com" #1: STATE_PARENT_I2: sent v2I2, expected v2R2 {auth=IKEv2 cipher=AES_GCM_16_256 integ=n/a prf=HMAC_SHA2_512 group=MODP2048} 002 "vpn.example.com" #2: IKE_AUTH response contained the error notification TS_UNACCEPTABLE
Example of mismatched IP address ranges for IKEv1:
# ipsec auto --up vpn.example.com ... 031 "vpn.example.com" #2: STATE_QUICK_I1: 60 second timeout exceeded after 0 retransmits. No acceptable response to our first Quick Mode message: perhaps peer likes no proposal
When using PreSharedKeys (PSK) in IKEv1, if both sides do not put in the same PSK, the entire IKE message becomes unreadable:
# ipsec auto --up vpn.example.com ... 003 "vpn.example.com" #1: received Hash Payload does not match computed value 223 "vpn.example.com" #1: sending notification INVALID_HASH_INFORMATION to 192.0.2.23:500
In IKEv2, the mismatched-PSK error results in an AUTHENTICATION_FAILED message:
# ipsec auto --up vpn.example.com ... 002 "vpn.example.com" #1: IKE SA authentication request rejected by peer: AUTHENTICATION_FAILED
Maximum transmission unit
Other than firewalls blocking IKE or IPsec packets, the most common cause of networking problems relates to an increased packet size of encrypted packets. Network hardware fragments packets larger than the maximum transmission unit (MTU), for example, 1500 bytes. Often, the fragments are lost and the packets fail to re-assemble. This leads to intermittent failures, when a ping test, which uses small-sized packets, works but other traffic fails. In this case, you can establish an SSH session but the terminal freezes as soon as you use it, for example, by entering the 'ls -al /usr' command on the remote host.
To work around the problem, reduce MTU size by adding the mtu=1400
option to the tunnel configuration file.
Alternatively, for TCP connections, enable an iptables rule that changes the MSS value:
# iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
If the previous command does not solve the problem in your scenario, directly specify a lower size in the set-mss
parameter:
# iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1380
Network address translation (NAT)
When an IPsec host also serves as a NAT router, it could accidentally remap packets. The following example configuration demonstrates the problem:
conn myvpn left=172.16.0.1 leftsubnet=10.0.2.0/24 right=172.16.0.2 rightsubnet=192.168.0.0/16 …
The system with address 172.16.0.1 have a NAT rule:
iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
If the system on address 10.0.2.33 sends a packet to 192.168.0.1, then the router translates the source 10.0.2.33 to 172.16.0.1 before it applies the IPsec encryption.
Then, the packet with the source address 10.0.2.33 no longer matches the conn myvpn
configuration, and IPsec does not encrypt this packet.
To solve this problem, insert rules that exclude NAT for target IPsec subnet ranges on the router, in this example:
iptables -t nat -I POSTROUTING -s 10.0.2.0/24 -d 192.168.0.0/16 -j RETURN
Kernel IPsec subsystem bugs
The kernel IPsec subsystem might fail, for example, when a bug causes a desynchronizing of the IKE user space and the IPsec kernel. To check for such problems:
$ cat /proc/net/xfrm_stat
XfrmInError 0
XfrmInBufferError 0
...
Any non-zero value in the output of the previous command indicates a problem. If you encounter this problem, open a new support case, and attach the output of the previous command along with the corresponding IKE logs.
Libreswan logs
Libreswan logs using the syslog
protocol by default. You can use the journalctl
command to find log entries related to IPsec. Because the corresponding entries to the log are sent by the pluto
IKE daemon, search for the “pluto” keyword, for example:
$ journalctl -b | grep pluto
To show a live log for the ipsec
service:
$ journalctl -f -u ipsec
If the default level of logging does not reveal your configuration problem, enable debug logs by adding the plutodebug=all
option to the config setup
section in the /etc/ipsec.conf
file.
Note that debug logging produces a lot of entries, and it is possible that either the journald
or syslogd
service rate-limits the syslog
messages. To ensure you have complete logs, redirect the logging to a file. Edit the /etc/ipsec.conf
, and add the logfile=/var/log/pluto.log
in the config setup
section.
Additional resources
- Troubleshooting problems by using log files
-
tcpdump(8)
andipsec.conf(5)
man pages. - Using and configuring firewalld
7.16. Configuring a VPN connection with control-center
If you use Red Hat Enterprise Linux with a graphical interface, you can configure a VPN connection in the GNOME control-center
.
Prerequisites
-
The
NetworkManager-libreswan-gnome
package is installed.
Procedure
-
Press the Super key, type
Settings
, and press Enter to open thecontrol-center
application. -
Select the
Network
entry on the left. - Click the + icon.
-
Select
VPN
. Select the
Identity
menu entry to see the basic configuration options:General
Gateway
— The name orIP
address of the remote VPN gateway.Authentication
Type
-
IKEv2 (Certificate)
- client is authenticated by certificate. It is more secure (default). IKEv1 (XAUTH)
- client is authenticated by user name and password, or a pre-shared key (PSK).The following configuration settings are available under the
Advanced
section:Figure 7.1. Advanced options of a VPN connection
WarningWhen configuring an IPsec-based VPN connection using the
gnome-control-center
application, theAdvanced
dialog displays the configuration, but it does not allow any changes. As a consequence, users cannot change any advanced IPsec options. Use thenm-connection-editor
ornmcli
tools instead to perform configuration of the advanced properties.Identification
Domain
— If required, enter the Domain Name.Security
-
Phase1 Algorithms
— corresponds to theike
Libreswan parameter — enter the algorithms to be used to authenticate and set up an encrypted channel. Phase2 Algorithms
— corresponds to theesp
Libreswan parameter — enter the algorithms to be used for theIPsec
negotiations.Check the
Disable PFS
field to turn off Perfect Forward Secrecy (PFS) to ensure compatibility with old servers that do not support PFS.-
Phase1 Lifetime
— corresponds to theikelifetime
Libreswan parameter — how long the key used to encrypt the traffic will be valid. Phase2 Lifetime
— corresponds to thesalifetime
Libreswan parameter — how long a particular instance of a connection should last before expiring.Note that the encryption key should be changed from time to time for security reasons.
Remote network
— corresponds to therightsubnet
Libreswan parameter — the destination private remote network that should be reached through the VPN.Check the
narrowing
field to enable narrowing. Note that it is only effective in IKEv2 negotiation.-
Enable fragmentation
— corresponds to thefragmentation
Libreswan parameter — whether or not to allow IKE fragmentation. Valid values areyes
(default) orno
. -
Enable Mobike
— corresponds to themobike
Libreswan parameter — whether to allow Mobility and Multihoming Protocol (MOBIKE, RFC 4555) to enable a connection to migrate its endpoint without needing to restart the connection from scratch. This is used on mobile devices that switch between wired, wireless, or mobile data connections. The values areno
(default) oryes
.
-
Select the
menu entry:IPv4 Method
-
Automatic (DHCP)
— Choose this option if the network you are connecting to uses aDHCP
server to assign dynamicIP
addresses. -
Link-Local Only
— Choose this option if the network you are connecting to does not have aDHCP
server and you do not want to assignIP
addresses manually. Random addresses will be assigned as per RFC 3927 with prefix169.254/16
. -
Manual
— Choose this option if you want to assignIP
addresses manually. Disable
—IPv4
is disabled for this connection.DNS
In the
DNS
section, whenAutomatic
isON
, switch it toOFF
to enter the IP address of a DNS server you want to use separating the IPs by comma.Routes
Note that in the
Routes
section, whenAutomatic
isON
, routes from DHCP are used, but you can also add additional static routes. WhenOFF
, only static routes are used.-
Address
— Enter theIP
address of a remote network or host. -
Netmask
— The netmask or prefix length of theIP
address entered above. -
Gateway
— TheIP
address of the gateway leading to the remote network or host entered above. Metric
— A network cost, a preference value to give to this route. Lower values will be preferred over higher values.Use this connection only for resources on its network
Select this check box to prevent the connection from becoming the default route. Selecting this option means that only traffic specifically destined for routes learned automatically over the connection or entered here manually is routed over the connection.
-
To configure
IPv6
settings in aVPN
connection, select the menu entry:IPv6 Method
-
Automatic
— Choose this option to useIPv6
Stateless Address AutoConfiguration (SLAAC) to create an automatic, stateless configuration based on the hardware address and Router Advertisements (RA). -
Automatic, DHCP only
— Choose this option to not use RA, but request information fromDHCPv6
directly to create a stateful configuration. -
Link-Local Only
— Choose this option if the network you are connecting to does not have aDHCP
server and you do not want to assignIP
addresses manually. Random addresses will be assigned as per RFC 4862 with prefixFE80::0
. -
Manual
— Choose this option if you want to assignIP
addresses manually. Disable
—IPv6
is disabled for this connection.Note that
DNS
,Routes
,Use this connection only for resources on its network
are common toIPv4
settings.
-
-
Once you have finished editing the
VPN
connection, click the button to customize the configuration or the button to save it for the existing one. -
Switch the profile to
ON
to active theVPN
connection.
Additional resources
-
nm-settings-libreswan(5)
7.17. Configuring a VPN connection using nm-connection-editor
If you use Red Hat Enterprise Linux with a graphical interface, you can configure a VPN connection in the nm-connection-editor
application.
Prerequisites
-
The
NetworkManager-libreswan-gnome
package is installed. If you configure an Internet Key Exchange version 2 (IKEv2) connection:
- The certificate is imported into the IPsec network security services (NSS) database.
- The nickname of the certificate in the NSS database is known.
Procedure
Open a terminal, and enter:
$ nm-connection-editor
- Click the button to add a new connection.
-
Select the
IPsec based VPN
connection type, and click . On the
VPN
tab:Enter the host name or IP address of the VPN gateway into the
Gateway
field, and select an authentication type. Based on the authentication type, you must enter different additional information:-
IKEv2 (Certifiate)
authenticates the client by using a certificate, which is more secure. This setting requires the nickname of the certificate in the IPsec NSS database IKEv1 (XAUTH)
authenticates the user by using a user name and password (pre-shared key). This setting requires that you enter the following values:- User name
- Password
- Group name
- Secret
-
If the remote server specifies a local identifier for the IKE exchange, enter the exact string in the
Remote ID
field. In the remote server runs Libreswan, this value is set in the server’sleftid
parameter.Optional: Configure additional settings by clicking the
button. You can configure the following settings:Identification
-
Domain
— If required, enter the domain name.
-
Security
-
Phase1 Algorithms
corresponds to theike
Libreswan parameter. Enter the algorithms to be used to authenticate and set up an encrypted channel. Phase2 Algorithms
corresponds to theesp
Libreswan parameter. Enter the algorithms to be used for theIPsec
negotiations.Check the
Disable PFS
field to turn off Perfect Forward Secrecy (PFS) to ensure compatibility with old servers that do not support PFS.-
Phase1 Lifetime
corresponds to theikelifetime
Libreswan parameter. This parameter defines how long the key used to encrypt the traffic is valid. -
Phase2 Lifetime
corresponds to thesalifetime
Libreswan parameter. This parameter defines how long a security association is valid.
-
Connectivity
Remote network
corresponds to therightsubnet
Libreswan parameter and defines the destination private remote network that should be reached through the VPN.Check the
narrowing
field to enable narrowing. Note that it is only effective in the IKEv2 negotiation.-
Enable fragmentation
corresponds to thefragmentation
Libreswan parameter and defines whether or not to allow IKE fragmentation. Valid values areyes
(default) orno
. -
Enable Mobike
corresponds to themobike
Libreswan parameter. The parameter defines whether to allow Mobility and Multihoming Protocol (MOBIKE) (RFC 4555) to enable a connection to migrate its endpoint without needing to restart the connection from scratch. This is used on mobile devices that switch between wired, wireless or mobile data connections. The values areno
(default) oryes
.
On the
IPv4 Settings
tab, select the IP assignment method and, optionally, set additional static addresses, DNS servers, search domains, and routes.- Save the connection.
-
Close
nm-connection-editor
.
When you add a new connection by clicking the NetworkManager creates a new configuration file for that connection and then opens the same dialog that is used for editing an existing connection. The difference between these dialogs is that an existing connection profile has a Details menu entry.
button,Additional resources
-
nm-settings-libreswan(5)
man page on your system
Chapter 8. Configuring IP tunnels
Similar to a VPN, an IP tunnel directly connects two networks over a third network, such as the internet. However, not all tunnel protocols support encryption.
The routers in both networks that establish the tunnel requires at least two interfaces:
- One interface that is connected to the local network
- One interface that is connected to the network through which the tunnel is established.
To establish the tunnel, you create a virtual interface on both routers with an IP address from the remote subnet.
NetworkManager supports the following IP tunnels:
- Generic Routing Encapsulation (GRE)
- Generic Routing Encapsulation over IPv6 (IP6GRE)
- Generic Routing Encapsulation Terminal Access Point (GRETAP)
- Generic Routing Encapsulation Terminal Access Point over IPv6 (IP6GRETAP)
- IPv4 over IPv4 (IPIP)
- IPv4 over IPv6 (IPIP6)
- IPv6 over IPv6 (IP6IP6)
- Simple Internet Transition (SIT)
Depending on the type, these tunnels act either on layer 2 or 3 of the Open Systems Interconnection (OSI) model.
8.1. Configuring an IPIP tunnel to encapsulate IPv4 traffic in IPv4 packets
An IP over IP (IPIP) tunnel operates on OSI layer 3 and encapsulates IPv4 traffic in IPv4 packets as described in RFC 2003.
Data sent through an IPIP tunnel is not encrypted. For security reasons, use the tunnel only for data that is already encrypted, for example, by other protocols, such as HTTPS.
Note that IPIP tunnels support only unicast packets. If you require an IPv4 tunnel that supports multicast, see Configuring a GRE tunnel to encapsulate layer-3 traffic in IPv4 packets.
For example, you can create an IPIP tunnel between two RHEL routers to connect two internal subnets over the internet as shown in the following diagram:
Prerequisites
- Each RHEL router has a network interface that is connected to its local subnet.
- Each RHEL router has a network interface that is connected to the internet.
- The traffic you want to send through the tunnel is IPv4 unicast.
Procedure
On the RHEL router in network A:
Create an IPIP tunnel interface named
tun0
:# nmcli connection add type ip-tunnel ip-tunnel.mode ipip con-name tun0 ifname tun0 remote 198.51.100.5 local 203.0.113.10
The
remote
andlocal
parameters set the public IP addresses of the remote and the local routers.Set the IPv4 address to the
tun0
device:# nmcli connection modify tun0 ipv4.addresses '10.0.1.1/30'
Note that a
/30
subnet with two usable IP addresses is sufficient for the tunnel.Configure the
tun0
connection to use a manual IPv4 configuration:# nmcli connection modify tun0 ipv4.method manual
Add a static route that routes traffic to the
172.16.0.0/24
network to the tunnel IP on router B:# nmcli connection modify tun0 +ipv4.routes "172.16.0.0/24 10.0.1.2"
Enable the
tun0
connection.# nmcli connection up tun0
Enable packet forwarding:
# echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/95-IPv4-forwarding.conf # sysctl -p /etc/sysctl.d/95-IPv4-forwarding.conf
On the RHEL router in network B:
Create an IPIP tunnel interface named
tun0
:# nmcli connection add type ip-tunnel ip-tunnel.mode ipip con-name tun0 ifname tun0 remote 203.0.113.10 local 198.51.100.5
The
remote
andlocal
parameters set the public IP addresses of the remote and local routers.Set the IPv4 address to the
tun0
device:# nmcli connection modify tun0 ipv4.addresses '10.0.1.2/30'
Configure the
tun0
connection to use a manual IPv4 configuration:# nmcli connection modify tun0 ipv4.method manual
Add a static route that routes traffic to the
192.0.2.0/24
network to the tunnel IP on router A:# nmcli connection modify tun0 +ipv4.routes "192.0.2.0/24 10.0.1.1"
Enable the
tun0
connection.# nmcli connection up tun0
Enable packet forwarding:
# echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/95-IPv4-forwarding.conf # sysctl -p /etc/sysctl.d/95-IPv4-forwarding.conf
Verification
From each RHEL router, ping the IP address of the internal interface of the other router:
On Router A, ping
172.16.0.1
:# ping 172.16.0.1
On Router B, ping
192.0.2.1
:# ping 192.0.2.1
8.2. Configuring a GRE tunnel to encapsulate layer-3 traffic in IPv4 packets
A Generic Routing Encapsulation (GRE) tunnel encapsulates layer-3 traffic in IPv4 packets as described in RFC 2784. A GRE tunnel can encapsulate any layer 3 protocol with a valid Ethernet type.
Data sent through a GRE tunnel is not encrypted. For security reasons, use the tunnel only for data that is already encrypted, for example, by other protocols, such as HTTPS.
For example, you can create a GRE tunnel between two RHEL routers to connect two internal subnets over the internet as shown in the following diagram:
Prerequisites
- Each RHEL router has a network interface that is connected to its local subnet.
- Each RHEL router has a network interface that is connected to the internet.
Procedure
On the RHEL router in network A:
Create a GRE tunnel interface named
gre1
:# nmcli connection add type ip-tunnel ip-tunnel.mode gre con-name gre1 ifname gre1 remote 198.51.100.5 local 203.0.113.10
The
remote
andlocal
parameters set the public IP addresses of the remote and the local routers.ImportantThe
gre0
device name is reserved. Usegre1
or a different name for the device.Set the IPv4 address to the
gre1
device:# nmcli connection modify gre1 ipv4.addresses '10.0.1.1/30'
Note that a
/30
subnet with two usable IP addresses is sufficient for the tunnel.Configure the
gre1
connection to use a manual IPv4 configuration:# nmcli connection modify gre1 ipv4.method manual
Add a static route that routes traffic to the
172.16.0.0/24
network to the tunnel IP on router B:# nmcli connection modify gre1 +ipv4.routes "172.16.0.0/24 10.0.1.2"
Enable the
gre1
connection.# nmcli connection up gre1
Enable packet forwarding:
# echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/95-IPv4-forwarding.conf # sysctl -p /etc/sysctl.d/95-IPv4-forwarding.conf
On the RHEL router in network B:
Create a GRE tunnel interface named
gre1
:# nmcli connection add type ip-tunnel ip-tunnel.mode gre con-name gre1 ifname gre1 remote 203.0.113.10 local 198.51.100.5
The
remote
andlocal
parameters set the public IP addresses of the remote and the local routers.Set the IPv4 address to the
gre1
device:# nmcli connection modify gre1 ipv4.addresses '10.0.1.2/30'
Configure the
gre1
connection to use a manual IPv4 configuration:# nmcli connection modify gre1 ipv4.method manual
Add a static route that routes traffic to the
192.0.2.0/24
network to the tunnel IP on router A:# nmcli connection modify gre1 +ipv4.routes "192.0.2.0/24 10.0.1.1"
Enable the
gre1
connection.# nmcli connection up gre1
Enable packet forwarding:
# echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/95-IPv4-forwarding.conf # sysctl -p /etc/sysctl.d/95-IPv4-forwarding.conf
Verification
From each RHEL router, ping the IP address of the internal interface of the other router:
On Router A, ping
172.16.0.1
:# ping 172.16.0.1
On Router B, ping
192.0.2.1
:# ping 192.0.2.1
8.3. Configuring a GRETAP tunnel to transfer Ethernet frames over IPv4
A Generic Routing Encapsulation Terminal Access Point (GRETAP) tunnel operates on OSI level 2 and encapsulates Ethernet traffic in IPv4 packets as described in RFC 2784.
Data sent through a GRETAP tunnel is not encrypted. For security reasons, establish the tunnel over a VPN or a different encrypted connection.
For example, you can create a GRETAP tunnel between two RHEL routers to connect two networks using a bridge as shown in the following diagram:
Prerequisites
- Each RHEL router has a network interface that is connected to its local network, and the interface has no IP configuration assigned.
- Each RHEL router has a network interface that is connected to the internet.
Procedure
On the RHEL router in network A:
Create a bridge interface named
bridge0
:# nmcli connection add type bridge con-name bridge0 ifname bridge0
Configure the IP settings of the bridge:
# nmcli connection modify bridge0 ipv4.addresses '192.0.2.1/24' # nmcli connection modify bridge0 ipv4.method manual
Add a new connection profile for the interface that is connected to local network to the bridge:
# nmcli connection add type ethernet slave-type bridge con-name bridge0-port1 ifname enp1s0 master bridge0
Add a new connection profile for the GRETAP tunnel interface to the bridge:
# nmcli connection add type ip-tunnel ip-tunnel.mode gretap slave-type bridge con-name bridge0-port2 ifname gretap1 remote 198.51.100.5 local 203.0.113.10 master bridge0
The
remote
andlocal
parameters set the public IP addresses of the remote and the local routers.ImportantThe
gretap0
device name is reserved. Usegretap1
or a different name for the device.Optional: Disable the Spanning Tree Protocol (STP) if you do not need it:
# nmcli connection modify bridge0 bridge.stp no
By default, STP is enabled and causes a delay before you can use the connection.
Configure that activating the
bridge0
connection automatically activates the ports of the bridge:# nmcli connection modify bridge0 connection.autoconnect-slaves 1
Active the
bridge0
connection:# nmcli connection up bridge0
On the RHEL router in network B:
Create a bridge interface named
bridge0
:# nmcli connection add type bridge con-name bridge0 ifname bridge0
Configure the IP settings of the bridge:
# nmcli connection modify bridge0 ipv4.addresses '192.0.2.2/24' # nmcli connection modify bridge0 ipv4.method manual
Add a new connection profile for the interface that is connected to local network to the bridge:
# nmcli connection add type ethernet slave-type bridge con-name bridge0-port1 ifname enp1s0 master bridge0
Add a new connection profile for the GRETAP tunnel interface to the bridge:
# nmcli connection add type ip-tunnel ip-tunnel.mode gretap slave-type bridge con-name bridge0-port2 ifname gretap1 remote 203.0.113.10 local 198.51.100.5 master bridge0
The
remote
andlocal
parameters set the public IP addresses of the remote and the local routers.Optional: Disable the Spanning Tree Protocol (STP) if you do not need it:
# nmcli connection modify bridge0 bridge.stp no
Configure that activating the
bridge0
connection automatically activates the ports of the bridge:# nmcli connection modify bridge0 connection.autoconnect-slaves 1
Active the
bridge0
connection:# nmcli connection up bridge0
Verification
On both routers, verify that the
enp1s0
andgretap1
connections are connected and that theCONNECTION
column displays the connection name of the port:# nmcli device nmcli device DEVICE TYPE STATE CONNECTION ... bridge0 bridge connected bridge0 enp1s0 ethernet connected bridge0-port1 gretap1 iptunnel connected bridge0-port2
From each RHEL router, ping the IP address of the internal interface of the other router:
On Router A, ping
192.0.2.2
:# ping 192.0.2.2
On Router B, ping
192.0.2.1
:# ping 192.0.2.1
Chapter 9. Using a VXLAN to create a virtual layer-2 domain for VMs
A virtual extensible LAN (VXLAN) is a networking protocol that tunnels layer-2 traffic over an IP network using the UDP protocol. For example, certain virtual machines (VMs), that are running on different hosts can communicate over a VXLAN tunnel. The hosts can be in different subnets or even in different data centers around the world. From the perspective of the VMs, other VMs in the same VXLAN are within the same layer-2 domain:
In this example, RHEL-host-A and RHEL-host-B use a bridge, br0
, to connect the virtual network of a VM on each host with a VXLAN named vxlan10
. Due to this configuration, the VXLAN is invisible to the VMs, and the VMs do not require any special configuration. If you later connect more VMs to the same virtual network, the VMs are automatically members of the same virtual layer-2 domain.
Just as normal layer-2 traffic, data in a VXLAN is not encrypted. For security reasons, use a VXLAN over a VPN or other types of encrypted connections.
9.1. Benefits of VXLANs
A virtual extensible LAN (VXLAN) provides the following major benefits:
- VXLANs use a 24-bit ID. Therefore, you can create up to 16,777,216 isolated networks. For example, a virtual LAN (VLAN), supports only 4,096 isolated networks.
- VXLANs use the IP protocol. This enables you to route the traffic and virtually run systems in different networks and locations within the same layer-2 domain.
- Unlike most tunnel protocols, a VXLAN is not only a point-to-point network. A VXLAN can learn the IP addresses of the other endpoints either dynamically or use statically-configured forwarding entries.
- Certain network cards support UDP tunnel-related offload features.
Additional resources
-
/usr/share/doc/kernel-doc-<kernel_version>/Documentation/networking/vxlan.rst
provided by thekernel-doc
package
9.2. Configuring the Ethernet interface on the hosts
To connect a RHEL VM host to the Ethernet, create a network connection profile, configure the IP settings, and activate the profile.
Run this procedure on both RHEL hosts, and adjust the IP address configuration accordingly.
Prerequisites
- The host is connected to the Ethernet.
Procedure
Add a new Ethernet connection profile to NetworkManager:
# nmcli connection add con-name Example ifname enp1s0 type ethernet
Configure the IPv4 settings:
# nmcli connection modify Example ipv4.addresses 198.51.100.2/24 ipv4.method manual ipv4.gateway 198.51.100.254 ipv4.dns 198.51.100.200 ipv4.dns-search example.com
Skip this step if the network uses DHCP.
Activate the
Example
connection:# nmcli connection up Example
Verification
Display the status of the devices and connections:
# nmcli device status DEVICE TYPE STATE CONNECTION enp1s0 ethernet connected Example
Ping a host in a remote network to verify the IP settings:
# ping RHEL-host-B.example.com
Note that you cannot ping the other VM host before you have configured the network on that host as well.
Additional resources
-
nm-settings(5)
man page on your system
9.3. Creating a network bridge with a VXLAN attached
To make a virtual extensible LAN (VXLAN) invisible to virtual machines (VMs), create a bridge on a host, and attach the VXLAN to the bridge. Use NetworkManager to create both the bridge and the VXLAN. You do not add any traffic access point (TAP) devices of the VMs, typically named vnet*
on the host, to the bridge. The libvirtd
service adds them dynamically when the VMs start.
Run this procedure on both RHEL hosts, and adjust the IP addresses accordingly.
Procedure
Create the bridge
br0
:# nmcli connection add type bridge con-name br0 ifname br0 ipv4.method disabled ipv6.method disabled
This command sets no IPv4 and IPv6 addresses on the bridge device, because this bridge works on layer 2.
Create the VXLAN interface and attach it to
br0
:# nmcli connection add type vxlan slave-type bridge con-name br0-vxlan10 ifname vxlan10 id 10 local 198.51.100.2 remote 203.0.113.1 master br0
This command uses the following settings:
-
id 10
: Sets the VXLAN identifier. -
local 198.51.100.2
: Sets the source IP address of outgoing packets. -
remote 203.0.113.1
: Sets the unicast or multicast IP address to use in outgoing packets when the destination link layer address is not known in the VXLAN device forwarding database. -
master br0
: Sets this VXLAN connection to be created as a port in thebr0
connection. -
ipv4.method disabled
andipv6.method disabled
: Disables IPv4 and IPv6 on the bridge.
By default, NetworkManager uses
8472
as the destination port. If the destination port is different, additionally, pass thedestination-port <port_number>
option to the command.-
Activate the
br0
connection profile:# nmcli connection up br0
Open port
8472
for incoming UDP connections in the local firewall:# firewall-cmd --permanent --add-port=8472/udp # firewall-cmd --reload
Verification
Display the forwarding table:
# bridge fdb show dev vxlan10 2a:53:bd:d5:b3:0a master br0 permanent 00:00:00:00:00:00 dst 203.0.113.1 self permanent ...
Additional resources
-
nm-settings(5)
man page on your system
9.4. Creating a virtual network in libvirt with an existing bridge
To enable virtual machines (VM) to use the br0
bridge with the attached virtual extensible LAN (VXLAN), first add a virtual network to the libvirtd
service that uses this bridge.
Prerequisites
-
You installed the
libvirt
package. -
You started and enabled the
libvirtd
service. -
You configured the
br0
device with the VXLAN on RHEL.
Procedure
Create the
~/vxlan10-bridge.xml
file with the following content:<network> <name>vxlan10-bridge</name> <forward mode="bridge" /> <bridge name="br0" /> </network>
Use the
~/vxlan10-bridge.xml
file to create a new virtual network inlibvirt
:# virsh net-define ~/vxlan10-bridge.xml
Remove the
~/vxlan10-bridge.xml
file:# rm ~/vxlan10-bridge.xml
Start the
vxlan10-bridge
virtual network:# virsh net-start vxlan10-bridge
Configure the
vxlan10-bridge
virtual network to start automatically when thelibvirtd
service starts:# virsh net-autostart vxlan10-bridge
Verification
Display the list of virtual networks:
# virsh net-list Name State Autostart Persistent ---------------------------------------------------- vxlan10-bridge active yes yes ...
Additional resources
-
virsh(1)
man page on your system
9.5. Configuring virtual machines to use VXLAN
To configure a VM to use a bridge device with an attached virtual extensible LAN (VXLAN) on the host, create a new VM that uses the vxlan10-bridge
virtual network or update the settings of existing VMs to use this network.
Perform this procedure on the RHEL hosts.
Prerequisites
-
You configured the
vxlan10-bridge
virtual network inlibvirtd
.
Procedure
To create a new VM and configure it to use the
vxlan10-bridge
network, pass the--network network:vxlan10-bridge
option to thevirt-install
command when you create the VM:# virt-install ... --network network:vxlan10-bridge
To change the network settings of an existing VM:
Connect the VM’s network interface to the
vxlan10-bridge
virtual network:# virt-xml VM_name --edit --network network=vxlan10-bridge
Shut down the VM, and start it again:
# virsh shutdown VM_name # virsh start VM_name
Verification
Display the virtual network interfaces of the VM on the host:
# virsh domiflist VM_name Interface Type Source Model MAC ------------------------------------------------------------------- vnet1 bridge vxlan10-bridge virtio 52:54:00:c5:98:1c
Display the interfaces attached to the
vxlan10-bridge
bridge:# ip link show master vxlan10-bridge 18: vxlan10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UNKNOWN mode DEFAULT group default qlen 1000 link/ether 2a:53:bd:d5:b3:0a brd ff:ff:ff:ff:ff:ff 19: vnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UNKNOWN mode DEFAULT group default qlen 1000 link/ether 52:54:00:c5:98:1c brd ff:ff:ff:ff:ff:ff
Note that the
libvirtd
service dynamically updates the bridge’s configuration. When you start a VM which uses thevxlan10-bridge
network, the correspondingvnet*
device on the host appears as a port of the bridge.Use address resolution protocol (ARP) requests to verify whether VMs are in the same VXLAN:
- Start two or more VMs in the same VXLAN.
Send an ARP request from one VM to the other one:
# arping -c 1 192.0.2.2 ARPING 192.0.2.2 from 192.0.2.1 enp1s0 Unicast reply from 192.0.2.2 [52:54:00:c5:98:1c] 1.450ms Sent 1 probe(s) (0 broadcast(s)) Received 1 response(s) (0 request(s), 0 broadcast(s))
If the command shows a reply, the VM is in the same layer-2 domain and, in this case in the same VXLAN.
Install the
iputils
package to use thearping
utility.
Additional resources
-
virt-install(1)
andvirt-xml(1)
man pages on your system -
virsh(1)
andarping(8)
man pages on your system
Chapter 10. Managing wifi connections
RHEL provides multiple utilities and applications to configure and connect to wifi networks, for example:
-
Use the
nmcli
utility to configure connections by using the command line. -
Use the
nmtui
application to configure connections in a text-based user interface. - Use the GNOME system menu to quickly connect to wifi networks that do not require any configuration.
-
Use the
GNOME Settings
application to configure connections by using the GNOME application. -
Use the
nm-connection-editor
application to configure connections in a graphical user interface. -
Use the
network
RHEL system role to automate the configuration of connections on one or multiple hosts.
10.1. Supported wifi security types
Depending on the security type a wifi network supports, you can transmitted data more or less securely.
Do not connect to wifi networks that do not use encryption or which support only the insecure WEP or WPA standards.
RHEL 8 supports the following wifi security types:
-
None
: Encryption is disabled, and data is transferred in plain text over the network. -
Enhanced Open
: With opportunistic wireless encryption (OWE), devices negotiate unique pairwise master keys (PMK) to encrypt connections in wireless networks without authentication. -
WEP 40/128-bit Key (Hex or ASCII)
: The Wired Equivalent Privacy (WEP) protocol in this mode uses pre-shared keys only in hex or ASCII format. WEP is deprecated and will be removed in RHEL 9.1. -
WEP 128-bit Passphrase
. The WEP protocol in this mode uses an MD5 hash of the passphrase to derive a WEP key. WEP is deprecated and will be removed in RHEL 9.1. -
Dynamic WEP (802.1x)
: A combination of 802.1X and EAP that uses the WEP protocol with dynamic keys. WEP is deprecated and will be removed in RHEL 9.1. -
LEAP
: The Lightweight Extensible Authentication Protocol, which was developed by Cisco, is a proprietary version of the extensible authentication protocol (EAP). -
WPA & WPA2 Personal
: In personal mode, the Wi-Fi Protected Access (WPA) and Wi-Fi Protected Access 2 (WPA2) authentication methods use a pre-shared key. -
WPA & WPA2 Enterprise
: In enterprise mode, WPA and WPA2 use the EAP framework and authenticate users to a remote authentication dial-in user service (RADIUS) server. -
WPA3 Personal
: Wi-Fi Protected Access 3 (WPA3) Personal uses simultaneous authentication of equals (SAE) instead of pre-shared keys (PSK) to prevent dictionary attacks. WPA3 uses perfect forward secrecy (PFS).
10.2. Connecting to a wifi network by using nmcli
You can use the nmcli
utility to connect to a wifi network. When you attempt to connect to a network for the first time, the utility automatically creates a NetworkManager connection profile for it. If the network requires additional settings, such as static IP addresses, you can then modify the profile after it has been automatically created.
Prerequisites
- A wifi device is installed on the host.
- The wifi device is enabled, if it has a hardware switch.
Procedure
If the wifi radio has been disabled in NetworkManager, enable this feature:
# nmcli radio wifi on
Optional: Display the available wifi networks:
# nmcli device wifi list IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY 00:53:00:2F:3B:08 Office Infra 44 270 Mbit/s 57 ▂▄▆_ WPA2 WPA3 00:53:00:15:03:BF -- Infra 1 130 Mbit/s 48 ▂▄__ WPA2 WPA3
The service set identifier (
SSID
) column contains the names of the networks. If the column shows--
, the access point of this network does not broadcast an SSID.Connect to the wifi network:
# nmcli device wifi connect Office --ask Password: wifi-password
If you prefer to set the password in the command instead of entering it interactively, use the
password <wifi_password>
option in the command instead of--ask
:# nmcli device wifi connect Office <wifi_password>
Note that, if the network requires static IP addresses, NetworkManager fails to activate the connection at this point. You can configure the IP addresses in later steps.
If the network requires static IP addresses:
Configure the IPv4 address settings, for example:
# nmcli connection modify Office ipv4.method manual ipv4.addresses 192.0.2.1/24 ipv4.gateway 192.0.2.254 ipv4.dns 192.0.2.200 ipv4.dns-search example.com
Configure the IPv6 address settings, for example:
# nmcli connection modify Office ipv6.method manual ipv6.addresses 2001:db8:1::1/64 ipv6.gateway 2001:db8:1::fffe ipv6.dns 2001:db8:1::ffbb ipv6.dns-search example.com
Re-activate the connection:
# nmcli connection up Office
Verification
Display the active connections:
# nmcli connection show --active NAME ID TYPE DEVICE Office 2501eb7e-7b16-4dc6-97ef-7cc460139a58 wifi wlp0s20f3
If the output lists the wifi connection you have created, the connection is active.
Ping a hostname or IP address:
# *ping -c 3 example.com
Additional resources
-
nm-settings-nmcli(5)
man page on your system
10.4. Connecting to a wifi network by using the GNOME settings application
You can use the GNOME settings
application, also named gnome-control-center
, to connect to a wifi network and configure the connection. When you connect to the network for the first time, GNOME creates a NetworkManager connection profile for it.
In GNOME settings
, you can configure wifi connections for all wifi network security types that RHEL supports.
Prerequisites
- A wifi device is installed on the host.
- The wifi device is enabled, if it has a hardware switch.
Procedure
-
Press the Super key, type
Wi-Fi
, and press Enter. - Click on the name of the wifi network you want to connect to.
-
Enter the password for the network, and click
Connect
. If the network requires additional settings, such as static IP addresses or a security type other than WPA2 Personal:
- Click the gear icon next to the network’s name.
Optional: Configure the network profile on the
Details
tab to not automatically connect.If you deactivate this feature, you must always manually connect to the network, for example, by using
GNOME settings
or the GNOME system menu.-
Configure IPv4 settings on the
IPv4
tab, and IPv6 settings on theIPv6
tab. On the
Security
tab, select the authentication of the network, such asWPA3 Personal
, and enter the password.Depending on the selected security, the application shows additional fields. Fill them accordingly. For details, ask the administrator of the wifi network.
-
Click
Apply
.
Verification
Open the system menu on the right side of the top bar, and verify that the wifi network is connected:
If the network appears in the list, it is connected.
Ping a hostname or IP address:
# ping -c 3 example.com
10.5. Configuring a wifi connection by using nmtui
The nmtui
application provides a text-based user interface for NetworkManager. You can use nmtui
to connect to a wifi network.
In nmtui
:
- Navigate by using the cursor keys.
- Press a button by selecting it and hitting Enter.
- Select and clear checkboxes by using Space.
Procedure
If you do not know the network device name you want to use in the connection, display the available devices:
# nmcli device status DEVICE TYPE STATE CONNECTION wlp2s0 wifi unavailable -- ...
Start
nmtui
:# nmtui
-
Select
Edit a connection
, and press Enter. -
Press the
Add
button. -
Select
Wi-Fi
from the list of network types, and press Enter. Optional: Enter a name for the NetworkManager profile to be created.
On hosts with multiple profiles, a meaningful name makes it easier to identify the purpose of a profile.
-
Enter the network device name into the
Device
field. -
Enter the name of the Wi-Fi network, the Service Set Identifier (SSID), into the
SSID
field. -
Leave the
Mode
field set to its default,Client
. Select the
Security
field, press Enter, and set the authentication type of the network from the list.Depending on the authentication type you have selected,
nmtui
displays different fields.- Fill the authentication type-related fields.
If the Wi-Fi network requires static IP addresses:
-
Press the
Automatic
button next to the protocol, and selectManual
from the displayed list. -
Press the
Show
button next to the protocol you want to configure to display additional fields, and fill them.
-
Press the
Press the
OK
button to create and automatically activate the new connection.-
Press the
Back
button to return to the main menu. -
Select
Quit
, and press Enter to close thenmtui
application.
Verification
Display the active connections:
# nmcli connection show --active NAME ID TYPE DEVICE Office 2501eb7e-7b16-4dc6-97ef-7cc460139a58 wifi wlp0s20f3
If the output lists the wifi connection you have created, the connection is active.
Ping a hostname or IP address:
# ping -c 3 example.com
10.6. Configuring a wifi connection by using nm-connection-editor
You can use the nm-connection-editor
application to create a connection profile for a wireless network. In this application you can configure all wifi network authentication types that RHEL supports.
By default, NetworkManager enables the auto-connect feature for connection profiles and automatically connects to a saved network if it is available.
Prerequisites
- A wifi device is installed on the host.
- The wifi device is enabled, if it has a hardware switch.
Procedure
Open a terminal and enter:
# nm-connection-editor
- Click the button to add a new connection.
-
Select the
Wi-Fi
connection type, and click . - Optional: Set a name for the connection profile.
Optional: Configure the network profile on the
General
tab to not automatically connect.If you deactivate this feature, you must always manually connect to the network, for example, by using
GNOME settings
or the GNOME system menu.-
On the
Wi-Fi
tab, enter the service set identifier (SSID) in theSSID
field. On the
Wi-Fi Security
tab, select the authentication type for the network, such asWPA3 Personal
, and enter the password.Depending on the selected security, the application shows additional fields. Fill them accordingly. For details, ask the administrator of the wifi network.
-
Configure IPv4 settings on the
IPv4
tab, and IPv6 settings on theIPv6
tab. -
Click
Save
. -
Close the
Network Connections
window.
Verification
Open the system menu on the right side of the top bar, and verify that the wifi network is connected:
If the network appears in the list, it is connected.
Ping a hostname or IP address:
# ping -c 3 example.com
10.7. Configuring a wifi connection with 802.1X network authentication by using the network
RHEL system role
Network Access Control (NAC) protects a network from unauthorized clients. You can specify the details that are required for the authentication in NetworkManager connection profiles to enable clients to access the network. By using Ansible and the network
RHEL system role, you can automate this process and remotely configure connection profiles on the hosts defined in a playbook.
You can use an Ansible playbook to copy a private key, a certificate, and the CA certificate to the client, and then use the network
RHEL system role to configure a connection profile with 802.1X network authentication.
Prerequisites
- You have prepared the control node and the managed nodes
- You are logged in to the control node as a user who can run playbooks on the managed nodes.
-
The account you use to connect to the managed nodes has
sudo
permissions on them. - The network supports 802.1X network authentication.
-
You installed the
wpa_supplicant
package on the managed node. - DHCP is available in the network of the managed node.
The following files required for TLS authentication exist on the control node:
-
The client key is stored in the
/srv/data/client.key
file. -
The client certificate is stored in the
/srv/data/client.crt
file. -
The CA certificate is stored in the
/srv/data/ca.crt
file.
-
The client key is stored in the
Procedure
Store your sensitive variables in an encrypted file:
Create the vault:
$ ansible-vault create vault.yml New Vault password: <vault_password> Confirm New Vault password: <vault_password>
After the
ansible-vault create
command opens an editor, enter the sensitive data in the<key>: <value>
format:pwd: <password>
- Save the changes, and close the editor. Ansible encrypts the data in the vault.
Create a playbook file, for example
~/playbook.yml
, with the following content:--- - name: Configure a wifi connection with 802.1X authentication hosts: managed-node-01.example.com tasks: - name: Copy client key for 802.1X authentication ansible.builtin.copy: src: "/srv/data/client.key" dest: "/etc/pki/tls/private/client.key" mode: 0400 - name: Copy client certificate for 802.1X authentication ansible.builtin.copy: src: "/srv/data/client.crt" dest: "/etc/pki/tls/certs/client.crt" - name: Copy CA certificate for 802.1X authentication ansible.builtin.copy: src: "/srv/data/ca.crt" dest: "/etc/pki/ca-trust/source/anchors/ca.crt" - name: Wifi connection profile with dynamic IP address settings and 802.1X ansible.builtin.import_role: name: rhel-system-roles.network vars: network_connections: - name: Wifi connection profile with dynamic IP address settings and 802.1X interface_name: wlp1s0 state: up type: wireless autoconnect: yes ip: dhcp4: true auto6: true wireless: ssid: "Example-wifi" key_mgmt: "wpa-eap" ieee802_1x: identity: <user_name> eap: tls private_key: "/etc/pki/tls/client.key" private_key_password: "{{ pwd }}" private_key_password_flags: none client_cert: "/etc/pki/tls/client.pem" ca_cert: "/etc/pki/tls/cacert.pem" domain_suffix_match: "example.com"
The settings specified in the example playbook include the following:
ieee802_1x
- This variable contains the 802.1X-related settings.
eap: tls
-
Configures the profile to use the certificate-based
TLS
authentication method for the Extensible Authentication Protocol (EAP).
For details about all variables used in the playbook, see the
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file on the control node.Validate the playbook syntax:
$ ansible-playbook --ask-vault-pass --syntax-check ~/playbook.yml
Note that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook --ask-vault-pass ~/playbook.yml
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
/usr/share/doc/rhel-system-roles/network/
directory
10.8. Configuring a wifi connection with 802.1X network authentication in an existing profile by using nmcli
Using the nmcli
utility, you can configure the client to authenticate itself to the network. For example, you can configure Protected Extensible Authentication Protocol (PEAP) authentication with the Microsoft Challenge-Handshake Authentication Protocol version 2 (MSCHAPv2) in an existing NetworkManager wifi connection profile named wlp1s0
.
Prerequisites
- The network must have 802.1X network authentication.
- The wifi connection profile exists in NetworkManager and has a valid IP configuration.
-
If the client is required to verify the certificate of the authenticator, the Certificate Authority (CA) certificate must be stored in the
/etc/pki/ca-trust/source/anchors/
directory. -
The
wpa_supplicant
package is installed.
Procedure
Set the wifi security mode to
wpa-eap
, the Extensible Authentication Protocol (EAP) topeap
, the inner authentication protocol tomschapv2
, and the user name:# nmcli connection modify wlp1s0 wireless-security.key-mgmt wpa-eap 802-1x.eap peap 802-1x.phase2-auth mschapv2 802-1x.identity user_name
Note that you must set the
wireless-security.key-mgmt
,802-1x.eap
,802-1x.phase2-auth
, and802-1x.identity
parameters in a single command.Optional: Store the password in the configuration:
# nmcli connection modify wlp1s0 802-1x.password password
ImportantBy default, NetworkManager stores the password in plain text in the
/etc/sysconfig/network-scripts/keys-connection_name
file, which is readable only by theroot
user. However, plain text passwords in a configuration file can be a security risk.To increase the security, set the
802-1x.password-flags
parameter to0x1
. With this setting, on servers with the GNOME desktop environment or thenm-applet
running, NetworkManager retrieves the password from these services. In other cases, NetworkManager prompts for the password.If the client needs to verify the certificate of the authenticator, set the
802-1x.ca-cert
parameter in the connection profile to the path of the CA certificate:# nmcli connection modify wlp1s0 802-1x.ca-cert /etc/pki/ca-trust/source/anchors/ca.crt
NoteFor security reasons, clients should validate the certiciate of the authenticator.
Activate the connection profile:
# nmcli connection up wlp1s0
Verification
- Access resources on the network that require network authentication.
Additional resources
- Managing wifi connections
-
nm-settings(5)
andnmcli(1)
man pages on your system
10.9. Manually setting the wireless regulatory domain
On RHEL, a udev
rule executes the setregdomain
utility to set the wireless regulatory domain. The utility then provides this information to the kernel.
By default, setregdomain
attempts to determine the country code automatically. If this fails, the wireless regulatory domain setting might be wrong. To work around this problem, you can manually set the country code.
Manually setting the regulatory domain disables the automatic detection. Therefore, if you later use the computer in a different country, the previously configured setting might no longer be correct. In this case, remove the /etc/sysconfig/regdomain
file to switch back to automatic detection or use this procedure to manually update the regulatory domain setting again.
Procedure
Optional: Display the current regulatory domain settings:
# iw reg get global country US: DFS-FCC ...
Create the
/etc/sysconfig/regdomain
file with the following content:COUNTRY=<country_code>
Set the
COUNTRY
variable to an ISO 3166-1 alpha2 country code, such asDE
for Germany orUS
for the United States of America.Set the regulatory domain:
# setregdomain
Verification
Display the regulatory domain settings:
# iw reg get global country DE: DFS-ETSI ...
Additional resources
-
iw(8)
,setregdomain(1)
, andregulatory.bin(5)
man pages on your system - ISO 3166 Country Codes
Chapter 11. Configuring RHEL as a WPA2 or WPA3 Personal access point
On a host with a wifi device, you can use NetworkManager to configure this host as an access point. Wi-Fi Protected Access 2 (WPA2) and Wi-Fi Protected Access 3 (WPA3) Personal provide secure authentication methods, and wireless clients can use a pre-shared key (PSK) to connect to the access point and use services on the RHEL host and in the network.
When you configure an access point, NetworkManager automatically:
-
Configures the
dnsmasq
service to provide DHCP and DNS services for clients - Enables IP forwarding
-
Adds
nftables
firewall rules to masquerade traffic from the wifi device and configures IP forwarding
Prerequisites
- The wifi device supports running in access point mode.
- The wifi device is not in use.
- The host has internet access.
Procedure
List the wifi devices to identify the one that should provide the access point:
# nmcli device status | grep wifi wlp0s20f3 wifi disconnected --
Verify that the device supports the access point mode:
# nmcli -f WIFI-PROPERTIES.AP device show wlp0s20f3 WIFI-PROPERTIES.AP: yes
To use a wifi device as an access point, the device must support this feature.
Install the
dnsmasq
andNetworkManager-wifi
packages:# yum install dnsmasq NetworkManager-wifi
NetworkManager uses the
dnsmasq
service to provide DHCP and DNS services to clients of the access point.Create the initial access point configuration:
# nmcli device wifi hotspot ifname wlp0s20f3 con-name Example-Hotspot ssid Example-Hotspot password "password"
This command creates a connection profile for an access point on the
wlp0s20f3
device that provides WPA2 and WPA3 Personal authentication. The name of the wireless network, the Service Set Identifier (SSID), isExample-Hotspot
and uses the pre-shared keypassword
.Optional: Configure the access point to support only WPA3:
# nmcli connection modify Example-Hotspot 802-11-wireless-security.key-mgmt sae
By default, NetworkManager uses the IP address
10.42.0.1
for the wifi device and assigns IP addresses from the remaining10.42.0.0/24
subnet to clients. To configure a different subnet and IP address, enter:# nmcli connection modify Example-Hotspot ipv4.addresses 192.0.2.254/24
The IP address you set, in this case
192.0.2.254
, is the one that NetworkManager assigns to the wifi device. Clients will use this IP address as default gateway and DNS server.Activate the connection profile:
# nmcli connection up Example-Hotspot
Verification
On the server:
Verify that NetworkManager started the
dnsmasq
service and that the service listens on port 67 (DHCP) and 53 (DNS):# ss -tulpn | egrep ":53|:67" udp UNCONN 0 0 10.42.0.1:53 0.0.0.0:* users:(("dnsmasq",pid=55905,fd=6)) udp UNCONN 0 0 0.0.0.0:67 0.0.0.0:* users:(("dnsmasq",pid=55905,fd=4)) tcp LISTEN 0 32 10.42.0.1:53 0.0.0.0:* users:(("dnsmasq",pid=55905,fd=7))
Display the
nftables
rule set to ensure that NetworkManager enabled forwarding and masquerading for traffic from the10.42.0.0/24
subnet:# nft list ruleset table ip nm-shared-wlp0s20f3 { chain nat_postrouting { type nat hook postrouting priority srcnat; policy accept; ip saddr 10.42.0.0/24 ip daddr != 10.42.0.0/24 masquerade } chain filter_forward { type filter hook forward priority filter; policy accept; ip daddr 10.42.0.0/24 oifname "wlp0s20f3" ct state { established, related } accept ip saddr 10.42.0.0/24 iifname "wlp0s20f3" accept iifname "wlp0s20f3" oifname "wlp0s20f3" accept iifname "wlp0s20f3" reject oifname "wlp0s20f3" reject } }
On a client with a wifi adapter:
Display the list of available networks:
# nmcli device wifi IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY 00:53:00:88:29:04 Example-Hotspot Infra 11 130 Mbit/s 62 ▂▄▆_ WPA3 ...
-
Connect to the
Example-Hotspot
wireless network. See Managing Wi-Fi connections. Ping a host on the remote network or the internet to verify that the connection works:
# ping -c 3 www.redhat.com
Additional resources
-
nm-settings(5)
man page on your system
Chapter 12. Using MACsec to encrypt layer-2 traffic in the same physical network
You can use MACsec to secure the communication between two devices (point-to-point). For example, your branch office is connected over a Metro-Ethernet connection with the central office, you can configure MACsec on the two hosts that connect the offices to increase the security.
12.1. How MACsec increases security
Media Access Control security (MACsec) is a layer-2 protocol that secures different traffic types over the Ethernet links, including:
- Dynamic host configuration protocol (DHCP)
- address resolution protocol (ARP)
- IPv4 and IPv6 traffic
- Any traffic over IP such as TCP or UDP
MACsec encrypts and authenticates all traffic in LANs, by default with the GCM-AES-128 algorithm, and uses a pre-shared key to establish the connection between the participant hosts. To change the pre-shared key, you must update the NM configuration on all network hosts that use MACsec.
A MACsec connection uses an Ethernet device, such as an Ethernet network card, VLAN, or tunnel device, as a parent. You can either set an IP configuration only on the MACsec device to communicate with other hosts only by using the encrypted connection, or you can also set an IP configuration on the parent device. In the latter case, you can use the parent device to communicate with other hosts using an unencrypted connection and the MACsec device for encrypted connections.
MACsec does not require any special hardware. For example, you can use any switch, except if you want to encrypt traffic only between a host and a switch. In this scenario, the switch must also support MACsec.
In other words, you can configure MACsec for two common scenarios:
- Host-to-host
- Host-to-switch and switch-to-other-hosts
You can use MACsec only between hosts being in the same physical or virtual LAN.
Additional resources
12.2. Configuring a MACsec connection by using nmcli
You can use the nmcli
utility to configure Ethernet interfaces to use MACsec. For example, you can create a MACsec connection between two hosts that are connected over Ethernet.
Procedure
On the first host on which you configure MACsec:
Create the connectivity association key (CAK) and connectivity-association key name (CKN) for the pre-shared key:
Create a 16-byte hexadecimal CAK:
# dd if=/dev/urandom count=16 bs=1 2> /dev/null | hexdump -e '1/2 "%04x"' 50b71a8ef0bd5751ea76de6d6c98c03a
Create a 32-byte hexadecimal CKN:
# dd if=/dev/urandom count=32 bs=1 2> /dev/null | hexdump -e '1/2 "%04x"' f2b4297d39da7330910a74abc0449feb45b5c0b9fc23df1430e1898fcf1c4550
- On both hosts you want to connect over a MACsec connection:
Create the MACsec connection:
# nmcli connection add type macsec con-name macsec0 ifname macsec0 connection.autoconnect yes macsec.parent enp1s0 macsec.mode psk macsec.mka-cak 50b71a8ef0bd5751ea76de6d6c98c03a macsec.mka-ckn f2b4297d39da7330910a74abc0449feb45b5c0b9fc23df1430e1898fcf1c4550
Use the CAK and CKN generated in the previous step in the
macsec.mka-cak
andmacsec.mka-ckn
parameters. The values must be the same on every host in the MACsec-protected network.Configure the IP settings on the MACsec connection.
Configure the
IPv4
settings. For example, to set a staticIPv4
address, network mask, default gateway, and DNS server to themacsec0
connection, enter:# nmcli connection modify macsec0 ipv4.method manual ipv4.addresses '192.0.2.1/24' ipv4.gateway '192.0.2.254' ipv4.dns '192.0.2.253'
Configure the
IPv6
settings. For example, to set a staticIPv6
address, network mask, default gateway, and DNS server to themacsec0
connection, enter:# nmcli connection modify macsec0 ipv6.method manual ipv6.addresses '2001:db8:1::1/32' ipv6.gateway '2001:db8:1::fffe' ipv6.dns '2001:db8:1::fffd'
Activate the connection:
# nmcli connection up macsec0
Verification
Verify that the traffic is encrypted:
# tcpdump -nn -i enp1s0
Optional: Display the unencrypted traffic:
# tcpdump -nn -i macsec0
Display MACsec statistics:
# ip macsec show
Display individual counters for each type of protection: integrity-only (encrypt off) and encryption (encrypt on)
# ip -s macsec show
Additional resources
Chapter 13. Getting started with IPVLAN
IPVLAN is a driver for a virtual network device that can be used in container environment to access the host network. IPVLAN exposes a single MAC address to the external network regardless the number of IPVLAN device created inside the host network. This means that a user can have multiple IPVLAN devices in multiple containers and the corresponding switch reads a single MAC address. IPVLAN driver is useful when the local switch imposes constraints on the total number of MAC addresses that it can manage.
13.1. IPVLAN modes
The following modes are available for IPVLAN:
L2 mode
In IPVLAN L2 mode, virtual devices receive and respond to address resolution protocol (ARP) requests. The
netfilter
framework runs only inside the container that owns the virtual device. Nonetfilter
chains are executed in the default namespace on the containerized traffic. Using L2 mode provides good performance, but less control on the network traffic.L3 mode
In L3 mode, virtual devices process only L3 traffic and above. Virtual devices do not respond to ARP request and users must configure the neighbour entries for the IPVLAN IP addresses on the relevant peers manually. The egress traffic of a relevant container is landed on the
netfilter
POSTROUTING and OUTPUT chains in the default namespace while the ingress traffic is threaded in the same way as L2 mode. Using L3 mode provides good control but decreases the network traffic performance.L3S mode
In L3S mode, virtual devices process the same way as in L3 mode, except that both egress and ingress traffics of a relevant container are landed on
netfilter
chain in the default namespace. L3S mode behaves in a similar way to L3 mode but provides greater control of the network.
The IPVLAN virtual device does not receive broadcast and multicast traffic in case of L3 and L3S modes.
13.2. Comparison of IPVLAN and MACVLAN
The following table shows the major differences between MACVLAN and IPVLAN:
MACVLAN | IPVLAN |
---|---|
Uses MAC address for each MACVLAN device. Note that, if a switch reaches the maximum number of MAC addresses it can store in its MAC table, connectivity can be lost. | Uses single MAC address which does not limit the number of IPVLAN devices. |
Netfilter rules for a global namespace cannot affect traffic to or from a MACVLAN device in a child namespace. | It is possible to control traffic to or from a IPVLAN device in L3 mode and L3S mode. |
Both IPVLAN and MACVLAN do not require any level of encapsulation.
13.3. Creating and configuring the IPVLAN device using iproute2
This procedure shows how to set up the IPVLAN device using iproute2
.
Procedure
To create an IPVLAN device, enter the following command:
# ip link add link real_NIC_device name IPVLAN_device type ipvlan mode l2
Note that network interface controller (NIC) is a hardware component which connects a computer to a network.
Example 13.1. Creating an IPVLAN device
# ip link add link enp0s31f6 name my_ipvlan type ipvlan mode l2 # ip link 47: my_ipvlan@enp0s31f6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether e8:6a:6e:8a:a2:44 brd ff:ff:ff:ff:ff:ff
To assign an
IPv4
orIPv6
address to the interface, enter the following command:# ip addr add dev IPVLAN_device IP_address/subnet_mask_prefix
In case of configuring an IPVLAN device in L3 mode or L3S mode, make the following setups:
Configure the neighbor setup for the remote peer on the remote host:
# ip neigh add dev peer_device IPVLAN_device_IP_address lladdr MAC_address
where MAC_address is the MAC address of the real NIC on which an IPVLAN device is based on.
Configure an IPVLAN device for L3 mode with the following command:
# ip route add dev <real_NIC_device> <peer_IP_address/32>
For L3S mode:
# ip route add dev real_NIC_device peer_IP_address/32
where IP-address represents the address of the remote peer.
To set an IPVLAN device active, enter the following command:
# ip link set dev IPVLAN_device up
To check if the IPVLAN device is active, execute the following command on the remote host:
# ping IP_address
where the IP_address uses the IP address of the IPVLAN device.
Chapter 14. Configuring NetworkManager to ignore certain devices
By default, NetworkManager manages all devices except the loopback (lo
) device. However, you can configure NetworkManager as unmanaged
to ignore certain devices. With this setting, you can manually manage these devices, for example, by using a script.
14.1. Permanently configuring a device as unmanaged in NetworkManager
You can permanently configure devices as unmanaged
based on several criteria, such as the interface name, MAC address, or device type.
Procedure
Optional: Display the list of devices to identify the device or MAC address you want to set as
unmanaged
:# ip link show ... 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:74:79:56 brd ff:ff:ff:ff:ff:ff ...
Create the
/etc/NetworkManager/conf.d/99-unmanaged-devices.conf
file with the following content:To configure a specific interface as unmanaged, add:
[keyfile] unmanaged-devices=interface-name:enp1s0
To configure a device with a specific MAC address as unmanaged, add:
[keyfile] unmanaged-devices=mac:52:54:00:74:79:56
To configure all devices of a specific type as unmanaged, add:
[keyfile] unmanaged-devices=type:ethernet
To set multiple devices as unmanaged, separate the entries in the
unmanaged-devices
parameter with a semicolon, for example:[keyfile] unmanaged-devices=interface-name:enp1s0;interface-name:enp7s0
Reload the
NetworkManager
service:# systemctl reload NetworkManager
Verification
Display the list of devices:
# nmcli device status DEVICE TYPE STATE CONNECTION enp1s0 ethernet unmanaged -- ...
The
unmanaged
state next to theenp1s0
device indicates that NetworkManager does not manage this device.
Troubleshooting
If the device is not shown as
unmanaged
, display the NetworkManager configuration:# NetworkManager --print-config ... [keyfile] unmanaged-devices=interface-name:enp1s0 ...
If the output does not match the settings that you configured, ensure that no configuration file with a higher priority overrides your settings. For details about how NetworkManager merges multiple configuration files, see the
NetworkManager.conf(5)
man page on your system.
14.2. Temporarily configuring a device as unmanaged in NetworkManager
You can temporarily configure devices as unmanaged
, for example, for testing purposes.
Procedure
Optional: Display the list of devices to identify the device you want to set as
unmanaged
:# nmcli device status DEVICE TYPE STATE CONNECTION enp1s0 ethernet disconnected -- ...
Set the
enp1s0
device to theunmanaged
state:# nmcli device set enp1s0 managed no
Verification
Display the list of devices:
# nmcli device status DEVICE TYPE STATE CONNECTION enp1s0 ethernet unmanaged -- ...
The
unmanaged
state next to theenp1s0
device indicates that NetworkManager does not manage this device.
Additional resources
-
NetworkManager.conf(5)
man page on your system
Chapter 15. Configuring the loopback interface by using nmcli
By default, NetworkManager does not manage the loopback (lo
) interface. After creating a connection profile for the lo
interface, you can configure this device by using NetworkManager. Some of the examples are as follows:
-
Assign additional IP addresses to the
lo
interface - Define DNS addresses
-
Change the Maximum Transmission Unit (MTU) size of the
lo
interface
Procedure
Create a new connection of type
loopback
:# nmcli connection add con-name example-loopback type loopback
Configure custom connection settings, for example:
To assign an additional IP address to the interface, enter:
# nmcli connection modify example-loopback +ipv4.addresses 192.0.2.1/24
NoteNetworkManager manages the
lo
interface by always assigning the IP addresses127.0.0.1
and::1
that are persistent across the reboots. You can not override127.0.0.1
and::1
. However, you can assign additional IP addresses to the interface.To set a custom Maximum Transmission Unit (MTU), enter:
# nmcli con mod example-loopback loopback.mtu 16384
To set an IP address to your DNS server, enter:
# nmcli connection modify example-loopback ipv4.dns 192.0.2.0
If you set a DNS server in the loopback connection profile, this entry is always available in the
/etc/resolv.conf
file. The DNS server entry remains independent of whether or not the host roams between different networks.
Activate the connection:
# nmcli connection up example-loopback
Verification
Display the settings of the
lo
interface:# ip address show lo 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16384 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet
192.0.2.1/24
brd192.0.2.255
scope global lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft foreverVerify the DNS address:
# cat /etc/resolv.conf ... nameserver
192.0.2.0
...
Chapter 16. Creating a dummy interface
As a Red Hat Enterprise Linux user, you can create and use dummy network interfaces for debugging and testing purposes. A dummy interface provides a device to route packets without actually transmitting them. It enables you to create additional loopback-like devices managed by NetworkManager and makes an inactive SLIP (Serial Line Internet Protocol) address look like a real address for local programs.
16.1. Creating a dummy interface with both an IPv4 and IPv6 address by using nmcli
You can create a dummy interface with various settings, such as IPv4 and IPv6 addresses. After creating the interface, NetworkManager automatically assigns it to the default public
firewalld
zone.
Procedure
Create a dummy interface named
dummy0
with static IPv4 and IPv6 addresses:# nmcli connection add type dummy ifname dummy0 ipv4.method manual ipv4.addresses 192.0.2.1/24 ipv6.method manual ipv6.addresses 2001:db8:2::1/64
NoteTo configure a dummy interface without IPv4 and IPv6 addresses, set both the
ipv4.method
andipv6.method
parameters todisabled
. Otherwise, IP auto-configuration fails, and NetworkManager deactivates the connection and removes the device.
Verification
List the connection profiles:
# nmcli connection show NAME UUID TYPE DEVICE dummy-dummy0 aaf6eb56-73e5-4746-9037-eed42caa8a65 dummy dummy0
Additional resources
-
nm-settings(5)
man page on your system
Chapter 17. Using NetworkManager to disable IPv6 for a specific connection
On a system that uses NetworkManager to manage network interfaces, you can disable the IPv6 protocol if the network only uses IPv4. If you disable IPv6
, NetworkManager automatically sets the corresponding sysctl
values in the Kernel.
If disabling IPv6 using kernel tunables or kernel boot parameters, additional consideration must be given to system configuration. For more information, see the How do I disable or enable the IPv6 protocol in RHEL? article.
17.1. Disabling IPv6 on a connection using nmcli
You can use the nmcli
utility to disable the IPv6
protocol on the command line.
Prerequisites
- The system uses NetworkManager to manage network interfaces.
Procedure
Optional: Display the list of network connections:
# nmcli connection show NAME UUID TYPE DEVICE Example 7a7e0151-9c18-4e6f-89ee-65bb2d64d365 ethernet enp1s0 ...
Set the
ipv6.method
parameter of the connection todisabled
:# nmcli connection modify Example ipv6.method "disabled"
Restart the network connection:
# nmcli connection up Example
Verification
Display the IP settings of the device:
# ip address show enp1s0 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 52:54:00:6b:74:be brd ff:ff:ff:ff:ff:ff inet 192.0.2.1/24 brd 192.10.2.255 scope global noprefixroute enp1s0 valid_lft forever preferred_lft forever
If no
inet6
entry is displayed,IPv6
is disabled on the device.Verify that the
/proc/sys/net/ipv6/conf/enp1s0/disable_ipv6
file now contains the value1
:# cat /proc/sys/net/ipv6/conf/enp1s0/disable_ipv6 1
The value
1
means thatIPv6
is disabled for the device.
Chapter 18. Changing a hostname
The hostname of a system is the name on the system itself. You can set the name when you install RHEL, and you can change it afterwards.
18.1. Changing a hostname by using nmcli
You can use the nmcli
utility to update the system hostname. Note that other utilities might use a different term, such as static or persistent hostname.
Procedure
Optional: Display the current hostname setting:
# nmcli general hostname old-hostname.example.com
Set the new hostname:
# nmcli general hostname new-hostname.example.com
NetworkManager automatically restarts the
systemd-hostnamed
to activate the new name. For the changes to take effect, reboot the host:# reboot
Alternatively, if you know which services use the hostname:
Restart all services that only read the hostname when the service starts:
# systemctl restart <service_name>
- Active shell users must re-login for the changes to take effect.
Verification
Display the hostname:
# nmcli general hostname new-hostname.example.com
18.2. Changing a hostname by using hostnamectl
You can use the hostnamectl
utility to update the hostname. By default, this utility sets the following hostname types:
-
Static hostname: Stored in the
/etc/hostname
file. Typically, services use this name as the hostname. -
Pretty hostname: A descriptive name, such as
Proxy server in data center A
. - Transient hostname: A fall-back value that is typically received from the network configuration.
Procedure
Optional: Display the current hostname setting:
# hostnamectl status --static old-hostname.example.com
Set the new hostname:
# hostnamectl set-hostname new-hostname.example.com
This command sets the static, pretty, and transient hostname to the new value. To set only a specific type, pass the
--static
,--pretty
, or--transient
option to the command.The
hostnamectl
utility automatically restarts thesystemd-hostnamed
to activate the new name. For the changes to take effect, reboot the host:# reboot
Alternatively, if you know which services use the hostname:
Restart all services that only read the hostname when the service starts:
# systemctl restart <service_name>
- Active shell users must re-login for the changes to take effect.
Verification
Display the hostname:
# hostnamectl status --static new-hostname.example.com
Chapter 19. Configuring NetworkManager DHCP settings
NetworkManager provides different configuration options related to DHCP. For example, you can configure NetworkManager to use the build-in DHCP client (default) or an external client, and you can influence DHCP settings of individual profiles.
19.1. Changing the DHCP client of NetworkManager
By default, NetworkManager uses its internal DHCP client. However, if you require a DHCP client with features that the built-in client does not provide, you can alternatively configure NetworkManager to use dhclient
.
Note that RHEL does not provide dhcpcd
and, therefore, NetworkManager can not use this client.
Procedure
Create the
/etc/NetworkManager/conf.d/dhcp-client.conf
file with the following content:[main] dhcp=dhclient
You can set the
dhcp
parameter tointernal
(default) ordhclient
.If you set the
dhcp
parameter todhclient
, install thedhcp-client
package:# yum install dhcp-client
Restart NetworkManager:
# systemctl restart NetworkManager
Note that the restart temporarily interrupts all network connections.
Verification
Search in the
/var/log/messages
log file for an entry similar to the following:Apr 26 09:54:19 server NetworkManager[27748]: <info> [1650959659.8483] dhcp-init: Using DHCP client 'dhclient'
This log entry confirms that NetworkManager uses
dhclient
as DHCP client.
Additional resources
-
NetworkManager.conf(5)
man page on your system
19.2. Configuring the DHCP behavior of a NetworkManager connection
A Dynamic Host Configuration Protocol (DHCP) client requests the dynamic IP address and corresponding configuration information from a DHCP server each time a client connects to the network.
When you configured a connection to retrieve an IP address from a DHCP server, the NetworkManager requests an IP address from a DHCP server. By default, the client waits 45 seconds for this request to be completed. When a DHCP
connection is started, a dhcp client requests an IP address from a DHCP
server.
Prerequisites
- A connection that uses DHCP is configured on the host.
Procedure
Set the
ipv4.dhcp-timeout
andipv6.dhcp-timeout
properties. For example, to set both options to30
seconds, enter:# nmcli connection modify <connection_name> ipv4.dhcp-timeout 30 ipv6.dhcp-timeout 30
Alternatively, set the parameters to
infinity
to configure that NetworkManager does not stop trying to request and renew an IP address until it is successful.Optional: Configure the behavior if NetworkManager does not receive an IPv4 address before the timeout:
# nmcli connection modify <connection_name> ipv4.may-fail <value>
If you set the
ipv4.may-fail
option to:yes
, the status of the connection depends on the IPv6 configuration:- If the IPv6 configuration is enabled and successful, NetworkManager activates the IPv6 connection and no longer tries to activate the IPv4 connection.
- If the IPv6 configuration is disabled or not configured, the connection fails.
no
, the connection is deactivated. In this case:-
If the
autoconnect
property of the connection is enabled, NetworkManager retries to activate the connection as many times as set in theautoconnect-retries
property. The default is4
. - If the connection still cannot acquire a DHCP address, auto-activation fails. Note that after 5 minutes, the auto-connection process starts again to acquire an IP address from the DHCP server.
-
If the
Optional: Configure the behavior if NetworkManager does not receive an IPv6 address before the timeout:
# nmcli connection modify <connection_name> ipv6.may-fail <value>
Additional resources
-
nm-settings(5)
man page on your system
Chapter 20. Running dhclient exit hooks using NetworkManager a dispatcher script
You can use a NetworkManager dispatcher script to execute dhclient
exit hooks.
20.1. The concept of NetworkManager dispatcher scripts
The NetworkManager-dispatcher
service executes user-provided scripts in alphabetical order when network events happen. These scripts are typically shell scripts, but can be any executable script or application. You can use dispatcher scripts, for example, to adjust network-related settings that you cannot manage with NetworkManager.
You can store dispatcher scripts in the following directories:
-
/etc/NetworkManager/dispatcher.d/
: The general location for dispatcher scripts theroot
user can edit. -
/usr/lib/NetworkManager/dispatcher.d/
: For pre-deployed immutable dispatcher scripts.
For security reasons, the NetworkManager-dispatcher
service executes scripts only if the following conditions met:
-
The script is owned by the
root
user. -
The script is only readable and writable by
root
. -
The
setuid
bit is not set on the script.
The NetworkManager-dispatcher
service runs each script with two arguments:
- The interface name of the device the operation happened on.
-
The action, such as
up
, when the interface has been activated.
The Dispatcher scripts
section in the NetworkManager(8)
man page provides an overview of actions and environment variables you can use in scripts.
The NetworkManager-dispatcher
service runs one script at a time, but asynchronously from the main NetworkManager process. Note that, if a script is queued, the service will always run it, even if a later event makes it obsolete. However, the NetworkManager-dispatcher
service runs scripts that are symbolic links referring to files in /etc/NetworkManager/dispatcher.d/no-wait.d/
immediately, without waiting for the termination of previous scripts, and in parallel.
Additional resources
-
NetworkManager(8)
man page on your system
20.2. Creating a NetworkManager dispatcher script that runs dhclient exit hooks
When a DHCP server assigns or updates an IPv4 address, NetworkManager can run a dispatcher script stored in the /etc/dhcp/dhclient-exit-hooks.d/
directory. This dispatcher script can then, for example, run dhclient
exit hooks.
Prerequisites
-
The
dhclient
exit hooks are stored in the/etc/dhcp/dhclient-exit-hooks.d/
directory.
Procedure
Create the
/etc/NetworkManager/dispatcher.d/12-dhclient-down
file with the following content:#!/bin/bash # Run dhclient.exit-hooks.d scripts if [ -n "$DHCP4_DHCP_LEASE_TIME" ] ; then if [ "$2" = "dhcp4-change" ] || [ "$2" = "up" ] ; then if [ -d /etc/dhcp/dhclient-exit-hooks.d ] ; then for f in /etc/dhcp/dhclient-exit-hooks.d/*.sh ; do if [ -x "${f}" ]; then . "${f}" fi done fi fi fi
Set the
root
user as owner of the file:# chown root:root /etc/NetworkManager/dispatcher.d/12-dhclient-down
Set the permissions so that only the root user can execute it:
# chmod 0700 /etc/NetworkManager/dispatcher.d/12-dhclient-down
Restore the SELinux context:
# restorecon /etc/NetworkManager/dispatcher.d/12-dhclient-down
Additional resources
-
NetworkManager(8)
man page on your system
Chapter 21. Manually configuring the /etc/resolv.conf file
By default, NetworkManager dynamically updates the /etc/resolv.conf
file with the DNS settings from active NetworkManager connection profiles. However, you can disable this behavior and manually configure DNS settings in /etc/resolv.conf
.
Alternatively, if you require a specific order of DNS servers in /etc/resolv.conf
, see Configuring the order of DNS servers.
21.1. Disabling DNS processing in the NetworkManager configuration
By default, NetworkManager manages DNS settings in the /etc/resolv.conf
file, and you can configure the order of DNS servers. Alternatively, you can disable DNS processing in NetworkManager if you prefer to manually configure DNS settings in /etc/resolv.conf
.
Procedure
As the root user, create the
/etc/NetworkManager/conf.d/90-dns-none.conf
file with the following content by using a text editor:[main] dns=none
Reload the
NetworkManager
service:# systemctl reload NetworkManager
NoteAfter you reload the service, NetworkManager no longer updates the
/etc/resolv.conf
file. However, the last contents of the file are preserved.-
Optional: Remove the
Generated by NetworkManager
comment from/etc/resolv.conf
to avoid confusion.
Verification
-
Edit the
/etc/resolv.conf
file and manually update the configuration. Reload the
NetworkManager
service:# systemctl reload NetworkManager
Display the
/etc/resolv.conf
file:# cat /etc/resolv.conf
If you successfully disabled DNS processing, NetworkManager did not override the manually configured settings.
Troubleshooting
Display the NetworkManager configuration to ensure that no other configuration file with a higher priority overrode the setting:
# NetworkManager --print-config ... dns=none ...
Additional resources
-
NetworkManager.conf(5)
man page on your system - Configuring the order of DNS servers using NetworkManager
21.2. Replacing /etc/resolv.conf with a symbolic link to manually configure DNS settings
By default, NetworkManager manages DNS settings in the /etc/resolv.conf
file, and you can configure the order of DNS servers. Alternatively, you can disable DNS processing in NetworkManager if you prefer to manually configure DNS settings in /etc/resolv.conf
. For example, NetworkManager does not automatically update the DNS configuration if /etc/resolv.conf
is a symbolic link.
Prerequisites
-
The NetworkManager
rc-manager
configuration option is not set tofile
. To verify, use theNetworkManager --print-config
command.
Procedure
-
Create a file, such as
/etc/resolv.conf.manually-configured
, and add the DNS configuration for your environment to it. Use the same parameters and syntax as in the original/etc/resolv.conf
. Remove the
/etc/resolv.conf
file:# rm /etc/resolv.conf
Create a symbolic link named
/etc/resolv.conf
that refers to/etc/resolv.conf.manually-configured
:# ln -s /etc/resolv.conf.manually-configured /etc/resolv.conf
Additional resources
-
resolv.conf(5)
andNetworkManager.conf(5)
man pages on your system - Configuring the order of DNS servers using NetworkManager
Chapter 22. Configuring the order of DNS servers
Most applications use the getaddrinfo()
function of the glibc
library to resolve DNS requests. By default, glibc
sends all DNS requests to the first DNS server specified in the /etc/resolv.conf
file. If this server does not reply, RHEL uses the next server in this file. NetworkManager enables you to influence the order of DNS servers in etc/resolv.conf
.
22.1. How NetworkManager orders DNS servers in /etc/resolv.conf
NetworkManager orders DNS servers in the /etc/resolv.conf
file based on the following rules:
- If only one connection profile exists, NetworkManager uses the order of IPv4 and IPv6 DNS server specified in that connection.
If multiple connection profiles are activated, NetworkManager orders DNS servers based on a DNS priority value. If you set DNS priorities, the behavior of NetworkManager depends on the value set in the
dns
parameter. You can set this parameter in the[main]
section in the/etc/NetworkManager/NetworkManager.conf
file:dns=default
or if thedns
parameter is not set:NetworkManager orders the DNS servers from different connections based on the
ipv4.dns-priority
andipv6.dns-priority
parameter in each connection.If you set no value or you set
ipv4.dns-priority
andipv6.dns-priority
to0
, NetworkManager uses the global default value. See Default values of DNS priority parameters.dns=dnsmasq
ordns=systemd-resolved
:When you use one of these settings, NetworkManager sets either
127.0.0.1
fordnsmasq
or127.0.0.53
asnameserver
entry in the/etc/resolv.conf
file.Both the
dnsmasq
andsystemd-resolved
services forward queries for the search domain set in a NetworkManager connection to the DNS server specified in that connection, and forwardes queries to other domains to the connection with the default route. When multiple connections have the same search domain set,dnsmasq
andsystemd-resolved
forward queries for this domain to the DNS server set in the connection with the lowest priority value.
Default values of DNS priority parameters
NetworkManager uses the following default values for connections:
-
50
for VPN connections -
100
for other connections
Valid DNS priority values:
You can set both the global default and connection-specific ipv4.dns-priority
and ipv6.dns-priority
parameters to a value between -2147483647
and 2147483647
.
- A lower value has a higher priority.
- Negative values have the special effect of excluding other configurations with a greater value. For example, if at least one connection with a negative priority value exists, NetworkManager uses only the DNS servers specified in the connection profile with the lowest priority.
If multiple connections have the same DNS priority, NetworkManager prioritizes the DNS in the following order:
- VPN connections
- Connection with an active default route. The active default route is the default route with the lowest metric.
Additional resources