Menu Close
Configuring and managing networking
A guide to configuring and managing networking in Red Hat Enterprise Linux 9
Abstract
Making open source more inclusive
Red Hat is committed to replacing problematic language in our code, documentation, and web properties. We are beginning with these four terms: master, slave, blacklist, and whitelist. Because of the enormity of this endeavor, these changes will be implemented gradually over several upcoming releases. For more details, see our CTO Chris Wright’s message.
Providing feedback on Red Hat documentation
We appreciate your input on our documentation. Please let us know how we could make it better.
For simple comments on specific passages:
- Make sure you are viewing the documentation in the Multi-page HTML format. In addition, ensure you see the Feedback button in the upper right corner of the document.
- Use your mouse cursor to highlight the part of text that you want to comment on.
- Click the Add Feedback pop-up that appears below the highlighted text.
- Follow the displayed instructions.
For submitting feedback via Bugzilla, create a new ticket:
- Go to the Bugzilla website.
- As the Component, use Documentation.
- Fill in the Description field with your suggestion for improvement. Include a link to the relevant part(s) of documentation.
- Click Submit Bug.
Chapter 1. Consistent network interface device naming
Red Hat Enterprise Linux provides methods for consistent and predictable device naming for network interfaces. These features help locating and differentiating network interfaces.
The kernel assigns names to network interfaces by concatenating a fixed prefix and a number that increases as the kernel initializes the network devices. For instance, eth0
would represent the first device being probed on start-up. However, these names do not necessarily correspond to labels on the chassis. Modern server platforms with multiple network adapters can encounter non-deterministic and counter-intuitive naming of these interfaces. This affects both network adapters embedded on the system board and add-in adapters.
In Red Hat Enterprise Linux, the udev
device manager supports a number of different naming schemes. By default, udev
assigns fixed names based on firmware, topology, and location information. This has the following advantages:
- Device names are fully predictable.
- Device names stay fixed even if you add or remove hardware, because no re-enumeration takes place.
- Defective hardware can be seamlessly replaced.
1.1. Network interface device naming hierarchy
If consistent device naming is enabled, which is the default in Red Hat Enterprise Linux, the udev
device manager generates device names based on the following schemes:
Scheme | Description | Example |
---|---|---|
1 |
Device names incorporate firmware or BIOS-provided index numbers for onboard devices. If this information is not available or applicable, |
|
2 |
Device names incorporate firmware or BIOS-provided PCI Express (PCIe) hot plug slot index numbers. If this information is not available or applicable, |
|
3 |
Device names incorporate the physical location of the connector of the hardware. If this information is not available or applicable, |
|
4 | Device names incorporate the MAC address. Red Hat Enterprise Linux does not use this scheme by default, but administrators can optionally use it. |
|
5 |
The traditional unpredictable kernel naming scheme. If |
|
By default, Red Hat Enterprise Linux selects the device name based on the NamePolicy
setting in the /usr/lib/systemd/network/99-default.link
file. The order of the values in NamePolicy
is important. Red Hat Enterprise Linux uses the first device name that is both specified in the file and that udev
generated.
If you manually configured udev
rules to change the name of kernel devices, those rules take precedence.
1.2. How the network device renaming works
By default, consistent device naming is enabled in Red Hat Enterprise Linux. The udev
device manager processes different rules to rename the devices. The following list describes the order in which udev
processes these rules and what actions these rules are responsible for:
-
The
/usr/lib/udev/rules.d/60-net.rules
file defines that the/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 the file. This file only exists after installing theinitscripts
package. -
The
/usr/lib/udev/rules.d/71-biosdevname.rules
file defines that thebiosdevname
utility renames the interface according to its naming policy, provided that it was not renamed in the previous step. -
The
/usr/lib/udev/rules.d/75-net-description.rules
file defines thatudev
examines the network interface device and sets the properties inudev
-internal variables that will be processed in the next step. Note that some of these properties might be undefined. The
/usr/lib/udev/rules.d/80-net-setup-link.rules
file calls thenet_setup_link
udev
built-in which then applies the policy. The following is the default policy that is stored in the/usr/lib/systemd/network/99-default.link
file:[Link] NamePolicy=kernel database onboard slot path MACAddressPolicy=persistent
With this policy, if the kernel uses a persistent name,
udev
does not rename the interface. If the kernel does not use a persistent name,udev
renames the interface to the name provided by the hardware database ofudev
. If this database is not available, Red Hat Enterprise Linux falls back to the mechanisms described above.Alternatively, set the
NamePolicy
parameter in this file tomac
for media access control (MAC) address-based interface names.The
/usr/lib/udev/rules.d/80-net-setup-link.rules
file defines thatudev
renames the interface based on theudev
-internal parameters in the following order:-
ID_NET_NAME_ONBOARD
-
ID_NET_NAME_SLOT
-
ID_NET_NAME_PATH
If one parameter is not set,
udev
uses the next one. If none of the parameters are set, the interface is not renamed.-
Steps 3 and 4 implement the naming schemes 1 to 4 described in Network interface device naming hierarchy.
Additional resources
- Customizing the prefix of Ethernet interfaces
-
For details about the
NamePolicy
parameter, see thesystemd.link(5)
man page.
1.3. Predictable network interface device names on the x86_64 platform explained
When the consistent network device name feature is enabled, the udev
device manager creates the names of devices based on different criteria. This section describes the naming scheme when Red Hat Enterprise Linux is installed on a x86_64 platform.
The interface name starts with a two-character prefix based on the type of interface:
-
en
for Ethernet -
wl
for wireless LAN (WLAN) -
ww
for wireless wide area network (WWAN)
Additionally, one of the following is appended to one of the above-mentioned prefix based on the schema the udev
device manager applies:
-
o<on-board_index_number>
s<hot_plug_slot_index_number>[f<function>][d<device_id>]
Note that all multi-function PCI devices have the
[f<function>]
number in the device name, including the function0
device.-
x<MAC_address>
[P<domain_number>]p<bus>s<slot>[f<function>][d<device_id>]
The
[P<domain_number>]
part defines the PCI geographical location. This part is only set if the domain number is not0
.[P<domain_number>]p<bus>s<slot>[f<function>][u<usb_port>][…][c<config>][i<interface>]
For USB devices, the full chain of port numbers of hubs is composed. If the name is longer than the maximum (15 characters), the name is not exported. If there are multiple USB devices in the chain,
udev
suppresses the default values for USB configuration descriptors (c1
) and USB interface descriptors (i0
).
1.4. Predictable network interface device names on the System z platform explained
When the consistent network device name feature is enabled, the udev
device manager on the System z platform creates the names of devices based on the bus ID. The bus ID identifies a device in the s390 channel subsystem.
For a channel command word (CCW) device, the bus ID is the device number with a leading 0.n
prefix where n
is the subchannel set ID.
Ethernet interfaces are named, for example, enccw0.0.1234
. Serial Line Internet Protocol (SLIP) channel-to-channel (CTC) network devices are named, for example, slccw0.0.1234
.
Use the znetconf -c
or the lscss -a
commands to display available network devices and their bus IDs.
1.5. Disabling consistent interface device naming during the installation
This section describes how to disable consistent interface device naming during the installation.
Red Hat recommends not to disable consistent device naming and does not support this feature on hosts with more than one network interface. Disabling consistent device naming can cause different kind of problems. For example, if you add another network interface card to the system, the assignment of the kernel device names, such as eth0
, is no longer fixed. Consequently, after a reboot, the Kernel can name the device differently.
Procedure
- Boot the Red Hat Enterprise Linux 9 installation media.
-
In the boot manager, select
Install Red Hat Enterprise Linux 9
, and press the Tab key to edit the entry. Append the
net.ifnames=0
parameter to the kernel command line:vmlinuz... net.ifnames=0
- Press Enter to start the installation.
1.6. Disabling consistent interface device naming on an installed system
This section describes how to disable consistent interface device naming on a RHEL system that is already installed.
Red Hat recommends not to disable consistent device naming and does not support this feature on hosts with more than one network interface. Disabling consistent device naming can cause different kinds of problems. For example, if you add another network interface card to the system, the assignment of the kernel device names, such as eth0
, is no longer fixed. Consequently, after a reboot, the Kernel can name the device differently.
Prerequisites
- The system uses consistent interface device naming, which is the default.
Procedure
Edit the
/etc/default/grub
file and append thenet.ifnames=0
parameter to theGRUB_CMDLINE_LINUX
variable:GRUB_CMDLINE_LINUX="... net.ifnames=0"
Rebuild the
grub.cfg
file:On a system with UEFI boot mode:
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
On a system with legacy boot mode:
# grub2-mkconfig -o /boot/grub2/grub.cfg
Display the current profile names and the associated device names:
# nmcli -f NAME,DEVICE,FILENAME connection show NAME DEVICE FILENAME System enp1s0 enp1s0 /etc/sysconfig/network-scripts/ifcfg-enp1s0 System enp7s0 enp7s0 /etc/NetworkManager/system-connections/enp7s0.nmconnection
Note which profile name and configuration file is associated with each device.
Remove
HWADDR
parameters from all connection profiles:# sed -i '/^HWADDR=/d' /etc/sysconfig/network-scripts/ifcfg-enp1s0 /etc/NetworkManager/system-connections/enp7s0.nmconnection
Display the MAC addresses that are associated with the Ethernet devices:
# 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 00:53:00:c5:98:1c brd ff:ff:ff:ff:ff:ff 3: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:53:00:b6:87:c6 brd ff:ff:ff:ff:ff:ff
Reboot the host:
# reboot
After the reboot, display the Ethernet devices and identify the new interface name based on the MAC address:
# ip link show ... 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:53:00:b6:87:c6 brd ff:ff:ff:ff:ff:ff 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:53:00:c5:98:1c brd ff:ff:ff:ff:ff:ff
If you compare the current output with the previous one:
-
Interface
enp7s0
(MAC address00:53:00:b6:87:c6
) is now namedeth0
. -
Interface
enp1s0
(MAC address00:53:00:c5:98:1c
) is now namedeth1
.
-
Interface
Rename the configuration file:
# mv /etc/NetworkManager/system-connections/enp7s0.nmconnection /etc/NetworkManager/system-connections/eth0.nmconnection # mv /etc/sysconfig/network-scripts/ifcfg-enp1s0 /etc/sysconfig/network-scripts/ifcfg-eth1
Reload NetworkManager:
# nmcli connection reload
If no profile name is set in the configuration files, NetworkManager uses a default value. To determine the current profile name after you renamed and reloaded the connections, enter:
# nmcli -f NAME,DEVICE,FILENAME connection show NAME FILENAME System enp7s0 /etc/NetworkManager/system-connections/eth0.nmconnection System enp1s0 /etc/sysconfig/network-scripts/ifcfg-eth1
You require the profile names in the next step.
Rename the NetworkManager connection profiles and update the interface name in each profile:
# nmcli connection modify "System enp7s0" connection.id eth0 connection.interface-name eth0 # nmcli connection modify "System enp1s0" connection.id eth1 connection.interface-name eth1
Reactivate the NetworkManager connections:
# nmcli connection up eth0 # nmcli connection up eth1
1.7. Customizing the prefix of Ethernet interfaces
You can customize the prefix of Ethernet interface names during the Red Hat Enterprise Linux installation.
Red Hat does not support customizing the prefix using the prefixdevname
utility on already deployed systems.
After the RHEL installation, the udev
service names Ethernet devices <prefix>.<index>
. For example, if you select the prefix net
, RHEL names Ethernet interfaces net0
, net1
, and so on.
Prerequisites
The prefix you want to set meets the following requirements:
- It consists of ASCII characters.
- It is an alpha-numeric string.
- It is shorter than 16 characters.
-
It does not conflict with any other well-known prefix used for network interface naming, such as
eth
,eno
,ens
, andem
.
Procedure
- Boot the Red Hat Enterprise Linux installation media.
In the boot manager:
-
Select the
Install Red Hat Enterprise Linux <version>
entry, and press Tab to edit the entry. -
Append
net.ifnames.prefix=<prefix>
to the kernel options. - Press Enter to start the installer.
-
Select the
- Install Red Hat Enterprise Linux.
Verification
After the installation, display the Ethernet 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:53:00:c5:98:1c brd ff:ff:ff:ff:ff:ff 3: net1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:53:00:c2:39:9e brd ff:ff:ff:ff:ff:ff ...
1.8. Assigning user-defined network interface names using udev rules
The udev
device manager supports a set of rules to customize the interface names.
Procedure
Display all network interfaces and their MAC addresses:
# ip link list enp6s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether b4:96:91:14:ae:58 brd ff:ff:ff:ff:ff:ff enp6s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether b4:96:91:14:ae:5a brd ff:ff:ff:ff:ff:ff enp4s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:90:fa:6a:7d:90 brd ff:ff:ff:ff:ff:ff
Create the file
/etc/udev/rules.d/70-custom-ifnames.rules
with the following contents:SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="b4:96:91:14:ae:58",ATTR{type}=="1",NAME="provider0" SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="b4:96:91:14:ae:5a",ATTR{type}=="1",NAME="provider1" SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="00:90:fa:6a:7d:90",ATTR{type}=="1",NAME="dmz"
These rules match the MAC address of the network interfaces and rename them to the name given in the NAME property. In these examples, ATTR{type} parameter value 1 defines that the interface is of type Ethernet.
Verification
Reboot the system.
# reboot
Verify that interface names for each MAC address match the value you set in the
NAME
parameter of the rule file:# ip link show provider0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether b4:96:91:14:ae:58 brd ff:ff:ff:ff:ff:ff altname enp6s0f0 provider1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether b4:96:91:14:ae:5a brd ff:ff:ff:ff:ff:ff altname enp6s0f1 dmz: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:90:fa:6a:7d:90 brd ff:ff:ff:ff:ff:ff altname enp4s0f0
Additional resources
-
udev(7)
man page -
udevadm(8)
man page -
/usr/src/kernels/<kernel_version>/include/uapi/linux/if_arp.h
provided by thekernel-doc
package
1.9. Assigning user-defined network interface names using systemd link files
Create a naming scheme by renaming network interfaces to provider0
.
Procedure
Display all interfaces names and their MAC addresses:
# ip link show enp6s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether b4:96:91:14:ae:58 brd ff:ff:ff:ff:ff:ff enp6s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether b4:96:91:14:ae:5a brd ff:ff:ff:ff:ff:ff enp4s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:90:fa:6a:7d:90 brd ff:ff:ff:ff:ff:ff
For naming the interface with MAC address b4:96:91:14:ae:58 to provider0, create the /etc/systemd/network/70-custom-ifnames.link file with following contents:
[Match] MACAddress=b4:96:91:14:ae:58 [Link] Name=provider0
This link file matches a MAC address and renames the network interface to the name set in the
Name
parameter.
Verification
Reboot the system:
# reboot
Verify that the device with the MAC address you specified in the link file has been assigned 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 b4:96:91:14:ae:58 brd ff:ff:ff:ff:ff:ff
Additional resources
-
systemd.link(5)
man page
1.10. Additional resources
-
See the
udev(7)
man page for details about theudev
device manager.
Chapter 2. Getting started with NetworkManager
By default, RHEL uses NetworkManager to manage the network configuration and connections.
2.1. Benefits of using NetworkManager
The main benefits of using NetworkManager are:
- Offering an API through D-Bus which allows to query and control network configuration and state. In this way, networking can be checked and configured by multiple applications ensuring a synced and up-to-date networking status. For example, the RHEL web console, which monitors and configures servers through a web browser, uses the NetworkManager D-BUS interface to configure networking, as well as the Gnome GUI, the nmcli and the nm-connection-editor tools. Each change made in one of these tools is detected by all the others.
- Making Network management easier: NetworkManager ensures that network connectivity works. When it detects that there is no network configuration in a system but there are network devices, NetworkManager creates temporary connections to provide connectivity.
- Providing easy setup of connection to the user: NetworkManager offers management through different tools — GUI, nmtui, nmcli.
- Supporting configuration flexibility. For example, configuring a WiFi interface, NetworkManager scans and shows the available wifi networks. You can select an interface, and NetworkManager displays the required credentials providing automatic connection after the reboot process. NetworkManager can configure network aliases, IP addresses, static routes, DNS information, and VPN connections, as well as many connection-specific parameters. You can modify the configuration options to reflect your needs.
- Maintaining the state of devices after the reboot process and taking over interfaces which are set into managed mode during restart.
- Handling devices which are not explicitly set unmanaged but controlled manually by the user or another network service.
Additional resources
2.2. An overview of utilities and applications you can use to manage NetworkManager connections
You can use the following utilities and applications to manage NetworkManager connections:
-
nmcli
: A command-line utility to manage connections. -
nmtui
: A curses-based text user interface (TUI). To use this application, install theNetworkManager-tui
package. -
nm-connection-editor
: A graphical user interface (GUI) for NetworkManager-related tasks. To start this application, enternm-connection-editor
in a terminal of a GNOME session. -
control-center
: A GUI provided by the GNOME shell for desktop users. Note that this application supports less features thannm-connection-editor
. -
The
network connection icon
in the GNOME shell: This icon represents network connection states and serves as visual indicator for the type of connection you are using.
Chapter 3. Configuring NetworkManager to ignore certain devices
By default, NetworkManager manages all devices except the lo
(loopback) device. However, you can set certain devices as unmanaged
to configure that NetworkManager ignores these devices. With this setting, you can manually manage these devices, for example, using a script.
3.1. Permanently configuring a device as unmanaged in NetworkManager
You can configure devices as unmanaged
based on several criteria, such as the interface name, MAC address, or device type. This procedure describes how to permanently set the enp1s0
interface as unmanaged
in NetworkManager.
To temporarily configure network devices as unmanaged
, see Temporarily configuring a device as unmanaged in NetworkManager.
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 -- ...
Create the
/etc/NetworkManager/conf.d/99-unmanaged-devices.conf
file with the following content:[keyfile] unmanaged-devices=interface-name:enp1s0
To set multiple devices as unmanaged, separate the entries in the
unmanaged-devices
parameter with semicolon:[keyfile] unmanaged-devices=interface-name:interface_1;interface-name:interface_2;...
Reload the
NetworkManager
service:# systemctl reload NetworkManager
Verification steps
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
-
The
Device List Format
section in theNetworkManager.conf(5)
man page.
3.2. Temporarily configuring a device as unmanaged in NetworkManager
You can configure devices as unmanaged
based on several criteria, such as the interface name, MAC address, or device type. This procedure describes how to temporarily set the enp1s0
interface as unmanaged
in NetworkManager.
Use this method, for example, for testing purposes. To permanently configure network devices as unmanaged
, see Permanently configuring a device as unmanaged in NetworkManager.
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 steps
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
-
The
Device List Format
section in theNetworkManager.conf(5)
man page
Chapter 4. Using nmtui to manage network connections using a text-based interface
The nmtui
application is a text user interface (TUI) for NetworkManager
. The following section provides how you can configure a network interface using nmtui
.
The nmtui application does not support all connection types. In particular, you cannot add or modify VPN connections or Ethernet connections that require 802.1X authentication.
4.1. Starting the nmtui utility
This procedure describes how to start the NetworkManager text user interface, nmtui
.
Prerequisites
-
The
NetworkManager-tui
package is installed.
Procedure
To start
nmtui
, enter:# nmtui
To navigate:
- Use the cursors or press Tab to step forwards and press Shift+Tab to step back through the options.
- Use Enter to select an option.
- Use the Space bar to toggle the status of check boxes.
4.2. Adding a connection profile using nmtui
The nmtui
application provides a text user interface to NetworkManager. This procedure describes how to add a new connection profile.
Prerequisites
-
The
NetworkManager-tui
package is installed.
Procedure
Start the NetworkManager text user interface utility:
# nmtui
-
Select the
Edit a connection
menu entry, and press Enter. - Select the Add button, and press Enter.
-
Select
Ethernet
, and press Enter. Fill the fields with the connection details.
- Select OK to save the changes.
-
Select
Back
to return to the main menu. -
Select
Activate a connection
, and press Enter. - Select the new connection entry, and press Enter to activate the connection.
- Select Back to return to the main menu.
-
Select
Quit
.
Verification steps
Display the status of the devices and connections:
# nmcli device status DEVICE TYPE STATE CONNECTION enp1s0 ethernet connected Example-Connection
To display all settings of the connection profile:
# nmcli connection show Example-Connection connection.id: Example-Connection connection.uuid: b6cdfa1c-e4ad-46e5-af8b-a75f06b79f76 connection.stable-id: -- connection.type: 802-3-ethernet connection.interface-name: enp1s0 ...
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 NetworkManager duplicates a connection after restart of NetworkManager service.
Additional resources
- Testing basic network settings
-
nmtui(1)
man page
4.3. Applying changes to a modified connection using nmtui
After you modified a connection in nmtui
, you must reactivate the connection. Note that reactivating a connection in nmtui
temporarily deactivates the connection.
Prerequisites
- The connection profile does not have the auto-connect setting enabled.
Procedure
In the main menu, select the
Activate a connection
menu entry:- Select the modified connection.
On the right, select the
Deactivate
button, and press Enter:- Select the connection again.
On the right, select the
Activate
button, and press Enter:
Chapter 5. Getting started with nmcli
This section describes general information about the nmcli
utility.
5.1. The different output formats of nmcli
The nmcli
utility supports different options to modify the output of nmcli
commands. Using these options, you can display only the required information. This simplifies processing the output in scripts.
By default, the nmcli
utility displays its output in a table-like format:
# nmcli device
DEVICE TYPE STATE CONNECTION
enp1s0 ethernet connected enp1s0
lo loopback unmanaged --
Using the -f
option, you can display specific columns in a custom order. For example, to display only the DEVICE
and STATE
column, enter:
# nmcli -f DEVICE,STATE device
DEVICE STATE
enp1s0 connected
lo unmanaged
The -t
option enables you to display the individual fields of the output in a colon-separated format:
# nmcli -t device
enp1s0:ethernet:connected:enp1s0
lo:loopback:unmanaged:
Combining the -f
and -t
to display only specific fields in colon-separated format can be helpful when you process the output in scripts:
# nmcli -f DEVICE,STATE -t device
enp1s0:connected
lo:unmanaged
5.2. Using tab completion in nmcli
If the bash-completion
package is installed on your host, the nmcli
utility supports tab completion. This enables you to auto-complete option names and to identify possible options and values.
For example, if you type nmcli con
and press Tab, then the shell automatically completes the command to nmcli connection
.
For the completion, the options or value you have typed must be unique. If it is not unique, then nmcli
displays all possibilities. For example, if you type nmcli connection d
and press Tab, then the command shows command delete
and down
as possible options.
You can also use tab completion to display all properties you can set in a connection profile. For example, if you type nmcli connection modify connection_name
and press Tab, the command shows the full list of available properties.
5.3. Frequent nmcli commands
The following is an overview about frequently-used nmcli
commands.
To display the list connection profiles, enter:
# nmcli connection show NAME UUID TYPE DEVICE enp1s0 45224a39-606f-4bf7-b3dc-d088236c15ee ethernet enp1s0
To display the settings of a specific connection profile, enter:
# nmcli connection show connection_name connection.id: enp1s0 connection.uuid: 45224a39-606f-4bf7-b3dc-d088236c15ee connection.stable-id: -- connection.type: 802-3-ethernet ...
To modify properties of a connection, enter:
# nmcli connection modify connection_name property value
You can modify multiple properties using a single command if you pass multiple
property value
combinations to the command.To display the list of network devices, their state, and which connection profiles use the device, enter:
# nmcli device DEVICE TYPE STATE CONNECTION enp1s0 ethernet connected enp1s0 enp8s0 ethernet disconnected -- enp7s0 ethernet unmanaged -- ...
To activate a connection, enter:
# nmcli connection up connection_name
To deactivate a connection, enter:
# nmcli connection down connection_name
Chapter 6. Configuring an Ethernet connection
This section describes different ways how to configure an Ethernet connection with static and dynamic IP addresses.
6.1. Configuring a static Ethernet connection using nmcli
This procedure describes adding an Ethernet connection with the following settings using the nmcli
utility:
-
A static IPv4 address -
192.0.2.1
with a/24
subnet mask -
A static IPv6 address -
2001:db8:1::1
with a/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
Procedure
Add a new NetworkManager connection profile for the Ethernet connection:
# nmcli connection add con-name Example-Connection ifname enp7s0 type ethernet
The further steps modify the
Example-Connection
connection profile you created.Set the IPv4 address:
# nmcli connection modify Example-Connection ipv4.addresses 192.0.2.1/24
Set the IPv6 address:
# nmcli connection modify Example-Connection ipv6.addresses 2001:db8:1::1/64
Set the IPv4 and IPv6 connection method to
manual
:# nmcli connection modify Example-Connection ipv4.method manual # nmcli connection modify Example-Connection ipv6.method manual
Set the IPv4 and IPv6 default gateways:
# nmcli connection modify Example-Connection ipv4.gateway 192.0.2.254 # nmcli connection modify Example-Connection ipv6.gateway 2001:db8:1::fffe
Set the IPv4 and IPv6 DNS server addresses:
# nmcli connection modify Example-Connection ipv4.dns "192.0.2.200" # nmcli connection modify Example-Connection ipv6.dns "2001:db8:1::ffbb"
To set multiple DNS servers, specify them space-separated and enclosed in quotes.
Set the DNS search domain for the IPv4 and IPv6 connection:
# nmcli connection modify Example-Connection ipv4.dns-search example.com # nmcli connection modify Example-Connection ipv6.dns-search example.com
Activate the connection profile:
# nmcli connection up Example-Connection Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13)
Verification steps
Display the status of the devices and connections:
# nmcli device status DEVICE TYPE STATE CONNECTION enp7s0 ethernet connected Example-Connection
To display all settings of the connection profile:
# nmcli connection show Example-Connection connection.id: Example-Connection connection.uuid: b6cdfa1c-e4ad-46e5-af8b-a75f06b79f76 connection.stable-id: -- connection.type: 802-3-ethernet connection.interface-name: enp7s0 ...
Use the
ping
utility to verify that this host can send packets to other hosts.Ping an IP address in the same subnet.
For IPv4:
# ping 192.0.2.3
For IPv6:
# ping 2001:db8:1::2
If the command fails, verify the IP and subnet settings.
Ping an IP address in a remote subnet.
For IPv4:
# ping 198.162.3.1
For IPv6:
# ping 2001:db8:2::1
If the command fails, ping the default gateway to verify settings.
For IPv4:
# ping 192.0.2.254
For IPv6:
# ping 2001:db8:1::fff3
Use the
host
utility to verify that name resolution works. For example:# host client.example.com
If the command returns any error, such as
connection timed out
orno servers could be reached
, verify your DNS settings.
Troubleshooting steps
If the connection fails or if the network interface switches between an up and down status:
- Make sure 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 the server is connected to.
- 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 NetworkManager duplicates a connection after restart of NetworkManager service
Additional resources
-
nm-settings(5)
,nmcli
andnmcli(1)
man pages - Configuring NetworkManager to avoid using a specific profile to provide a default gateway
6.2. Configuring a static Ethernet connection using the nmcli interactive editor
This procedure describes adding an Ethernet connection with the following settings using the nmcli
interactive mode:
-
A static IPv4 address -
192.0.2.1
with a/24
subnet mask -
A static IPv6 address -
2001:db8:1::1
with a/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
Procedure
To add a new NetworkManager connection profile for the Ethernet connection, and starting the interactive mode, enter:
# nmcli connection edit type ethernet con-name Example-Connection
Set the network interface:
nmcli>
set connection.interface-name enp7s0
Set the IPv4 address:
nmcli>
set ipv4.addresses 192.0.2.1/24
Set the IPv6 address:
nmcli>
set ipv6.addresses 2001:db8:1::1/64
Set the IPv4 and IPv6 connection method to
manual
:nmcli>
set ipv4.method manual
nmcli>set ipv6.method manual
Set the IPv4 and IPv6 default gateways:
nmcli>
set ipv4.gateway 192.0.2.254
nmcli>set ipv6.gateway 2001:db8:1::fffe
Set the IPv4 and IPv6 DNS server addresses:
nmcli>
set ipv4.dns 192.0.2.200
nmcli>set ipv6.dns 2001:db8:1::ffbb
To set multiple DNS servers, specify them space-separated and enclosed in quotes.
Set the DNS search domain for the IPv4 and IPv6 connection:
nmcli>
set ipv4.dns-search example.com
nmcli>set ipv6.dns-search example.com
Save and activate the connection:
nmcli>
save persistent
Saving the connection with 'autoconnect=yes'. That might result in an immediate activation of the connection. Do you still want to save? (yes/no) [yes]yes
Leave the interactive mode:
nmcli>
quit
Verification steps
Display the status of the devices and connections:
# nmcli device status DEVICE TYPE STATE CONNECTION enp7s0 ethernet connected Example-Connection
To display all settings of the connection profile:
# nmcli connection show Example-Connection connection.id: Example-Connection connection.uuid: b6cdfa1c-e4ad-46e5-af8b-a75f06b79f76 connection.stable-id: -- connection.type: 802-3-ethernet connection.interface-name: enp7s0 ...
Use the
ping
utility to verify that this host can send packets to other hosts.Ping an IP address in the same subnet.
For IPv4:
# ping 192.0.2.3
For IPv6:
# ping 2001:db8:1::2
If the command fails, verify the IP and subnet settings.
Ping an IP address in a remote subnet.
For IPv4:
# ping 198.162.3.1
For IPv6:
# ping 2001:db8:2::1
If the command fails, ping the default gateway to verify settings.
For IPv4:
# ping 192.0.2.254
For IPv6:
# ping 2001:db8:1::fff3
Use the
host
utility to verify that name resolution works. For example:# host client.example.com
If the command returns any error, such as
connection timed out
orno servers could be reached
, verify your DNS settings.
Troubleshooting steps
If the connection fails or if the network interface switches between an up and down status:
- Make sure 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 the server is connected to.
- 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 NetworkManager duplicates a connection after restart of NetworkManager service
Additional resources
-
nm-settings(5)
man page -
nmcli(1)
man page - Configuring NetworkManager to avoid using a specific profile to provide a default gateway
6.3. Configuring a static Ethernet connection using nmstatectl
This procedure describes how to configure an Ethernet connection for the enp7s0
device with the following settings using the nmstatectl
utility:
-
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
The nmstatectl
utility 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.
The procedure defines the interface configuration in YAML format. Alternatively, you can also specify the configuration in JSON format.
Prerequisites
-
The
nmstate
package is installed.
Procedure
Create a YAML file, for example
~/create-ethernet-profile.yml
, with the following contents:--- interfaces: - name: enp7s0 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: enp7s0 - destination: ::/0 next-hop-address: 2001:db8:1::fffe next-hop-interface: enp7s0 dns-resolver: config: search: - example.com server: - 192.0.2.200 - 2001:db8:1::ffbb
Apply the settings to the system:
# nmstatectl apply ~/create-ethernet-profile.yml
Verification steps
Display the status of the devices and connections:
# nmcli device status DEVICE TYPE STATE CONNECTION enp7s0 ethernet connected enp7s0
Display all settings of the connection profile:
# nmcli connection show enp7s0 connection.id: enp7s0 connection.uuid: b6cdfa1c-e4ad-46e5-af8b-a75f06b79f76 connection.stable-id: -- connection.type: 802-3-ethernet connection.interface-name: enp7s0 ...
Display the connection settings in YAML format:
# nmstatectl show enp7s0
Additional resources
-
nmstatectl(8)
man page -
/usr/share/doc/nmstate/examples/
6.4. Configuring a static Ethernet connection using RHEL System Roles with the interface name
This procedure describes how to use the Networking RHEL System Role to remotely add an Ethernet connection for the enp7s0
interface with the following settings by running an Ansible playbook:
-
A static IPv4 address -
192.0.2.1
with a/24
subnet mask -
A static IPv6 address -
2001:db8:1::1
with a/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
Run this procedure on the Ansible control node.
Prerequisites
-
The
ansible-core
andrhel-system-roles
packages are installed on the control node. -
If you use a different remote user than
root
when you run the playbook, this user has appropriatesudo
permissions on the managed node. - The host uses NetworkManager to configure the network.
Procedure
If the host on which you want to execute the instructions in the playbook is not yet inventoried, add the IP or name of this host to the
/etc/ansible/hosts
Ansible inventory file:node.example.com
Create the
~/ethernet-static-IP.yml
playbook with the following content:--- - name: Configure an Ethernet connection with static IP hosts: node.example.com become: true tasks: - include_role: name: rhel-system-roles.network vars: network_connections: - name: enp7s0 interface_name: enp7s0 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
Run the playbook:
To connect as
root
user to the managed host, enter:# ansible-playbook -u root ~/ethernet-static-IP.yml
To connect as a user to the managed host, enter:
# ansible-playbook -u user_name --ask-become-pass ~/ethernet-static-IP.yml
The
--ask-become-pass
option makes sure that theansible-playbook
command prompts for thesudo
password of the user defined in the-u user_name
option.
If you do not specify the
-u user_name
option,ansible-playbook
connects to the managed host as the user that is currently logged in to the control node.
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
-
ansible-playbook(1)
man page
6.5. Configuring a static Ethernet connection using RHEL System Roles with a device path
This procedure describes how to use RHEL System Roles to remotely add an Ethernet connection with static IP address for devices that match a specific device path by running an Ansible playbook.
You can identify the device path with the following command:
# udevadm info /sys/class/net/<device_name> | grep ID_PATH=
This procedure sets the following settings to the device that matches the PCI ID 0000:00:0[1-3].0
expression, but not 0000:00:02.0
:
-
A static IPv4 address -
192.0.2.1
with a/24
subnet mask -
A static IPv6 address -
2001:db8:1::1
with a/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
Run this procedure on the Ansible control node.
Prerequisites
-
The
ansible-core
andrhel-system-roles
packages are installed on the control node. -
If you use a different remote user than
root
when you run the playbook, this user has appropriatesudo
permissions on the managed node. - The host uses NetworkManager to configure the network.
Procedure
If the host on which you want to execute the instructions in the playbook is not yet inventoried, add the IP or name of this host to the
/etc/ansible/hosts
Ansible inventory file:node.example.com
Create the
~/ethernet-dynamic-IP.yml
playbook with the following content:--- - name: Configure an Ethernet connection with dynamic IP hosts: node.example.com become: true tasks: - 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
match
parameter in this example defines that Ansible applies the play to devices that match PCI ID0000:00:0[1-3].0
, but not0000:00:02.0
. For further details about special modifiers and wild cards you can use, see thematch
parameter description in the/usr/share/ansible/roles/rhel-system-roles.network/README.md
file.Run the playbook:
To connect as
root
user to the managed host, enter:# ansible-playbook -u root ~/ethernet-dynamic-IP.yml
To connect as a user to the managed host, enter:
# ansible-playbook -u user_name --ask-become-pass ~/ethernet-dynamic-IP.yml
The
--ask-become-pass
option makes sure that theansible-playbook
command prompts for thesudo
password of the user defined in the-u user_name
option.
If you do not specify the
-u user_name
option,ansible-playbook
connects to the managed host as the user that is currently logged in to the control node.
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
ansible-playbook(1)
man page
6.6. Configuring a dynamic Ethernet connection using nmcli
This procedure describes adding an dynamic Ethernet connection using the nmcli
utility. With this setting, NetworkManager requests the IP settings for this connection from a DHCP server.
Prerequisites
- A DHCP server is available in the network.
Procedure
Add a new NetworkManager connection profile for the Ethernet connection:
# nmcli connection add con-name Example-Connection ifname enp7s0 type ethernet
Optionally, change the host name NetworkManager sends to the DHCP server when using the
Example-Connection
profile:# nmcli connection modify Example-Connection ipv4.dhcp-hostname Example ipv6.dhcp-hostname Example
Optionally, change the client ID NetworkManager sends to an IPv4 DHCP server when using the
Example-Connection
profile:# nmcli connection modify Example-Connection ipv4.dhcp-client-id client-ID
Note that there is no
dhcp-client-id
parameter for IPv6. To create an identifier for IPv6, configure thedhclient
service.
Verification steps
Display the status of the devices and connections:
# nmcli device status DEVICE TYPE STATE CONNECTION enp7s0 ethernet connected Example-Connection
To display all settings of the connection profile:
# nmcli connection show Example-Connection connection.id: Example-Connection connection.uuid: b6cdfa1c-e4ad-46e5-af8b-a75f06b79f76 connection.stable-id: -- connection.type: 802-3-ethernet connection.interface-name: enp7s0 ...
Use the
ping
utility to verify that this host can send packets to other hosts.Ping an IP address in the same subnet.
For IPv4:
# ping 192.0.2.3
For IPv6:
# ping 2001:db8:1::2
If the command fails, verify the IP and subnet settings.
Ping an IP address in a remote subnet.
For IPv4:
# ping 198.162.3.1
For IPv6:
# ping 2001:db8:2::1
If the command fails, ping the default gateway to verify settings.
For IPv4:
# ping 192.0.2.254
For IPv6:
# ping 2001:db8:1::fff3
Use the
host
utility to verify that name resolution works. For example:# host client.example.com
If the command returns any error, such as
connection timed out
orno servers could be reached
, verify your DNS settings.
Additional resources
-
dhclient(8)
man page -
nm-settings(5)
-
nmcli(1)
man page - NetworkManager duplicates a connection after restart of NetworkManager service
6.7. Configuring a dynamic Ethernet connection using the nmcli interactive editor
This procedure describes adding an dynamic Ethernet connection using the interactive editor of the nmcli
utility. With this setting, NetworkManager requests the IP settings for this connection from a DHCP server.
Prerequisites
- A DHCP server is available in the network.
Procedure
To add a new NetworkManager connection profile for the Ethernet connection, and starting the interactive mode, enter:
# nmcli connection edit type ethernet con-name Example-Connection
Set the network interface:
nmcli>
set connection.interface-name enp7s0
Optionally, change the host name NetworkManager sends to the DHCP server when using the
Example-Connection
profile:nmcli>
set ipv4.dhcp-hostname Example
nmcli>set ipv6.dhcp-hostname Example
Optionally, change the client ID NetworkManager sends to an IPv4 DHCP server when using the
Example-Connection
profile:nmcli>
set ipv4.dhcp-client-id client-ID
Note that there is no
dhcp-client-id
parameter for IPv6. To create an identifier for IPv6, configure thedhclient
service.Save and activate the connection:
nmcli>
save persistent
Saving the connection with 'autoconnect=yes'. That might result in an immediate activation of the connection. Do you still want to save? (yes/no) [yes]yes
Leave the interactive mode:
nmcli>
quit
Verification steps
Display the status of the devices and connections:
# nmcli device status DEVICE TYPE STATE CONNECTION enp7s0 ethernet connected Example-Connection
To display all settings of the connection profile:
# nmcli connection show Example-Connection connection.id: Example-Connection connection.uuid: b6cdfa1c-e4ad-46e5-af8b-a75f06b79f76 connection.stable-id: -- connection.type: 802-3-ethernet connection.interface-name: enp7s0 ...
Use the
ping
utility to verify that this host can send packets to other hosts.Ping an IP address in the same subnet.
For IPv4:
# ping 192.0.2.3
For IPv6:
# ping 2001:db8:1::2
If the command fails, verify the IP and subnet settings.
Ping an IP address in a remote subnet.
For IPv4:
# ping 198.162.3.1
For IPv6:
# ping 2001:db8:2::1
If the command fails, ping the default gateway to verify settings.
For IPv4:
# ping 192.0.2.254
For IPv6:
# ping 2001:db8:1::fff3
Use the
host
utility to verify that name resolution works. For example:# host client.example.com
If the command returns any error, such as
connection timed out
orno servers could be reached
, verify your DNS settings.
Additional resources
-
dhclient(8)
man page -
nm-settings(5)
-
nmcli(1)
man page - NetworkManager duplicates a connection after restart of NetworkManager service
6.8. Configuring a dynamic Ethernet connection using nmstatectl
This procedure describes how to add an dynamic Ethernet for the enp7s0
device using the nmstatectl
utility. With the settings in this procedure, NetworkManager requests the IP settings for this connection from a DHCP server.
The nmstatectl
utility 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.
The procedure defines the interface configuration in YAML format. Alternatively, you can also specify the configuration in JSON format.
Prerequisites
-
The
nmstate
package is installed.
Procedure
Create a YAML file, for example
~/create-ethernet-profile.yml
, with the following contents:--- interfaces: - name: enp7s0 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
Apply the settings to the system:
# nmstatectl apply ~/create-ethernet-profile.yml
Verification steps
Display the status of the devices and connections:
# nmcli device status DEVICE TYPE STATE CONNECTION enp7s0 ethernet connected enp7s0
Display all settings of the connection profile:
# nmcli connection show enp7s0 connection.id: enp7s0_ connection.uuid: b6cdfa1c-e4ad-46e5-af8b-a75f06b79f76 connection.stable-id: -- connection.type: 802-3-ethernet connection.interface-name: enp7s0 ...
Display the connection settings in YAML format:
# nmstatectl show enp7s0
Additional resources
-
nmstatectl(8)
man page -
/usr/share/doc/nmstate/examples/
6.9. Configuring a dynamic Ethernet connection using RHEL System Roles with the interface name
This procedure describes how to use RHEL System Roles to remotely add a dynamic Ethernet connection for the enp7s0
interface by running an Ansible playbook. With this setting, the network connection requests the IP settings for this connection from a DHCP server. Run this procedure on the Ansible control node.
Prerequisites
- A DHCP server is available in the network.
-
The
ansible-core
andrhel-system-roles
packages are installed on the control node. -
If you use a different remote user than
root
when you run the playbook, this user has appropriatesudo
permissions on the managed node. - The host uses NetworkManager to configure the network.
Procedure
If the host on which you want to execute the instructions in the playbook is not yet inventoried, add the IP or name of this host to the
/etc/ansible/hosts
Ansible inventory file:node.example.com
Create the
~/ethernet-dynamic-IP.yml
playbook with the following content:--- - name: Configure an Ethernet connection with dynamic IP hosts: node.example.com become: true tasks: - include_role: name: rhel-system-roles.network vars: network_connections: - name: enp7s0 interface_name: enp7s0 type: ethernet autoconnect: yes ip: dhcp4: yes auto6: yes state: up
Run the playbook:
To connect as
root
user to the managed host, enter:# ansible-playbook -u root ~/ethernet-dynamic-IP.yml
To connect as a user to the managed host, enter:
# ansible-playbook -u user_name --ask-become-pass ~/ethernet-dynamic-IP.yml
The
--ask-become-pass
option makes sure that theansible-playbook
command prompts for thesudo
password of the user defined in the-u user_name
option.
If you do not specify the
-u user_name
option,ansible-playbook
connects to the managed host as the user that is currently logged in to the control node.
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
ansible-playbook(1)
man page
6.10. Configuring a dynamic Ethernet connection using RHEL System Roles with a device path
This procedure describes how to use RHEL System Roles to remotely add a dynamic Ethernet connection for devices that match a specific device path by running an Ansible playbook. With dynamic IP settings, the network connection requests the IP settings for this connection from a DHCP server. Run this procedure on the Ansible control node.
You can identify the device path with the following command:
# udevadm info /sys/class/net/<device_name> | grep ID_PATH=
Prerequisites
- A DHCP server is available in the network.
-
The
ansible-core
andrhel-system-roles
packages are installed on the control node. -
If you use a different remote user than
root
when you run the playbook, this user has appropriatesudo
permissions on the managed node. - The host uses NetworkManager to configure the network.
Procedure
If the host on which you want to execute the instructions in the playbook is not yet inventoried, add the IP or name of this host to the
/etc/ansible/hosts
Ansible inventory file:node.example.com
Create the
~/ethernet-dynamic-IP.yml
playbook with the following content:--- - name: Configure an Ethernet connection with dynamic IP hosts: node.example.com become: true tasks: - 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
match
parameter in this example defines that Ansible applies the play to devices that match PCI ID0000:00:0[1-3].0
, but not0000:00:02.0
. For further details about special modifiers and wild cards you can use, see thematch
parameter description in the/usr/share/ansible/roles/rhel-system-roles.network/README.md
file.Run the playbook:
To connect as
root
user to the managed host, enter:# ansible-playbook -u root ~/ethernet-dynamic-IP.yml
To connect as a user to the managed host, enter:
# ansible-playbook -u user_name --ask-become-pass ~/ethernet-dynamic-IP.yml
The
--ask-become-pass
option makes sure that theansible-playbook
command prompts for thesudo
password of the user defined in the-u user_name
option.
If you do not specify the
-u user_name
option,ansible-playbook
connects to the managed host as the user that is currently logged in to the control node.
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
ansible-playbook(1)
man page
6.11. Configuring an Ethernet connection using control-center
Ethernet connections are the most frequently used connections types in physical or virtual machines. This section describes how to configure this connection type in the GNOME control-center
:
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 device 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. -
Click the + button next to the
Wired
entry to create a new profile. -
Optional: Set a name for the connection on the
Identity
tab. On the
IPv4
tab, configure the IPv4 settings. For example, select methodManual
, set a static IPv4 address, network mask, default gateway, and DNS server:On the
IPv6
tab, configure the IPv6 settings. For example, select methodManual
, set a static IPv6 address, network mask, default gateway, and DNS server:-
Click the Add button to save the connection. The GNOME
control-center
automatically activates the connection.
Verification steps
Display the status of the devices and connections:
# nmcli device status DEVICE TYPE STATE CONNECTION enp7s0 ethernet connected Example-Connection
To display all settings of the connection profile:
# nmcli connection show Example-Connection connection.id: Example-Connection connection.uuid: b6cdfa1c-e4ad-46e5-af8b-a75f06b79f76 connection.stable-id: -- connection.type: 802-3-ethernet connection.interface-name: enp7s0 ...
Use the
ping
utility to verify that this host can send packets to other hosts.Ping an IP address in the same subnet.
For IPv4:
# ping 192.0.2.3
For IPv6:
# ping 2001:db8:1::2
If the command fails, verify the IP and subnet settings.
Ping an IP address in a remote subnet.
For IPv4:
# ping 198.162.3.1
For IPv6:
# ping 2001:db8:2::1
If the command fails, ping the default gateway to verify settings.
For IPv4:
# ping 192.0.2.254
For IPv6:
# ping 2001:db8:1::fffe
Use the
host
utility to verify that name resolution works. For example:# host client.example.com
If the command returns any error, such as
connection timed out
orno servers could be reached
, verify your DNS settings.
Troubleshooting steps
If the connection fails or if the network interface switches between an up and down status:
- Make sure 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 the server is connected to.
- 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.
Additional Resources
- If the connection does not have a default gateway, see Configuring NetworkManager to avoid using a specific profile to provide a default gateway.
6.12. Configuring an Ethernet connection using nm-connection-editor
Ethernet connections are the most frequently used connection types in physical or virtual servers. This section describes how to configure this connection type using the nm-connection-editor
application.
Prerequisites
- A physical or virtual Ethernet device exists in the server’s configuration.
- GNOME is installed.
Procedure
Open a terminal, and enter:
$ nm-connection-editor
- Click the + button to add a new connection.
-
Select the
Ethernet
connection type, and click Create. On the
General
tab:To automatically enable this connection when the system boots or when you restart the
NetworkManager
service:-
Select
Connect automatically with priority
. Optional: Change the priority value next to
Connect automatically with priority
.If multiple connection profiles exist for the same device, NetworkManager enables only one profile. By default, NetworkManager activates the last-used profile that has auto-connect enabled. However, if you set priority values in the profiles, NetworkManager activates the profile with the highest priority.
-
Select
-
Clear the
All users may connect to this network
check box if the profile should be available only to the user that created the connection profile.
-
On the
Ethernet
tab, select a device and, optionally, further Ethernet-related settings. -
On the
IPv4 Settings
tab, configure the IPv4 settings. For example, set a static IPv4 address, network mask, default gateway, and DNS server: -
On the
IPv6 Settings
tab, configure the IPv6 settings. For example, set a static IPv6 address, network mask, default gateway, and DNS server: - Save the connection.
-
Close
nm-connection-editor
.
Verification steps
Use the
ping
utility to verify that this host can send packets to other hosts.Ping an IP address in the same subnet.
For IPv4:
# ping 192.0.2.3
For IPv6:
# ping 2001:db8:1::2
If the command fails, verify the IP and subnet settings.
Ping an IP address in a remote subnet.
For IPv4:
# ping 198.162.3.1
For IPv6:
# ping 2001:db8:2::1
If the command fails, ping the default gateway to verify settings.
For IPv4:
# ping 192.0.2.254
For IPv6:
# ping 2001:db8:1::fff3
Use the
host
utility to verify that name resolution works. For example:# host client.example.com
If the command returns any error, such as
connection timed out
orno servers could be reached
, verify your DNS settings.
Additional Resources
- If the connection does not have a default gateway, see Configuring NetworkManager to avoid using a specific profile to provide a default gateway.
6.13. 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:# dnf 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
6.14. 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
6.15. Configuring multiple Ethernet interfaces 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
- DHCP is available in the network
- The host has multiple Ethernet adapters
- 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 Example connection.multi-connect multiple match.interface-name enp* type ethernet
Verification steps
Display all settings of the single connection profile:
#
nmcli connection show Example
connection.id: Example ... 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 ... Example 6f22402e-c0cc-49cf-b702-eaf0cd5ea7d1 ethernet enp7s0 Example 6f22402e-c0cc-49cf-b702-eaf0cd5ea7d1 ethernet enp8s0 Example 6f22402e-c0cc-49cf-b702-eaf0cd5ea7d1 ethernet enp9s0
Additional resources
-
nmcli(1)
man page -
nm-settings(5)
man page
6.16. 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
- DHCP server is available in the network
- The host has multiple Ethernet adapters
- No connection profile exists on system
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.0Add 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 Example
Verification steps
Display the status of the connection:
#
nmcli connection show
NAME UUID TYPE DEVICE ... Example 9cee0958-512f-4203-9d3d-b57af1d88466 ethernet enp7s0 Example 9cee0958-512f-4203-9d3d-b57af1d88466 ethernet enp8s0 ...To display all settings of the connection profile:
#
nmcli connection show Example
connection.id: Example ... 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 -
nm-settings(5)
man page
Chapter 7. Managing Wi-Fi connections
This section describes how to configure and manage Wi-Fi connections.
7.1. Setting the wireless regulatory domain
In Red Hat Enterprise Linux, the crda package contains the Central Regulatory Domain Agent that provides the kernel with the wireless regulatory rules for a given jurisdiction. It is used by certain udev scripts and should not be run manually unless debugging udev scripts. The kernel runs crda by sending a udev event upon a new regulatory domain change. Regulatory domain changes are triggered by the Linux wireless subsystem (IEEE-802.11). This subsystem uses the regulatory.bin
file to keep its regulatory database information.
The setregdomain
utility sets the regulatory domain for your system. Setregdomain
takes no arguments and is usually called through system script such as udev rather than manually by the administrator. If a country code look-up fails, the system administrator can define the COUNTRY
environment variable in the /etc/sysconfig/regdomain
file.
Additional resources
-
setregdomain(1)
man page -
crda(8)
man page -
regulatory.bin(5)
man page -
iw(8)
man page
7.2. Configuring a Wi-Fi connection using nmcli
This procedure describes how to configure a Wi-fi connection profile using nmcli.
Prerequisites
- The nmcli utility to be installed.
Make sure that the WiFi radio is on (default):
$ nmcli radio wifi on
Procedure
To create a Wi-Fi connection profile with static
IP
configuration:$ nmcli con add con-name MyCafe ifname wlan0 type wifi ssid MyCafe ip4 192.0.2.101/24 gw4 192.0.2.1
Set a DNS server. For example, to set
192.0.2.1
as the DNS server:$ nmcli con modify con-name MyCafe ipv4.dns "192.0.2.1"
Optionally, set a DNS search domain. For example, to set the search domain to
example.com
:$ nmcli con modify con-name MyCafe ipv4.dns-search "example.com"
To check a specific property, for example
mtu
:$ nmcli connection show id MyCafe | grep mtu 802-11-wireless.mtu: auto
To change the property of a setting:
$ nmcli connection modify id MyCafe wireless.mtu 1350
To verify the change:
$ nmcli connection show id MyCafe | grep mtu 802-11-wireless.mtu: 1350
Verification steps
Use the
ping
utility to verify that this host can send packets to other hosts.Ping an IP address in the same subnet. For example:
# ping 192.0.2.103
If the command fails, verify the IP and subnet settings.
Ping an IP address in a remote subnet. For example:
# ping 198.51.16.3
If the command fails, ping the default gateway to verify settings.
# ping 192.0.2.1
Use the
host
utility to verify that name resolution works. For example:# host client.example.com
If the command returns any error, such as
connection timed out
orno servers could be reached
, verify your DNS settings.
Additional resources
-
nm-settings(5)
man page - NetworkManager duplicates a connection after restart of NetworkManager service.
7.3. Configuring a Wi-Fi connection using control-center
When you connect to a Wi-Fi
, the network settings are prefilled depending on the current network connection. This means that the settings will be detected automatically when the interface connects to a network.
This procedure describes how to use control-center to manually configure the Wi-Fi
settings.
Procedure
-
Press the Super key to enter the
Activities Overview
, typeWi-Fi
and press Enter. In the left-hand-side menu entry you see the list of available networks. Select the gear wheel icon to the right of the
Wi-Fi
connection name that you want to edit, and the editing connection dialog appears. The Details menu window shows the connection details where you can make further configuration.Options
-
If you select
Connect automatically
, NetworkManager auto-connects to this connection whenever NetworkManager detects that it is available. If you do not want NetworkManager to connect automatically, clear the check box. Note that when the check box is clear, you have to select that connection manually in the network connection icon’s menu to cause it to connect. -
To make a connection available to other users, select the
Make available to other users
check box. You can also control the background data usage by changing the
Restrict background data usage
option.NoteTo delete a
Wi-Fi
connection, click theForget Connection
red box.
-
If you select
Select the Identity menu entry to see the basic configuration options.
SSID
— The Service Set Identifier (SSID) of the access point (AP).BSSID
— The Basic Service Set Identifier (BSSID) is the MAC address, also known as a hardware address, of the specific wireless access point you are connecting to when inInfrastructure
mode. This field is blank by default, and you are able to connect to a wireless access point bySSID
without having to specify itsBSSID
. If the BSSID is specified, it will force the system to associate to a specific access point only. For ad-hoc networks, theBSSID
is generated randomly by the mac80211 subsystem when the ad-hoc network is created. It is not displayed by NetworkManager.MAC address
— The MAC address allows you to associate a specific wireless adapter with a specific connection (or connections).Cloned Address
— A cloned MAC address to use in place of the real hardware address. Leave blank unless required.For further IP address configuration , select the IPv4 and IPv6 menu entries.
By default, both
IPv4
andIPv6
are set to automatic configuration depending on current network settings. This means that addresses such as the local IP address, DNS address, and other settings will be detected automatically when the interface connects to a network. If a DHCP server assigns the IP configuration in this network, this is sufficient, but you can also provide static configuration in theIPv4
andIPv6
Settings. In the IPv4 and IPv6 menu entries, you can see the following settings:IPv4 Method
-
Automatic (DHCP)
— Choose this option if the network you are connecting to uses Router Advertisements (RA) or aDHCP
server to assign dynamic IP addresses. You can see the assigned IP address in the Details menu entry. -
Link-Local Only
— Choose this option if the network you are connecting to does not have aDHCP
server and you do not want to assign IP addresses manually. Random addresses will be assigned as per RFC 3927 with prefix169.254/16
. -
Manual
— Choose this option if you want to assign IP addresses manually. -
Disable
—IPv4
is disabled for this connection.
-
DNS
If
Automatic
isON
, and no DHCP server is available that assigns DNS servers to this connection, switch it toOFF
to enter the IP address of a DNS server separating the IPs by comma.Routes
Note that in the
Routes
section, whenAutomatic
isON
, routes from Router Advertisements (RA) or 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, sub-net, or host. -
Netmask
— The netmask or prefix length of the IP address entered above. -
Gateway
— The IP address of the gateway leading to the remote network, sub-net, 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.
Alternatively, to configure
IPv6
settings in aWi-Fi
connection, select the IPv6 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 assign IP addresses manually. Random addresses will be assigned as per RFC 4862 with prefixFE80::0
. -
Manual
— Choose this option if you want to assign IP addresses manually. -
Disable
—IPv6
is disabled for this connection.
-
-
The
DNS
,Routes
,Use this connection only for resources on its network
fields are common toIPv4
settings.
To configure
Security
settings in aWi-Fi
connection, select the Security menu entry.WarningDo not connect to Wi-Fi networks without encryption or which support only the insecure WEP or WPA standards.
The following configuration options are available:
Security
-
None
— Encryption is disabled, and data is transferred in plain text over the network. -
WEP 40/128-bit Key
— Wired Equivalent Privacy (WEP), from the IEEE 802.11 standard. Uses a single pre-shared key (PSK). -
WEP 128-bit Passphrase
— An MD5 hash of the passphrase to derive a WEP key. -
Dynamic WEP (802.1X)
— WEP keys are changed dynamically. -
LEAP
— Lightweight Extensible Authentication Protocol, from Cisco Systems. -
WPA & WPA2 Personal
— Wi-Fi Protected Access (WPA), from the draft IEEE 802.11i standard. Wi-Fi Protected Access 2 (WPA2), from the 802.11i-2004 standard. Personal mode uses a pre-shared key (WPA-PSK). -
WPA & WPA2 Enterprise
— WPA and WPA 2 for use with a RADIUS authentication server to provide IEEE 802.1X network access control. -
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.
-
- Password — Enter the password to be used in the authentication process.
- Once you have finished the configuration, click the Apply button to save it.
When you add a new connection by clicking the plus button, 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.
7.4. Connecting to a Wi-Fi network with nmcli
This procedure describes how to connect to a wireless
connection using the nmcli utility.
Prerequisites
- The nmcli utility to be installed.
Make sure that the WiFi radio is on (default):
$ nmcli radio wifi on
Procedure
To refresh the available Wi-Fi connection list:
$ nmcli device wifi rescan
To view the available Wi-Fi access points:
$ nmcli dev wifi list IN-USE SSID MODE CHAN RATE SIGNAL BARS SECURITY ... MyCafe Infra 3 405 Mbit/s 85 ▂▄▆█ WPA1 WPA2
To connect to a Wi-Fi connection using nmcli:
$ nmcli dev wifi connect SSID-Name password wireless-password
For example:
$ nmcli dev wifi connect MyCafe password wireless-password
Note that if you want to disable the Wi-Fi state:
$ nmcli radio wifi off
7.5. Connecting to a hidden Wi-Fi network using nmcli
All access points have a Service Set Identifier (SSID) to identify them. However, an access point may be configured not to broadcast its SSID, in which case it is hidden, and will not show up in NetworkManager’s list of Available networks.
This procedure shows how you can connect to a hidden network using the nmcli tool.
Prerequisites
- The nmcli utility to be installed.
-
To know the SSID, and password of the
Wi-Fi
connection. Make sure that the WiFi radio is on (default):
$ nmcli radio wifi on
Procedure
Connect to the SSID that is hidden:
$ nmcli dev wifi connect SSID_Name password wireless_password hidden yes
7.6. Connecting to a Wi-Fi network using the GNOME GUI
This procedure describes how you can connect to a wireless network to get access to the Internet.
Procedure
- Open the GNOME Shell network connection icon menu from the top right-hand corner of the screen.
-
Select
Wi-Fi Not Connected
. -
Click the
Select Network
option. Click the name of the network to which you want to connect, and then click
Connect
.Note that if you do not see the network, the network might be hidden.
If the network is protected by a password or encryption keys are required, enter the password and click
Connect
.Note that if you do not know the password, contact the administrator of the Wi-Fi network.
- If the connection is successful, the name of the network is visible in the connection icon menu and the wireless indicator is on the top right-hand corner of the screen.
Additional resources
7.7. Configuring 802.1X network authentication on an existing Wi-Fi connection using nmcli
Using the nmcli
utility, you can configure the client to authenticate itself to the network. This procedure describes how to configure Protected Extensible Authentication Protocol (PEAP) authentication with the Microsoft Challenge-Handshake Authentication Protocol version 2 (MSCHAPv2) in an existing NetworkManager Wi-Fi connection profile named wlp1s0
.
Prerequisites
- The network must have 802.1X network authentication.
- The Wi-Fi 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 Wi-Fi 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.Optionally, store the password in the configuration:
# nmcli connection modify wlp1s0 802-1x.password password
ImportantBy default, NetworkManager stores the password in clear text in the
/etc/sysconfig/network-scripts/keys-connection_name
file, that is readable only by theroot
user. However, clear 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 is required 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, Red Hat recommends using the certificate of the authenticator to enable clients to validate the identity of the authenticator.
Activate the connection profile:
# nmcli connection up wlp1s0
Verification steps
- Access resources on the network that require network authentication.
Additional resources
- Managing Wi-Fi connections
-
The
802-1x settings
section in thenm-settings(5)
man page -
nmcli(1)
man page
Chapter 8. Configuring VLAN tagging
This section describes how to configure Virtual Local Area Network (VLAN). A 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 a VLAN interface on top of another interface, such as an Ethernet, bond, team, or bridge device. This interface is called the parent interface
.
8.1. Configuring VLAN tagging using nmcli commands
This section describes how to configure Virtual Local Area Network (VLAN) tagging 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 IP settings of the VLAN device. Skip this step if you want to use this VLAN device as a port of other devices.
Configure the IPv4 settings. For example, 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' # nmcli connection modify vlan10 ipv4.gateway '192.0.2.254' # nmcli connection modify vlan10 ipv4.dns '192.0.2.253' # nmcli connection modify vlan10 ipv4.method manual
Configure the IPv6 settings. For example, 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' # nmcli connection modify vlan10 ipv6.gateway '2001:db8:1::fffe' # nmcli connection modify vlan10 ipv6.dns '2001:db8:1::fffd' # nmcli connection modify vlan10 ipv6.method manual
Activate the connection:
# nmcli connection up vlan10
Verification steps
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
- Testing basic network settings.
- Configuring NetworkManager to avoid using a specific profile to provide a default gateway.
-
nmcli-examples(7)
man page -
The
vlan setting
section in thenm-settings(5)
man page
8.2. Configuring VLAN tagging using the RHEL web console
This section explains how to configure a network bridge using 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.
Procedure
-
Select the
Networking
tab in the navigation on the left side of the screen. -
Click Add VLAN in the
Interfaces
section. - Select the parent device.
- Enter the VLAN ID.
Enter the name of the VLAN device or keep the automatically-generated name.
- Click Apply.
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 Apply
-
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:
8.3. Configuring VLAN tagging using nm-connection-editor
This section describes how to configure Virtual Local Area Network (VLAN) tagging 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 Create. On the
VLAN
tab:- Select the parent interface.
-
Select the VLAN id. 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.
Optionally, set the name of the VLAN interface and further VLAN-specific options.
Configure the IP settings of the VLAN device. Skip this step if you want to use this VLAN device as a port of other devices.
-
On the
IPv4 Settings
tab, configure the IPv4 settings. For example, set a static IPv4 address, network mask, default gateway, and DNS server: -
On the
IPv6 Settings
tab, configure the IPv6 settings. For example, set a static IPv6 address, network mask, default gateway, and DNS server:
-
On the
- Click Save to save the VLAN connection.
-
Close
nm-connection-editor
.
Verification steps
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
8.4. Configuring VLAN tagging using nmstatectl
This section describes how to use the nmstatectl
utility to configure a VLAN with ID 10 that uses an Ethernet connection. As the child device, the VLAN connection contains the IP, default gateway, and DNS configurations.
Depending on your environment, adjust the YAML file accordingly. For example, to use a bridge, or bond device 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 contents:--- 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
Apply the settings to the system:
# nmstatectl apply ~/create-vlan.yml
Verification steps
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 -
/usr/share/doc/nmstate/examples/
8.5. Configuring VLAN tagging using RHEL System Role
You can use the Networking RHEL System Role to configure VLAN tagging. This procedure describes how to add an Ethernet connection and a VLAN with ID 10
on top of this Ethernet connection. As the child device, the VLAN connection contains the IP, default gateway, and DNS configurations.
Depending on your environment, adjust the play accordingly. For example:
-
To use the VLAN as a port in other connections, such as a bond, omit the
ip
attribute, and set the IP configuration in the child configuration. -
To use team, bridge, or bond devices in the VLAN, adapt the
interface_name
andtype
attributes of the ports you use in the VLAN.
Prerequisites
-
The
ansible-core
andrhel-system-roles
packages are installed on the control node. -
If you use a different remote user than
root
when you run the playbook, this user has appropriatesudo
permissions on the managed node.
Procedure
If the host on which you want to execute the instructions in the playbook is not yet inventoried, add the IP or name of this host to the
/etc/ansible/hosts
Ansible inventory file:node.example.com
Create the
~/vlan-ethernet.yml
playbook with the following content:--- - name: Configure a VLAN that uses an Ethernet connection hosts: node.example.com become: true tasks: - include_role: name: rhel-system-roles.network vars: network_connections: # Add an Ethernet profile for the underlying device of the VLAN - name: enp1s0 type: ethernet interface_name: enp1s0 autoconnect: yes state: up ip: dhcp4: no auto6: no # Define the VLAN profile - name: enp1s0.10 type: vlan 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 vlan_id: 10 parent: enp1s0 state: up
The
parent
attribute in the VLAN profile configures the VLAN to operate on top of theenp1s0
device.Run the playbook:
To connect as
root
user to the managed host, enter:# ansible-playbook -u root ~/vlan-ethernet.yml
To connect as a user to the managed host, enter:
# ansible-playbook -u user_name --ask-become-pass ~/vlan-ethernet.yml
The
--ask-become-pass
option makes sure that theansible-playbook
command prompts for thesudo
password of the user defined in the-u user_name
option.
If you do not specify the
-u user_name
option,ansible-playbook
connects to the managed host as the user that is currently logged in to the control node.
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
ansible-playbook(1)
man page
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.
This documentation describes how to configure a VXLAN on RHEL hosts, which is invisible to the VMs:

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 hosts.
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)
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)
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
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)
man page -
virt-xml(1)
man page -
virsh(1)
man page -
arping(8)
man page
Chapter 10. 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.
10.1. Configuring a network bridge using nmcli commands
This section explains how to configure a network bridge using 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.
Configure the IP settings of the bridge. Skip this step if you want to use this bridge as a ports of other devices.
Configure the IPv4 settings. For example, to set a static IPv4 address, network mask, default gateway, DNS server, and DNS search domain of the
bridge0
connection, enter:# nmcli connection modify bridge0 ipv4.addresses '192.0.2.1/24' # nmcli connection modify bridge0 ipv4.gateway '192.0.2.254' # nmcli connection modify bridge0 ipv4.dns '192.0.2.253' # nmcli connection modify bridge0 ipv4.dns-search 'example.com' # nmcli connection modify bridge0 ipv4.method manual
Configure the IPv6 settings. For example, to set a static IPv6 address, network mask, default gateway, DNS server, and DNS search domain of the
bridge0
connection, enter:# nmcli connection modify bridge0 ipv6.addresses '2001:db8:1::1/64' # nmcli connection modify bridge0 ipv6.gateway '2001:db8:1::fffe' # nmcli connection modify bridge0 ipv6.dns '2001:db8:1::fffd' # nmcli connection modify bridge0 ipv6.dns-search 'example.com' # nmcli connection modify bridge0 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 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 steps
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
- Testing basic network settings
- Configuring NetworkManager to avoid using a specific profile to provide a default gateway
-
nmcli-examples(7)
man page -
The
bridge settings
section in thenm-settings(5)
man page -
The
bridge-port settings
section in thenm-settings(5)
man page -
bridge(8)
man page - NetworkManager duplicates a connection after restart of NetworkManager service
- How to configure bridge with vlan information?
10.2. Configuring a network bridge using the RHEL web console
This section explains how to configure a network bridge using the RHEL web console.
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
-
Select the
Networking
tab in the navigation on the left side of the screen. -
Click Add bridge in the
Interfaces
section. - 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 Apply.
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 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 Apply
-
Click the name of the bridge 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:
10.3. Configuring a network bridge using nm-connection-editor
This section explains how to configure a network bridge 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 using nmcli commands.
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 Create. In the
Bridge
tab:-
Optional: Set the name of the bridge interface in the
Interface name
field. Click the Add 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. - Optionally, 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 theDevice
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 Save.
-
Select the connection type of the interface. For example, select
Repeat the previous step for each interface you want to add to the bridge.
-
Optional: Set the name of the bridge interface in the
- Optional: Configure further bridge settings, such as Spanning Tree Protocol (STP) options.
Configure the IP settings of the bridge. Skip this step if you want to use this bridge as a port of other devices.
In the
IPv4 Settings
tab, configure the IPv4 settings. For example, set a static IPv4 address, network mask, default gateway, DNS server, and DNS search domain:In the
IPv6 Settings
tab, configure the IPv6 settings. For example, set a static IPv6 address, network mask, default gateway, DNS server, and DNS search domain:
- Save the bridge connection.
-
Close
nm-connection-editor
.
Verification steps
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 using nm-connection-editor
- Configuring a network team using nm-connection-editor
- Configuring VLAN tagging using nm-connection-editor
- Testing basic network settings
- Configuring NetworkManager to avoid using a specific profile to provide a default gateway
- How to configure bridge with vlan information?
10.4. Configuring a network bridge using nmstatectl
This section describes how to use the nmstatectl
utility to configure a Linux network bridge bridge0
with 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
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 contents:--- 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
Apply the settings to the system:
# nmstatectl apply ~/create-bridge.yml
Verification steps
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 -
/usr/share/doc/nmstate/examples/
- How to configure bridge with vlan information?
Chapter 11. Configuring network teaming
This section describes the basics of network teaming, the differences between bonding and teaming, and how to configure a network team on Red Hat Enterprise Linux.
Network teaming is deprecated in Red Hat Enterprise Linux 9. Consider using the network bonding driver as an alternative. For details, see Configuring network bonding.
You can create network teams on different types of devices, such as:
- Physical and virtual Ethernet devices
- Network bonds
- Network bridges
- VLAN devices
11.1. Migrating a network team configuration to network bond
Network teaming is deprecated in Red Hat Enterprise Linux 9. If you already have a working network team configured, for example because you upgraded from an earlier RHEL version, you can migrate the configuration to a network bond that is managed by NetworkManager.
The team2bond
utility only converts the network team configuration to a bond. Afterwards, you must manually configure further settings of the bond, such as IP addresses and DNS configuration.
Prerequisites
-
The
team-team0
NetworkManager connection profile is configured and manages theteam0
device. -
The
teamd
package is installed.
Procedure
Optional: Display the IP configuration of the
team-team0
NetworkManager connection:# nmcli connection show team-team0 | egrep "^ip" ... ipv4.method: manual ipv4.dns: 192.0.2.253 ipv4.dns-search: example.com ipv4.addresses: 192.0.2.1/24 ipv4.gateway: 192.0.2.254 ... ipv6.method: manual ipv6.dns: 2001:db8:1::fffd ipv6.dns-search: example.com ipv6.addresses: 2001:db8:1::1/64 ipv6.gateway: 2001:db8:1::fffe ...
Export the configuration of the
team0
device to a JSON file:# teamdctl team0 config dump actual > /tmp/team0.json
Remove the network team. For example, if you configured the team in NetworkManager, remove the
team-team0
connection profile and the profiles of associated ports:# nmcli connection delete team-team0 # nmcli connection delete team-team0-port1 # nmcli connection delete team-team0-port2
Run the
team2bond
utility in dry-run mode to displaynmcli
commands that set up a network bond with similar settings as the team device:# team2bond --config=/tmp/team0.json --rename=bond0 nmcli con add type bond ifname bond0 bond.options "mode=active-backup,num_grat_arp=1,num_unsol_na=1,resend_igmp=1,miimon=100,miimon=100" nmcli con add type ethernet ifname enp7s0 master bond0 nmcli con add type ethernet ifname enp8s0 master bond0
The first command contains two
miimon
options because the team configuration file contained twolink_watch
entries. Note that this does not affect the creation of the bond.If you bound services to the device name of the team and want to avoid updating or breaking these services, omit the
--rename=bond0
option. In this case,team2bond
uses the same interface name for the bond as for the team.-
Verify that the options for the bond the
team2bond
utility suggested are correct. Create the bond. You can execute the suggested
nmcli
commands or re-run theteam2bond
command with the--exec-cmd
option:# team2bond --config=/tmp/team0.json --rename=bond0 --exec-cmd Connection 'bond-bond0' (0241a531-0c72-4202-80df-73eadfc126b5) successfully added. Connection 'bond-slave-enp7s0' (38489729-b624-4606-a784-1ccf01e2f6d6) successfully added. Connection 'bond-slave-enp8s0' (de97ec06-7daa-4298-9a71-9d4c7909daa1) successfully added.
You require the name of the bond connection profile (
bond-bond0
) in the next steps.Set the IPv4 settings that were previously configured on
team-team0
to thebond-bond0
connection:# nmcli connection modify bond-bond0 ipv4.addresses '192.0.2.1/24' # nmcli connection modify bond-bond0 ipv4.gateway '192.0.2.254' # nmcli connection modify bond-bond0 ipv4.dns '192.0.2.253' # nmcli connection modify bond-bond0 ipv4.dns-search 'example.com' # nmcli connection modify bond-bond0 ipv4.method manual
Set the IPv6 settings that were previously configured on
team-team0
to thebond-bond0
connection:# nmcli connection modify bond-bond0 ipv6.addresses '2001:db8:1::1/64' # nmcli connection modify bond-bond0 ipv6.gateway '2001:db8:1::fffe' # nmcli connection modify bond-bond0 ipv6.dns '2001:db8:1::fffd' # nmcli connection modify bond-bond0 ipv6.dns-search 'example.com' # nmcli connection modify bond-bond0 ipv6.method manual
Activate the connection:
# nmcli connection up bond-bond0
Verification
Display the IP configuration of the
bond-bond0
NetworkManager connection:# nmcli connection show bond-bond0 | egrep "^ip" ... ipv4.method: manual ipv4.dns: 192.0.2.253 ipv4.dns-search: example.com ipv4.addresses: 192.0.2.1/24 ipv4.gateway: 192.0.2.254 ... ipv6.method: manual ipv6.dns: 2001:db8:1::fffd ipv6.dns-search: example.com ipv6.addresses: 2001:db8:1::1/64 ipv6.gateway: 2001:db8:1::fffe ...
Display the status of the bond:
# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v5.13.0-0.rc7.51.el9.x86_64 Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: enp7s0 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Peer Notification Delay (ms): 0 Slave Interface: enp7s0 MII Status: up Speed: Unknown Duplex: Unknown Link Failure Count: 0 Permanent HW addr: 52:54:00:bf:b1:a9 Slave queue ID: 0 Slave Interface: enp8s0 MII Status: up Speed: Unknown Duplex: Unknown Link Failure Count: 0 Permanent HW addr: 52:54:00:04:36:0f Slave queue ID: 0
In this example, both ports are up.
To verify that bonding failover works:
- Temporarily remove the network cable from the host. Note that there is no method to properly test link failure events using the command line.
Display the status of the bond:
# cat /proc/net/bonding/bond0
11.2. Understanding network teaming
Network teaming is a feature that combines or aggregates network interfaces to provide a logical interface with higher throughput or redundancy.
Network teaming uses a kernel driver to implement fast handling of packet flows, as well as user-space libraries and services for other tasks. This way, network teaming is an easily extensible and scalable solution for load-balancing and redundancy requirements.
Certain network teaming features, such as the fail-over mechanism, do not support direct cable connections without a network switch. For further details, see Is bonding supported with direct connection using crossover cables?
11.3. Understanding the default behavior of controller and port interfaces
Consider the following default behavior of, 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.
11.4. 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.
11.5. Installing the teamd service
To configure a network team in NetworkManager
, you require the teamd
service and the team plug-in for NetworkManager
. Both are installed on Red Hat Enterprise Linux by default. This section describes how you install the required packages in case that you remove them.
Prerequisites
- An active Red Hat subscription is assigned to the host.
Procedure
Install the
teamd
andNetworkManager-team
packages:# dnf install teamd NetworkManager-team
11.6. Configuring a network team using nmcli commands
This section describes how to configure a network team using nmcli
utility.
Network teaming is deprecated in Red Hat Enterprise Linux 9. Consider using the network bonding driver as an alternative. For details, see Configuring network bonding.
Prerequisites
- 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 network team named
team0
that uses theactivebackup
runner.Optionally, 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 quotes. 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.
Configure the IP settings of the team. Skip this step if you want to use this team as a ports of other devices.
Configure the IPv4 settings. For example, to set a static IPv4 address, network mask, default gateway, DNS server, and DNS search domain the
team0
connection, enter:# nmcli connection modify team0 ipv4.addresses '192.0.2.1/24' # nmcli connection modify team0 ipv4.gateway '192.0.2.254' # nmcli connection modify team0 ipv4.dns '192.0.2.253' # nmcli connection modify team0 ipv4.dns-search 'example.com' # nmcli connection modify team0 ipv4.method manual
Configure the IPv6 settings. For example, to set a static IPv6 address, network mask, default gateway, DNS server, and DNS search domain of the
team0
connection, enter:# nmcli connection modify team0 ipv6.addresses '2001:db8:1::1/64' # nmcli connection modify team0 ipv6.gateway '2001:db8:1::fffe' # nmcli connection modify team0 ipv6.dns '2001:db8:1::fffd' # nmcli connection modify team0 ipv6.dns-search 'example.com' # nmcli connection modify team0 ipv6.method manual
Activate the connection:
# nmcli connection up team0
Verification steps
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
- Testing basic network settings
- Configuring NetworkManager to avoid using a specific profile to provide a default gateway
- Understanding the teamd service, runners, and link-watchers
-
nmcli-examples(7)
man page -
The
team
section in thenm-settings(5)
man page -
teamd.conf(5)
man page
11.7. Configuring a network team using the RHEL web console
This section describes how to configure a network team using the RHEL web console.
Network teaming is deprecated in Red Hat Enterprise Linux 9. Consider using the network bonding driver as an alternative. For details, see Configuring network bonding.
Prerequisites
- 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:
Procedure
-
Select the
Networking
tab in the navigation on the left side of the screen. -
Click Add team in the
Interfaces
section. - 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 Apply.
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 Apply
-
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
11.8. Configuring a network team using nm-connection-editor
This section describes how you configure a network team 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 network team using nmcli commands.
Network teaming is deprecated in Red Hat Enterprise Linux 9. Consider using the network bonding driver as an alternative. For details, see Configuring network bonding.
Prerequisites
- 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 Create. In the
Team
tab:-
Optional: Set the name of the team interface in the
Interface name
field. Click the Add 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 theDevice
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 Save.
-
Select the connection type of the interface. For example, select
Repeat the previous step for each interface you want to add to the team.
Click the Advanced button to set advanced options to the team connection.
-
In the
Runner
tab, select the runner. -
In the
Link Watcher
tab, set the link watcher and its optional settings. - Click OK.
-
In the
-
Optional: Set the name of the team interface in the
Configure the IP settings of the team. Skip this step if you want to use this team as a port of other devices.
-
In the
IPv4 Settings
tab, configure the IPv4 settings. For example, set a static IPv4 address, network mask, default gateway, DNS server, and DNS search domain: -
In the
IPv6 Settings
tab, configure the IPv6 settings. For example, set a static IPv6 address, network mask, default gateway, DNS server, and DNS search domain:
-
In the
- Save the team connection.
-
Close
nm-connection-editor
.
Verification steps
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 using nm-connection-editor
- Configuring a network team using nm-connection-editor
- Configuring VLAN tagging using nm-connection-editor
- Testing basic network settings
- 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
Chapter 12. Configuring network bonding
This section describes the basics of network bonding, the differences between bonding and teaming, and how to configure a network bond on Red Hat Enterprise Linux.
You can create bonds on different types of devices, such as:
- Physical and virtual Ethernet devices
- Network bridges
- Network teams
- VLAN devices
12.1. Understanding network bonding
Network bonding is a method to combine or aggregate network interfaces to provide a logical interface with higher throughput or redundancy.
The active-backup
, balance-tlb
, and balance-alb
modes do not require any specific configuration of the network switch. However, other bonding modes require configuring the switch to aggregate the links. For example, Cisco switches requires EtherChannel
for modes 0, 2, and 3, but for mode 4, the Link Aggregation Control Protocol (LACP) and EtherChannel
are required.
For further details, see the documentation of your switch and Linux Ethernet Bonding Driver HOWTO.
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.
12.2. Understanding the default behavior of controller and port interfaces
Consider the following default behavior of, 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.
12.3. Upstream Switch Configuration Depending on the Bonding Modes
The following table describes which settings you must apply to the upstream switch depending on the bonding mode:
Bonding mode | Configuration on the switch |
---|---|
| Requires static Etherchannel enabled (not LACP-negotiated) |
| Requires autonomous ports |
| Requires static Etherchannel enabled (not LACP-negotiated) |
| Requires static Etherchannel enabled (not LACP-negotiated) |
| Requires LACP-negotiated Etherchannel enabled |
| Requires autonomous ports |
| Requires autonomous ports |
For configuring these settings on your switch, see the switch documentation.
12.4. Configuring a network bond using nmcli commands
This section describes how to configure a network bond using nmcli
commands.
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, to use the same command but, additionally, set the MII monitoring interval to1000
milliseconds (1 second), enter:# 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.
Configure the IP settings of the bond. Skip this step if you want to use this bond as a port of other devices.
Configure the IPv4 settings. For example, to set a static IPv4 address, network mask, default gateway, DNS server, and DNS search domain to the
bond0
connection, enter:# 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. For example, to set a static IPv6 address, network mask, default gateway, DNS server, and DNS search domain to the
bond0
connection, enter:# 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
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 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 steps
Temporarily remove the network cable from the host.
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
Additional resources
12.5. Configuring a network bond using the RHEL web console
This section describes how to configure a network bond using the RHEL web console.
Prerequisites
- You are logged in to the RHEL web console.
- 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:
Procedure
-
Select the
Networking
tab in the navigation on the left side of the screen. -
Click Add bond in the
Interfaces
section. - 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 fieldPrimary
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 toARP
. Optional: Adjust the monitoring interval, link up delay, and link down delay settings. Typically, you only change the defaults for troubleshooting purposes.
- Click Apply.
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 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 Apply
-
Click the name of the bond 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:Temporarily remove the network cable from the host.
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
12.6. Configuring a network bond using nm-connection-editor
This section describes how to configure a network bond 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 using the nmcli
utility as described in Configuring a network bond using nmcli commands.
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 Create. In the
Bond
tab:-
Optional: Set the name of the bond interface in the
Interface name
field. Click the Add 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 theDevice
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 Save.
-
Select the connection type of the interface. For example, select
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.
-
Optional: Set the name of the bond interface in the
Configure the IP settings of the bond. Skip this step if you want to use this bond as a port of other devices.
In the
IPv4 Settings
tab, configure the IPv4 settings. For example, set a static IPv4 address, network mask, default gateway, DNS server, and DNS search domain:In the
IPv6 Settings
tab, configure the IPv6 settings. For example, set a static IPv6 address, network mask, default gateway, DNS server, and DNS search domain:
- Click Save to save the bond connection.
-
Close
nm-connection-editor
.
Verification steps
Temporarily remove the network cable from the host.
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
Additional resources
12.7. Configuring a network bond using nmstatectl
This section describes how to use the nmstatectl
utility to configure a network bond, bond0
, 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
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 contents:--- 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
Apply the settings to the system:
# nmstatectl apply ~/create-bond.yml
Verification steps
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 -
/usr/share/doc/nmstate/examples/
12.8. Configuring a network bond using RHEL System Roles
You can use the Networking RHEL System Role to configure a network bond. This procedure describes how to configure a bond in active-backup mode that uses two Ethernet devices, and sets an IPv4 and IPv6 addresses, default gateways, and DNS configuration.
Set the IP configuration on the bond and not on the ports of the Linux bond.
Prerequisites
-
The
ansible-core
package andrhel-system-roles
packages are installed on the control node. -
If you use a different remote user than
root
when you run the playbook, this user has appropriatesudo
permissions on the managed node. - Two or more physical or virtual network devices are installed on the server.
Procedure
If the host on which you want to execute the instructions in the playbook is not yet inventoried, add the IP or name of this host to the
/etc/ansible/hosts
Ansible inventory file:node.example.com
Create the
~/bond-ethernet.yml
playbook with the following content:--- - name: Configure a network bond that uses two Ethernet ports hosts: node.example.com become: true tasks: - include_role: name: rhel-system-roles.network vars: network_connections: # Define the bond profile - name: bond0 type: bond interface_name: bond0 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 bond: mode: active-backup state: up # Add an Ethernet profile to the bond - name: bond0-port1 interface_name: enp7s0 type: ethernet controller: bond0 state: up # Add a second Ethernet profile to the bond - name: bond0-port2 interface_name: enp8s0 type: ethernet controller: bond0 state: up
Run the playbook:
To connect as
root
user to the managed host, enter:# ansible-playbook -u root ~/bond-ethernet.yml
To connect as a user to the managed host, enter:
# ansible-playbook -u user_name --ask-become-pass ~/bond-ethernet.yml
The
--ask-become-pass
option makes sure that theansible-playbook
command prompts for thesudo
password of the user defined in the-u user_name
option.
If you do not specify the
-u user_name
option,ansible-playbook
connects to the managed host as the user that is currently logged in to the control node.
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
ansible-playbook(1)
man page
12.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 steps
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
Chapter 13. Setting up a WireGuard VPN
WireGuard is a high-performance VPN solution that runs in the Linux kernel. It uses modern cryptography and is easier to configure than many other VPN solutions. Additionally, WireGuard’s small codebase reduces the surface for attacks and, therefore, improves security. For authentication and encryption, WireGuard uses keys similar to SSH.
WireGuard is provided as a Technology Preview only. Technology Preview features are not supported with Red Hat production Service Level Agreements (SLAs), might not be functionally complete, and Red Hat does not recommend using them for production. These previews provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
See Technology Preview Features Support Scope on the Red Hat Customer Portal for information about the support scope for Technology Preview features.
To set up a WireGuard VPN, you must complete the following steps. You can perform each step by using different options:
- Create public and private keys for every host in the VPN.
- Configure the WireGuard server by using nmcli, nmtui, nm-connection-editor, or the wg-quick service.
- Configure firewalld on the WireGuard server by using the command line or graphical interface.
- Configure the WireGuard client by using nmcli, nm-connection-editor, or the wg-quick service.
WireGuard operates on the network layer (layer 3). Therefore, you cannot use DHCP and must assign static IP addresses or IPv6 link-local addresses to the tunnel devices on both the server and clients.
You can use WireGuard only if the Federal Information Processing Standard (FIPS) mode in RHEL is disabled.
Note that all hosts that participate in a WireGuard VPN are peers. This documentation uses the terms client
to describe hosts that establish a connection and server
to describe the host with the fixed hostname or IP address that the clients connect to and optionally route all traffic through this server.
13.1. Protocols and primitives used by WireGuard
WireGuard uses the following protocols and primitives:
- ChaCha20 for symmetric encryption, authenticated with Poly1305, using Authenticated Encryption with Associated Data (AEAD) construction as described in RFC7539
- Curve25519 for Elliptic-curve Diffie–Hellman (ECDH) key exchange
- BLAKE2s for hashing and keyed hashing, as described in RFC7693
- SipHash24 for hash table keys
- HKDF for key derivation, as described in RFC5869
13.2. How WireGuard uses tunnel IP addresses, public keys, and remote endpoints
When WireGuard sends a network packet to a peer:
- WireGuard reads the destination IP from the packet and compares it to the list of allowed IP addresses in the local configuration. If the peer is not found, WireGuard drops the packet.
- If the peer is valid, WireGuard encrypts the packet using the peer’s public key.
- The sending host looks up the most recent Internet IP address of the host and sends the encrypted packet to it.
When WireGuard receives a packet:
- WireGuard decrypts the packet using private key of the remote host.
- WireGuard reads the internal source address from the packet and looks up whether the IP is configured in the list of allowed IP addresses in the settings for the peer on the local host. If the source IP is on the allowlist, WireGuard accepts the packet. If the IP address is not on the list, WireGuard drops the packet.
The association of public keys and allowed IP addresses is called Cryptokey Routing Table
. This means that the list of IP addresses behaves similar to a routing table when sending packets, and as a kind of access control list when receiving packets.
13.3. Using a WireGuard client behind NAT and firewalls
WireGuard uses the UDP protocol and transmits data only when a peer sends packets. Stateful firewalls and network address translation (NAT) on routers track connections to enable a peer behind NAT or a firewall to receive packets.
To keep the connection active, WireGuard supports persistent keepalives
. This means you can set an interval at which WireGuard sends keepalive packets. By default, the persistent keep-alive feature is disabled to reduce network traffic. Enable this feature on the client if you use the client in a network with NAT or if a firewall closes the connection after some time of inactivity.
13.4. Creating private and public keys to be used in WireGuard connections
WireGuard uses base64-encoded private and public keys to authenticate hosts to each other. Therefore, you must create the keys on each host that participates in the WireGuard VPN.
For secure connections, create different keys for each host, and ensure that you only share the public key with the remote WireGuard host. Do not use the example keys used in this documentation.
Procedure
Install the
wireguard-tools
package:#
dnf install wireguard-tools
Create a private key and a corresponding public key for the host:
#
wg genkey | tee /etc/wireguard/$HOSTNAME.private.key | wg pubkey > /etc/wireguard/$HOSTNAME.public.key
You will need the content of the key files, but not the files themselves. However, Red Hat recommends keeping the files in case that you need to remember the keys in future.
Set secure permissions on the key files:
#
chmod 600 /etc/wireguard/$HOSTNAME.private.key /etc/wireguard/$HOSTNAME.public.key
Display the private key:
#
cat /etc/wireguard/$HOSTNAME.private.key
YFAnE0psgIdiAF7XR4abxiwVRnlMfeltxu10s/c4JXg=You will need the private key to configure the WireGuard connection on the local host. Do not share the private key.
Display the public key:
#
cat /etc/wireguard/$HOSTNAME.public.key
UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE=You will need the public key to configure the WireGuard connection on the remote host.
Additional resources
-
The
wg(8)
man page
13.5. Configuring a WireGuard server using nmcli
You can configure the WireGuard server by creating a connection profile in NetworkManager. Use this method to let NetworkManager manage the WireGuard connection.
This procedure assumes the following settings:
Server:
-
Private key:
YFAnE0psgIdiAF7XR4abxiwVRnlMfeltxu10s/c4JXg=
-
Tunnel IPv4 address:
192.0.2.1/24
-
Tunnel IPv6 address:
2001:db8:1::1/32
-
Private key:
Client:
-
Public key:
bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM=
-
Tunnel IPv4 address:
192.0.2.2/24
-
Tunnel IPv6 address:
2001:db8:1::2/32
-
Public key:
Prerequisites
- You have generated the public and private key for both the server and client.
You know the following information:
- The private key of the server
- The static tunnel IP addresses and subnet masks of the client
- The public key of the client
- The static tunnel IP addresses and subnet masks of the server
Procedure
Add a NetworkManager WireGuard connection profile:
#
nmcli connection add type wireguard con-name server-wg0 ifname wg0 autoconnect no
This command creates a profile named
server-wg0
and assigns the virtual interfacewg0
to it. To prevent the connection from starting automatically after you add it without finalizing the configuration, disable theautoconnect
parameter.Set the tunnel IPv4 address and subnet mask of the server:
#
nmcli connection modify server-wg0 ipv4.method manual ipv4.addresses 192.0.2.1/24
Set the tunnel IPv6 address and subnet mask of the server:
#
nmcli connection modify server-wg0 ipv6.method manual ipv6.addresses 2001:db8:1::1/32
Add the server’s private key to the connection profile:
#
nmcli connection modify server-wg0 wireguard.private-key "YFAnE0psgIdiAF7XR4abxiwVRnlMfeltxu10s/c4JXg="
Set the port for incoming WireGuard connections:
#
nmcli connection modify server-wg0 wireguard.listen-port 51820
Always set a fixed port number on hosts that receive incoming WireGuard connections. If you do not set a port, WireGuard uses a random free port each time you activate the
wg0
interface.Add peer configurations for each client that you want to allow to communicate with this server. You must add these settings manually, because the
nmcli
utility does not support setting the corresponding connection properties.Edit the
/etc/NetworkManager/system-connections/server-wg0.nmconnection
file, and append:[wireguard-peer.bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM=] allowed-ips=192.0.2.2;2001:db8:1::2;
-
The
[wireguard-peer.<public_key_of_the_client>]
entry defines the peer section of the client, and the section name contains the public key of the client. The
allowed-ips
parameter sets the tunnel IP addresses of the client that are allowed to send data to this server.Add a section for each client.
-
The
Reload the
server-wg0
connection profile:#
nmcli connection load /etc/NetworkManager/system-connections/server-wg0.nmconnection
Optional: Configure the connection to start automatically, enter:
#
nmcli connection modify server-wg0 autoconnect yes
Reactivate the
server-wg0
connection:#
nmcli connection up server-wg0
Verification
Display the interface configuration of the
wg0
device:#
wg show wg0
interface: wg0 public key: UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE= private key: (hidden) listening port: 51820 peer: bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM= allowed ips: 192.0.2.2/32, 2001:db8:1::2/128To display the private key in the output, use the
WG_HIDE_KEYS=never wg show wg0
command.Display the IP configuration of the
wg0
device:#
ip address show wg0
20: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000 link/none inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute wg0 valid_lft forever preferred_lft forever inet6 2001:db8:1::1/32 scope global noprefixroute valid_lft forever preferred_lft forever inet6 fe80::3ef:8863:1ce2:844/64 scope link noprefixroute valid_lft forever preferred_lft forever
Additional resources
-
The
wg(8)
man page -
The
WireGuard setting
section in thenm-settings(5)
man page
13.6. Configuring a WireGuard server using nmtui
You can configure the WireGuard server by creating a connection profile in NetworkManager. Use this method to let NetworkManager manage the WireGuard connection.
This procedure assumes the following settings:
Server:
-
Private key:
YFAnE0psgIdiAF7XR4abxiwVRnlMfeltxu10s/c4JXg=
-
Tunnel IPv4 address:
192.0.2.1/24
-
Tunnel IPv6 address:
2001:db8:1::1/32
-
Private key:
Client:
-
Public key:
bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM=
-
Tunnel IPv4 address:
192.0.2.2/24
-
Tunnel IPv6 address:
2001:db8:1::2/32
-
Public key:
Prerequisites
- You have generated the public and private key for both the server and client.
You know the following information:
- The private key of the server
- The static tunnel IP addresses and subnet masks of the client
- The public key of the client
- The static tunnel IP addresses and subnet masks of the server
-
You installed the
NetworkManager-tui
package.
Procedure
Start the
nmtui
application:# nmtui
-
Select
Edit a connection
, and press Enter. - Select Add, and press Enter.
-
Select the
WireGuard
connection type in the list, and press Enter. In the
Edit connection
window:-
Enter the name of the connection and the virtual interface, such as
wg0
, that NetworkManager should assign to the connection. - Enter the private key of the server.
Set the listen port number, such as
51820
, for incoming WireGuard connections.Always set a fixed port number on hosts that receive incoming WireGuard connections. If you do not set a port, WireGuard uses a random free port each time you activate the interface.
Click Add next to the
Peers
pane:- Enter the public key of the client.
-
Set the
Allowed IPs
field to the tunnel IP addresses of the client that are allowed to send data to this server. Select OK, and press Enter.
Select Show next to
IPv4 Configuration
, and press Enter.-
Select the IPv4 configuration method
Manual
. -
Enter the tunnel IPv4 address and the subnet mask. Leave the
Gateway
field empty.
-
Select the IPv4 configuration method
Select Show next to
IPv6 Configuration
, and press Enter.-
Select the IPv6 configuration method
Manual
. -
Enter the tunnel IPv6 address and the subnet mask. Leave the
Gateway
field empty.
-
Select the IPv6 configuration method
Select OK, and press Enter
-
Enter the name of the connection and the virtual interface, such as
- In the window with the list of connections, select Back, and press Enter.
-
In the
NetworkManager TUI
main window, select Quit, and press Enter.
Verification
Display the interface configuration of the
wg0
device:# wg show wg0 interface: wg0 public key: UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE= private key: (hidden) listening port: 51820 peer: bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM= allowed ips: 192.0.2.2/32, 2001:db8:1::2/128
To display the private key in the output, use the
WG_HIDE_KEYS=never wg show wg0
command.Display the IP configuration of the
wg0
device:# ip address show wg0 20: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000 link/none inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute wg0 valid_lft forever preferred_lft forever inet6 2001:db8:1::1/32 scope global noprefixroute valid_lft forever preferred_lft forever inet6 fe80::3ef:8863:1ce2:844/64 scope link noprefixroute valid_lft forever preferred_lft forever
Additional resources
-
The
wg(8)
man page
13.7. Configuring a WireGuard server using nm-connection-editor
You can configure the WireGuard server by creating a connection profile in NetworkManager. Use this method to let NetworkManager manage the WireGuard connection.
Prerequisites
- You have generated the public and private key for both the server and client.
You know the following information:
- The private key of the server
- The static tunnel IP addresses and subnet masks of the client
- The public key of the client
- The static tunnel IP addresses and subnet masks of the server
Procedure
Open a terminal, and enter:
#
nm-connection-editor
- Add a new connection by clicking the + button.
-
Select the
WireGuard
connection type, and click Create. - Optional: Update the connection name.
-
On the
General
tab, selectConnect automatically with priority
. Optionally, set a priority value. On the
WireGuard
tab:-
Enter the name of the virtual interface, such as
wg0
, that NetworkManager should assign to the connection. - Enter the private key of the server.
Set the listen port number, such as
51820
, for incoming WireGuard connections.Always set a fixed port number on hosts that receive incoming WireGuard connections. If you do not set a port, WireGuard uses a random free port each time you activate the interface.
Click Add to add peers:
- Enter the public key of the client.
-
Set the
Allowed IPs
field to the tunnel IP addresses of the client that are allowed to send data to this server. - Click Apply.
-
Enter the name of the virtual interface, such as
On the
IPv4 Settings
tab:-
Select
Manual
in theMethod
list. -
Click Add to enter the tunnel IPv4 address and the subnet mask. Leave the
Gateway
field empty.
-
Select
On the
IPv6 Settings
tab:-
Select
Manual
in theMethod
list. -
Click Add to enter the tunnel IPv6 address and the subnet mask. Leave the
Gateway
field empty.
-
Select
- Click Save to store the connection profile.
Verification
Display the interface configuration of the
wg0
device:#
wg show wg0
interface: wg0 public key: UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE= private key: (hidden) listening port: 51820 peer: bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM= allowed ips: 192.0.2.2/32, 2001:db8:1::2/128To display the private key in the output, use the
WG_HIDE_KEYS=never wg show wg0
command.Display the IP configuration of the
wg0
device:#
ip address show wg0
20: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000 link/none inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute wg0 valid_lft forever preferred_lft forever inet6 2001:db8:1::1/32 scope global noprefixroute valid_lft forever preferred_lft forever inet6 fe80::3ef:8863:1ce2:844/64 scope link noprefixroute valid_lft forever preferred_lft forever
Additional resources
-
The
wg(8)
man page
13.8. Configuring a WireGuard server using the wg-quick service
You can configure the WireGuard server by creating a configuration file in the /etc/wireguard/
directory. Use this method to configure the service independently from NetworkManager.
This procedure assumes the following settings:
Server:
-
Private key:
YFAnE0psgIdiAF7XR4abxiwVRnlMfeltxu10s/c4JXg=
-
Tunnel IPv4 address:
192.0.2.1/24
-
Tunnel IPv6 address:
2001:db8:1::1/32
-
Private key:
Client:
-
Public key:
bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM=
-
Tunnel IPv4 address:
192.0.2.2/24
-
Tunnel IPv6 address:
2001:db8:1::2/32
-
Public key:
Prerequisites
- You have generated the public and private key for both the server and client.
You know the following information:
- The private key of the server
- The static tunnel IP addresses and subnet masks of the client
- The public key of the client
- The static tunnel IP addresses and subnet masks of the server
Procedure
Install the
wireguard-tools
package:#
dnf install wireguard-tools
Create the
/etc/wireguard/wg0.conf
file with the following content:[Interface] Address = 192.0.2.1/24, 2001:db8:1::1/32 ListenPort = 51820 PrivateKey = YFAnE0psgIdiAF7XR4abxiwVRnlMfeltxu10s/c4JXg= [Peer] PublicKey = bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM= AllowedIPs = 192.0.2.2, 2001:db8:1::2
The
[Interface]
section describes the WireGuard settings of the interface on the server:-
Address
: A comma-separated list of the server’s tunnel IP addresses. -
PrivateKey
: The private key of the server. ListenPort
: The port on which WireGuard listens for incoming UDP connections.Always set a fixed port number on hosts that receive incoming WireGuard connections. If you do not set a port, WireGuard uses a random free port each time you activate the
wg0
interface.
-
Each
[Peer]
section describes the settings of one client:-
PublicKey
: The public key of the client. -
AllowedIPs
: The tunnel IP addresses of the client that are allowed to send data to this server.
-
Enable and start the WireGuard connection:
#
systemctl enable --now wg-quick@wg0
The systemd instance name must match the name of the configuration file in the
/etc/wireguard/
directory without the.conf
suffix. The service also uses this name for the virtual network interface.
Verification
Display the interface configuration of the
wg0
device:#
wg show wg0
interface: wg0 public key: UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE= private key: (hidden) listening port: 51820 peer: bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM= allowed ips: 192.0.2.2/32, 2001:db8:1::2/128To display the private key in the output, use the
WG_HIDE_KEYS=never wg show wg0
command.Display the IP configuration of the
wg0
device:#
ip address show wg0
20: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000 link/none inet 192.0.2.1/24 scope global wg0 valid_lft forever preferred_lft forever inet6 2001:db8:1::1/32 scope global valid_lft forever preferred_lft forever
Additional resources
-
The
wg(8)
man page -
The
wg-quick(8)
man page
13.9. Configuring firewalld on a WireGuard server using the command line
You must configure the firewalld
service on the WireGuard server to allow incoming connections from clients. Additionally, if clients should be able to use the WireGuard server as the default gateway and route all traffic through the tunnel, you must enable masquerading.
Procedure
Open the WireGuard port for incoming connections in the
firewalld
service:#
firewall-cmd --permanent --add-port=51820/udp --zone=public
If clients should route all traffic through the tunnel and use the WireGuard server as the default gateway, enable masquerading for the
public
zone:#
firewall-cmd --permanent --zone=public --add-masquerade
Reload the
firewalld
rules.#
firewall-cmd --reload
Verification
Display the configuration of the
public
zone:#
firewall-cmd --list-all
public (active) ... ports: 51820/udp masquerade: yes ...
Additional resources
-
The
firewall-cmd(1)
man page
13.10. Configuring firewalld on a WireGuard server using the graphical interface
You must configure the firewalld
service on the WireGuard server to allow incoming connections from clients. Additionally, if clients should be able to use the WireGuard server as the default gateway and route all traffic through the tunnel, you must enable masquerading.
Procedure
-
Press the Super key, enter
firewall
, and select theFirewall
application from the results. -
Select
Permanent
in theConfiguration
list. -
Select the
public
zone. Allow incoming connections to the WireGuard port:
-
On the
Ports
tab, click Add. - Enter the port number you set for incoming WireGuard connections:
-
Select
udp
from theProtocol
list. - Click OK.
-
On the
If clients should route all traffic through the tunnel and use the WireGuard server as the default gateway:
-
Navigate to the
Masquerading
tab of thepublic
zone. -
Select
Masquerade zone
.
-
Navigate to the
- Select Options → Reload Firewalld.
Verification
Display the configuration of the
public
zone:#
firewall-cmd --list-all
public (active) ... ports: 51820/udp masquerade: yes ...
13.11. Configuring a WireGuard client using nmcli
You can configure a WireGuard client by creating a connection profile in NetworkManager. Use this method to let NetworkManager manage the WireGuard connection.
This procedure assumes the following settings:
Client:
-
Private key:
aPUcp5vHz8yMLrzk8SsDyYnV33IhE/k20e52iKJFV0A=
-
Tunnel IPv4 address:
192.0.2.2/24
-
Tunnel IPv6 address:
2001:db8:1::2/32
-
Private key:
Server:
-
Public key:
UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE=
-
Tunnel IPv4 address:
192.0.2.1/24
-
Tunnel IPv6 address:
2001:db8:1::1/32
-
Public key:
Prerequisites
- You have generated the public and private key for both the server and client.
You know the following information:
- The private key of the client
- The static tunnel IP addresses and subnet masks of the client
- The public key of the server
- The static tunnel IP addresses and subnet masks of the server
Procedure
Add a NetworkManager WireGuard connection profile:
#
nmcli connection add type wireguard con-name client-wg0 ifname wg0 autoconnect no
This command creates a profile named
client-wg0
and assigns the virtual interfacewg0
to it. To prevent the connection from starting automatically after you add it without finalizing the configuration, disable theautoconnect
parameter.Optional: Configure NetworkManager so that it does not automatically start the
client-wg
connection:#
nmcli connection modify client-wg0 autoconnect no
Set the tunnel IPv4 address and subnet mask of the client:
#
nmcli connection modify client-wg0 ipv4.method manual ipv4.addresses 192.0.2.2/24
Set the tunnel IPv6 address and subnet mask of the client:
#
nmcli connection modify client-wg0 ipv6.method manual ipv6.addresses 2001:db8:1::2/32
If you want to route all traffic through the tunnel, set the tunnel IP addresses of the server as the default gateway:
#
nmcli connection modify client-wg0 ipv4.gateway 192.0.2.1 ipv6.gateway 2001:db8:1::1
Add the server’s private key to the connection profile:
#
nmcli connection modify client-wg0 wireguard.private-key "aPUcp5vHz8yMLrzk8SsDyYnV33IhE/k20e52iKJFV0A="
Edit the
/etc/NetworkManager/system-connections/client-wg0.nmconnection
file, and append:[wireguard-peer.UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE=] endpoint=server.example.com:51820 allowed-ips=192.0.2.1;2001:db8:1::1; persistent-keepalive=20
-
The
[wireguard-peer.<public_key_of_the_server>]
entry defines the peer section of the server, and the section name contains the public key of the server. -
The
endpoint
parameter sets the hostname or IP address and the port of the server. The client uses this information to establish the connection. The
allowed-ips
parameter sets a list of IP addresses that are allowed to send data to this client. For example, set the parameter to:- The tunnel IP addresses of the server to allow only the server to communicate with this client. The value in the example above configures this scenario.
-
0.0.0.0/0;::/0;
to allow any remote IPv4 and IPv6 address to communicate with this client. Use this setting to route all traffic through the tunnel and use the WireGuard server as default gateway.
-
The optional
persistent-keepalive
parameter defines an interval in seconds in which WireGuard sends a keepalive packet to the server. Set this parameter if you use the client in a network with network address translation (NAT) or if a firewall closes the UDP connection after some time of inactivity.
-
The
Reload the
client-wg0
connection profile:#
nmcli connection load /etc/NetworkManager/system-connections/client-wg0.nmconnection
Reactivate the
client-wg0
connection:#
nmcli connection up client-wg0
Verification
Ping the IP addresses of the server:
#
ping 192.0.2.1
#ping6 2001:db8:1::1
Display the interface configuration of the
wg0
device:#
wg show wg0
interface: wg0 public key: bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM= private key: (hidden) listening port: 51820 peer: UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE= endpoint: server.example.com:51820 allowed ips: 192.0.2.1/32, 2001:db8:1::1/128 latest handshake: 1 minute, 41 seconds ago transfer: 824 B received, 1.01 KiB sent persistent keepalive: every 20 secondsTo display the private key in the output, use the
WG_HIDE_KEYS=never wg show wg0
command.Note that the output contains only the
latest handshake
andtransfer
entries if you have already sent traffic through the VPN tunnel.Display the IP configuration of the
wg0
device:#
ip address show wg0
10: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000 link/none inet 192.0.2.2/24 brd 192.0.2.255 scope global noprefixroute wg0 valid_lft forever preferred_lft forever inet6 2001:db8:1::2/32 scope global noprefixroute valid_lft forever preferred_lft forever inet6 fe80::73d9:6f51:ea6f:863e/64 scope link noprefixroute valid_lft forever preferred_lft forever
Additional resources
-
The
wg(8)
man page -
The
WireGuard setting
section in thenm-settings(5)
man page
13.12. Configuring a WireGuard client using nmtui
You can configure a WireGuard client by creating a connection profile in NetworkManager. Use this method to let NetworkManager manage the WireGuard connection.
This procedure assumes the following settings:
Client:
-
Private key:
aPUcp5vHz8yMLrzk8SsDyYnV33IhE/k20e52iKJFV0A=
-
Tunnel IPv4 address:
192.0.2.2/24
-
Tunnel IPv6 address:
2001:db8:1::2/32
-
Private key:
Server:
-
Public key:
UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE=
-
Tunnel IPv4 address:
192.0.2.1/24
-
Tunnel IPv6 address:
2001:db8:1::1/32
-
Public key:
Prerequisites
- You have generated the public and private key for both the server and client.
You know the following information:
- The private key of the client
- The static tunnel IP addresses and subnet masks of the client
- The public key of the server
- The static tunnel IP addresses and subnet masks of the server
-
You installed the
NetworkManager-tui
package
Procedure
Start the
nmtui
application:# nmtui
-
Select
Edit a connection
, and press Enter. - Select Add, and press Enter.
-
Select the
WireGuard
connection type in the list, and press Enter. In the
Edit connection
window:-
Enter the name of the connection and the virtual interface, such as
wg0
, that NetworkManager should assign to the connection. Enter the private key of the client.
Click Add next to the
Peers
pane:- Enter the public key of the server.
Set the
Allowed IPs
field. For example, set it to:- The tunnel IP addresses of the server to allow only the server to communicate with this client.
-
0.0.0.0/0,::/0
to allow any remote IPv4 and IPv6 address to communicate with this client. Use this setting to route all traffic through the tunnel and use the WireGuard server as default gateway.
-
Enter the host name or IP address and port of the WireGuard server into the
Endpoint
field. Use the following format:hostname_or_IP:port_number
- Optional: If you use the client in a network with network address translation (NAT) or if a firewall closes the UDP connection after some time of inactivity, set a persistent keep alive interval in seconds. In this interval, the client sends a keepalive packet to the server.
Select OK, and press Enter.
Select Show next to
IPv4 Configuration
, and press Enter.-
Select the IPv4 configuration method
Manual
. -
Enter the tunnel IPv4 address and the subnet mask. Leave the
Gateway
field empty.
-
Select the IPv4 configuration method
Select Show next to
IPv6 Configuration
, and press Enter.-
Select the IPv6 configuration method
Manual
. -
Enter the tunnel IPv6 address and the subnet mask. Leave the
Gateway
field empty.
-
Select the IPv6 configuration method
-
Optional: Select
Automatically connect
. Select OK, and press Enter
-
Enter the name of the connection and the virtual interface, such as
- In the window with the list of connections, select Back, and press Enter.
-
In the
NetworkManager TUI
main window, select Quit, and press Enter.
Verification
Ping the IP addresses of the server:
# ping 192.0.2.1 # ping6 2001:db8:1::1
Display the interface configuration of the
wg0
device:# wg show wg0 interface: wg0 public key: bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM= private key: (hidden) listening port: 51820 peer: UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE= endpoint: server.example.com:51820 allowed ips: 192.0.2.1/32, 2001:db8:1::1/128 latest handshake: 1 minute, 41 seconds ago transfer: 824 B received, 1.01 KiB sent persistent keepalive: every 20 seconds
To display the private key in the output, use the
WG_HIDE_KEYS=never wg show wg0
command.Note that the output contains only the
latest handshake
andtransfer
entries if you have already sent traffic through the VPN tunnel.Display the IP configuration of the
wg0
device:# ip address show wg0 10: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000 link/none inet 192.0.2.2/24 brd 192.0.2.255 scope global noprefixroute wg0 valid_lft forever preferred_lft forever inet6 2001:db8:1::2/32 scope global noprefixroute valid_lft forever preferred_lft forever inet6 fe80::73d9:6f51:ea6f:863e/64 scope link noprefixroute valid_lft forever preferred_lft forever
Additional resources
-
The
wg(8)
man page
13.13. Configuring a WireGuard client using nm-connection-editor
You can configure a WireGuard client by creating a connection profile in NetworkManager. Use this method to let NetworkManager manage the WireGuard connection.
Prerequisites
- You have generated the public and private key for both the server and client.
You know the following information:
- The private key of the client
- The static tunnel IP addresses and subnet masks of the client
- The public key of the server
- The static tunnel IP addresses and subnet masks of the server
Procedure
Open a terminal, and enter:
#
nm-connection-editor
- Add a new connection by clicking the + button.
-
Select the
WireGuard
connection type, and click Create. - Optional: Update the connection name.
-
Optional: On the
General
tab, selectConnect automatically with priority
. On the
WireGuard
tab:-
Enter the name of the virtual interface, such as
wg0
, that NetworkManager should assign to the connection. - Enter client’s private key.
Click Add to add peers:
- Enter the public key of the server.
Set the
Allowed IPs
field. For example, set it to:- The tunnel IP addresses of the server to allow only the server to communicate with this client.
-
0.0.0.0/0;::/0;
to allow any remote IPv4 and IPv6 address to communicate with this client. Use this setting to route all traffic through the tunnel and use the WireGuard server as default gateway.
-
Enter the hostname or IP address and port of the WireGuard server into the
Endpoint
field. Use the following format:hostname_or_IP:port_number
- Optional: If you use the client in a network with network address translation (NAT) or if a firewall closes the UDP connection after some time of inactivity, set a persistent keep alive interval in seconds. In this interval, the client sends a keepalive packet to the server.
- Click Apply.
-
Enter the name of the virtual interface, such as
On the
IPv4 Settings
tab:-
Select
Manual
in theMethod
list. - Click Add to enter the tunnel IPv4 address and the subnet mask.
-
If you want to route all traffic through the tunnel, set the tunnel IPv4 address of the server in the
Gateway
field. Otherwise, leave the field empty.
-
Select
On the
IPv6 Settings
tab:-
Select
Manual
in theMethod
list. - Click Add to enter the tunnel IPv6 address and the subnet mask.
-
If you want to route all traffic through the tunnel, set the tunnel IPv6 address of the server in the
Gateway
field. Otherwise, leave the field empty.
-
Select
- Click Save to store the connection profile.
Verification
Ping the IP addresses of the server:
#
ping 192.0.2.1
#ping6 2001:db8:1::1
Display the interface configuration of the
wg0
device:#
wg show wg0
interface: wg0 public key: bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM= private key: (hidden) listening port: 51820 peer: UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE= endpoint: server.example.com:51820 allowed ips: 192.0.2.1/32, 2001:db8:1::1/128 latest handshake: 1 minute, 41 seconds ago transfer: 824 B received, 1.01 KiB sent persistent keepalive: every 20 secondsTo display the private key in the output, use the
WG_HIDE_KEYS=never wg show wg0
command.Note that the output only contains the
latest handshake
andtransfer
entries if you have already sent traffic through the VPN tunnel.Display the IP configuration of the
wg0
device:#
ip address show wg0
10: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000 link/none inet 192.0.2.2/24 brd 192.0.2.255 scope global noprefixroute wg0 valid_lft forever preferred_lft forever inet6 2001:db8:1::2/32 scope global noprefixroute valid_lft forever preferred_lft forever inet6 fe80::73d9:6f51:ea6f:863e/64 scope link noprefixroute valid_lft forever preferred_lft forever
Additional resources
-
The
wg(8)
man page
13.14. Configuring a WireGuard client using the wg-quick service
You can configure a WireGuard client by creating a configuration file in the /etc/wireguard/
directory. Use this method to configure the service independently from NetworkManager.
This procedure assumes the following settings:
Client:
-
Private key:
aPUcp5vHz8yMLrzk8SsDyYnV33IhE/k20e52iKJFV0A=
-
Tunnel IPv4 address:
192.0.2.2/24
-
Tunnel IPv6 address:
2001:db8:1::2/32
-
Private key:
Server:
-
Public key:
UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE=
-
Tunnel IPv4 address:
192.0.2.1/24
-
Tunnel IPv6 address:
2001:db8:1::1/32
-
Public key:
Prerequisites
- You have generated the public and private key for both the server and client.
You know the following information:
- The private key of the client
- The static tunnel IP addresses and subnet masks of the client
- The public key of the server
- The static tunnel IP addresses and subnet masks of the server
Procedure
Install the
wireguard-tools
package:#
dnf install wireguard-tools
Create the
/etc/wireguard/wg0.conf
file with the following content:[Interface] Address = 192.0.2.2/24, 2001:db8:1::2/32 PrivateKey = aPUcp5vHz8yMLrzk8SsDyYnV33IhE/k20e52iKJFV0A= [Peer] PublicKey = UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE= AllowedIPs = 192.0.2.1, 2001:db8:1::1 Endpoint = server.example.com:51820 PersistentKeepalive = 20
The
[Interface]
section describes the WireGuard settings of the interface on the client:-
Address
: A comma-separated list of the client’s tunnel IP addresses. -
PrivateKey
: The private key of the client.
-
The
[Peer]
section describes the settings of the server:-
PublicKey
: The public key of the server. AllowedIPs
: The IP addresses that are allowed to send data to this client. For example, set the parameter to:- The tunnel IP addresses of the server to allow only the server to communicate with this client. The value in the example above configures this scenario.
-
0.0.0.0/0, ::/0
to allow any remote IPv4 and IPv6 address to communicate with this client. Use this setting to route all traffic through the tunnel and use the WireGuard server as default gateway.
-
Endpoint
: Sets the hostname or IP address and the port of the server. The client uses this information to establish the connection. -
The optional
persistent-keepalive
parameter defines an interval in seconds in which WireGuard sends a keepalive packet to the server. Set this parameter if you use the client in a network with network address translation (NAT) or if a firewall closes the UDP connection after some time of inactivity.
-
Enable and start the WireGuard connection:
#
systemctl enable --now wg-quick@wg0
The systemd instance name must match the name of the configuration file in the
/etc/wireguard/
directory without the.conf
suffix. The service also uses this name for the virtual network interface.
Verification
Ping the IP addresses of the server:
#
ping 192.0.2.1
#ping6 2001:db8:1::1
Display the interface configuration of the
wg0
device:#
wg show wg0
interface: wg0 public key: bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM= private key: (hidden) listening port: 51820 peer: UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE= endpoint: server.example.com:51820 allowed ips: 192.0.2.1/32, 2001:db8:1::1/128 latest handshake: 1 minute, 41 seconds ago transfer: 824 B received, 1.01 KiB sent persistent keepalive: every 20 secondsTo display the private key in the output, use the
WG_HIDE_KEYS=never wg show wg0
command.Note that the output contains only the
latest handshake
andtransfer
entries if you have already sent traffic through the VPN tunnel.Display the IP configuration of the
wg0
device:#
ip address show wg0
10: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000 link/none inet 192.0.2.2/24 scope global wg0 valid_lft forever preferred_lft forever inet6 2001:db8:1::2/32__ scope global valid_lft forever preferred_lft forever
Additional resources
-
The
wg(8)
man page -
The
wg-quick(8)
man page
Chapter 14. Configuring a VPN connection
This section explains how to configure a virtual private network (VPN) connection.
A 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.
14.1. Configuring a VPN connection with control-center
This procedure describes how to configure a VPN connection using 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 14.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 IPv4 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 IPv6 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 Add button to customize the configuration or the Apply button to save it for the existing one. -
Switch the profile to
ON
to active theVPN
connection.
Additional resources
-
nm-settings-libreswan(5)
14.2. Configuring a VPN connection using nm-connection-editor
This procedure describes how to configure a VPN connection using nm-connection-editor
.
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 Create. 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.Optionally, configure additional settings by clicking the Advanced 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 + button, 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.
Additional resources
-
nm-settings-libreswan(5)
man page
14.3. 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. This procedure describes how to enable the automatic detection in case that the feature was disabled or explicitly enabled.
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
If the network card supports ESP hardware offload support, following these steps to verify the result:
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: 10Send 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: 15If the counter values have increased, ESP hardware offload works.
Additional resources
14.4. 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.
-
The network driver supports ESP hardware offload on a bond device. In RHEL, only the
ixgbe
driver 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
Display the active port of the bond:
#
grep "Currently Active Slave" /proc/net/bonding/bond0
Currently Active Slave: enp1s0Display the
tx_ipsec
andrx_ipsec
counters of the active port:#
ethtool -S enp1s0 | egrep "_ipsec"
tx_ipsec: 10 rx_ipsec: 10Send 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: 15If the counter values have increased, ESP hardware offload works.
Additional resources
- Configuring network bonding
-
The Configuring a VPN with IPsec section in the
Securing networks
documentation - Configuring a VPN with IPsec chapter in the Securing networks document.
Chapter 15. 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.
15.1. Configuring an IPIP tunnel using nmcli 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 using nmcli to encapsulate layer-3 traffic in IPv4 packets.
This procedure describes how to 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 steps
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
Additional resources
-
nmcli
man page -
The
ip-tunnel settings
section in thenm-settings(5)
man page
15.2. Configuring a GRE tunnel using nmcli 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.
This procedure describes how to create a GRE tunnel between two RHEL routers to connect two internal subnets over the Internet as shown in the following diagram:

The gre0
device name is reserved. Use gre1
or a different name for the device.
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.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 steps
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
Additional resources
-
nmcli
man page -
The
ip-tunnel settings
section in thenm-settings(5)
man page
15.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.
This procedure describes how to create a GRETAP tunnel between two RHEL routers to connect two networks using a bridge as shown in the following diagram:

The gretap0
device name is reserved. Use gretap1
or a different name for the device.
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.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 steps
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
Additional resources
-
nmcli
man page -
The
ip-tunnel settings
section in thenm-settings(5)
man page
15.4. Additional resources
-
ip-link(8)
man page
Chapter 16. Port mirroring
Network administrators can use port mirroring to replicate inbound and outbound network traffic being communicated from one network device to another. Administrators use port mirroring to monitor network traffic and collect network data to:
- Debug networking issues and tune the network flow
- Inspect and analyze the network traffic to troubleshoot networking problems
- Detect an intrusion
16.1. Mirroring a network interface using nmcli
You can configure port mirroring using NetworkManager. The following procedure mirrors the network traffic from enp1s0
to enp7s0
by adding Traffic Control (tc
) rules and filters to the enp1s0
network interface.
Prerequisites
- A network interface to mirror the network traffic to.
Procedure
Add a network connection profile that you want to mirror the network traffic from:
# nmcli connection add type ethernet ifname enp1s0 con-name enp1s0 autoconnect no
Attach a
prio
qdisc
toenp1s0
for the egress (outgoing) traffic with the10:
handle:# nmcli connection modify enp1s0 +tc.qdisc "root prio handle 10:"
The
prio
qdisc
attached without children allows attaching filters.Add a
qdisc
for the ingress traffic, with theffff:
handle:# nmcli connection modify enp1s0 +tc.qdisc "ingress handle ffff:"
Add the following filters to match packets on the ingress and egress
qdiscs
, and to mirror them toenp7s0
:# nmcli connection modify enp1s0 +tc.tfilter "parent ffff: matchall action mirred egress mirror dev enp7s0" # nmcli connection modify enp1s0 +tc.tfilter "parent 10: matchall action mirred egress mirror dev enp7s0"
The
matchall
filter matches all packets, and themirred
action redirects packets to destination.Activate the connection:
# nmcli connection up enp1s0
Verification steps
Install the
tcpdump
utility:# dnf install tcpdump
Display the traffic mirrored on the target device (
enp7s0
):# tcpdump -i enp7s0
Additional resources
Chapter 17. Configuring network devices to accept traffic from all MAC addresses
Network devices usually intercept and read packets that their controller is programmed to receive. You can configure the network devices to accept traffic from all MAC addresses in a virtual switch or at the port group level.
You can use this network mode to:
- diagnose network connectivity issues,
- monitor network activity for security reasons,
- intercept private data-in-transit or intrusion in the network.
This section describes how to configure a network device to accept traffic from all the MAC addresses using iproute2
, nmcli
, or nmstatectl
utilities. You can enable this mode for any kind of network device except InfiniBand
.
17.1. Temporarily configuring a network device to accept all traffic using iproute2
This procedure describes how to configure a network device to accept all traffic regardless of the MAC addresses. Any change made using the iproute2
utility is temporary and lost after the machine reboots.
Procedure
Optional: Display the network interfaces to identify the one for which you want to receive all traffic:
# ip a 1: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000 link/ether 98:fa:9b:a4:34:09 brd ff:ff:ff:ff:ff:ff 2: bond0: <NO-CARRIER,BROADCAST,MULTICAST,MASTER,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 6a:fd:16:b0:83:5c brd ff:ff:ff:ff:ff:ff 3: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 ...
Modify the device to enable or disable this property.
To enable the
accept-all-mac-addresses
mode forenp1s0
:# ip link set enp1s0 promisc on
To disable the
accept-all-mac-addresses
mode forenp1s0
:# ip link set enp1s0 promisc off
Verification steps
To verify that the
accept-all-mac-addresses
mode is enabled:# ip link show enp1s0 1: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,PROMISC,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000 link/ether 98:fa:9b:a4:34:09 brd ff:ff:ff:ff:ff:ff
The PROMISC
flag in the device description indicates that the mode is enabled.
17.2. Permanently configuring a network device to accept all traffic using nmcli
This procedure describes how to configure a network device to accept traffic regardless of MAC addresses using the nmcli
commands.
Procedure
Optional: Display the network interfaces to identify the one for which you want to receive all traffic:
# ip a 1: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000 link/ether 98:fa:9b:a4:34:09 brd ff:ff:ff:ff:ff:ff 2: bond0: <NO-CARRIER,BROADCAST,MULTICAST,MASTER,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 6a:fd:16:b0:83:5c brd ff:ff:ff:ff:ff:ff 3: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 ...
You can create a new connection, if you do not have any.
Modify the network device to enable or disable this property.
To enable the
ethernet.accept-all-mac-addresses
mode forenp1s0
:# nmcli connection modify enp1s0 ethernet.accept-all-mac-addresses yes
To disable the
accept-all-mac-addresses
mode forenp1s0
:# nmcli connection modify enp1s0 ethernet.accept-all-mac-addresses no
To apply the changes, reactivate the connection:
# nmcli connection up enp1s0
Verification steps
To verify that the
ethernet.accept-all-mac-addresses
mode is enabled:# nmcli connection show enp1s0 ... 802-3-ethernet.accept-all-mac-addresses:1 (true)
The 802-3-ethernet.accept-all-mac-addresses: true
indicates that the mode is enabled.
17.3. Permanently configuring a network network device to accept all traffic using nmstatectl
This procedure describes how to configure a network device to accept all traffic regardless of MAC addresses using the nmstatectl
utility.
Prerequisites
-
The
nmstate
package is installed. -
The
.yml
file that you used to configure the device is available.
Procedure
Edit the existing
enp1s0.yml
file for the enp1s0 connection and add the following content to it.--- interfaces: - name: enp1s0 type: ethernet state: up accept -all-mac-address: true
Apply the network settings.
# nmstatectl apply ~/enp1s0.yml
Verification steps
To verify that the
802-3-ethernet.accept-all-mac-addresses
mode is enabled:# nmstatectl show enp1s0 interfaces: - name: enp1s0 type: ethernet state: up accept-all-mac-addresses: true ...
The 802-3-ethernet.accept-all-mac-addresses: true
indicates that the mode is enabled.
Additional resources
-
For further details about
nmstatectl
, see thenmstatectl(8)
man page. -
For more configuration examples, see the
/usr/share/doc/nmstate/examples/
directory.
Chapter 18. Setting up an 802.1x network authentication service for LAN clients using hostapd with FreeRADIUS backend
The IEEE 802.1X standard defines secure authentication and authorization methods to protect networks from unauthorized clients. Using the hostapd
service and FreeRADIUS, you can provide network access control (NAC) in your network.
In this documentation, the RHEL host acts as a bridge to connect different clients with an existing network. However, the RHEL host grants only authenticated clients access to the network.

18.1. Prerequisites
A clean installation of FreeRADIUS.
If the
freeradius
package is already installed, remove the/etc/raddb/
directory, uninstall and then install the package again. Do not reinstall the package using thednf reinstall
command, because the permissions and symbolic links in the/etc/raddb/
directory are then different.
18.2. Setting up the bridge on the authenticator
A network bridge is a link-layer device which forwards traffic between hosts and networks based on a table of MAC addresses. If you set up RHEL as an 802.1X authenticator, add both the interfaces on which to perform authentication and the LAN interface to the bridge.
Prerequisites
- The server has multiple Ethernet interfaces.
Procedure
Create the bridge interface:
# nmcli connection add type bridge con-name br0 ifname br0
Assign the Ethernet interfaces to the bridge:
# nmcli connection add type ethernet slave-type bridge con-name br0-port1 ifname enp1s0 master br0 # nmcli connection add type ethernet slave-type bridge con-name br0-port2 ifname enp7s0 master br0 # nmcli connection add type ethernet slave-type bridge con-name br0-port3 ifname enp8s0 master br0 # nmcli connection add type ethernet slave-type bridge con-name br0-port4 ifname enp9s0 master br0
Enable the bridge to forward extensible authentication protocol over LAN (EAPOL) packets:
# nmcli connection modify br0 group-forward-mask 8
Configure the connection to automatically activate the ports:
# nmcli connection modify br0 connection.autoconnect-slaves 1
Activate the connection:
# nmcli connection up br0
Verification
Display the link status of Ethernet devices that are ports of a specific bridge:
# ip link show master br0 3: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:62:61:0e brd ff:ff:ff:ff:ff:ff ...
Verify if forwarding of EAPOL packets is enabled on the
br0
device:# cat /sys/class/net/br0/bridge/group_fwd_mask 0x8
If the command returns
0x8
, forwarding is enabled.
Additional resources
-
nm-settings(5)
man page
18.3. Certificate requirements by FreeRADIUS
For a secure FreeRADIUS service, you require TLS certificates for different purposes:
A TLS server certificate for encrypted connections to the server. Use a trusted certificate authority (CA) to issue the certificate.
The server certificate requires the extended key usage (EKU) field set to
TLS Web Server Authentication
.Client certificates issued by the same CA for extended authentication protocol transport layer security (EAP-TLS). EAP-TLS provides certificate-based authentication and is enabled by default.
The client certificates require their EKU field set to
TLS Web Client Authentication
.
To secure connection, use your company’s CA or create your own CA to issue certificates for FreeRADIUS. If you use a public CA, you allow it to authenticate users and issue client certificates for EAP-TLS.
18.4. Creating a set of certificates on a FreeRADIUS server for testing purposes
For testing purposes, the freeradius
package installs scripts and configuration files in the /etc/raddb/certs/
directory to create your own certificate authority (CA) and issue certificates.
If you use the default configuration, certificates generated by these scripts expire after 60 days and keys use an insecure password ("whatever"). However, you can customize the CA, server, and client configuration.
After you perform the procedure, the following files, which you require later in this documentation, are created:
-
/etc/raddb/certs/ca.pem
: CA certificate -
/etc/raddb/certs/server.key
: Private key of the server certificate -
/etc/raddb/certs/server.pem
: Server certificate -
/etc/raddb/certs/client.key
: Private key of the client certificate -
/etc/raddb/certs/client.pem
: Client certificate
Prerequisites
-
You installed the
freeradius
package.
Procedure
Change into the
/etc/raddb/certs/
directory:# cd /etc/raddb/certs/
Optional: Customize the CA configuration:
... [ req ] default_bits = 2048 input_password = ca_password output_password = ca_password ... [certificate_authority] countryName = US stateOrProvinceName = North Carolina localityName = Raleigh organizationName = Example Inc. emailAddress = admin@example.org commonName = "Example Certificate Authority" ...
Optional: Customize the server configuration:
... [ CA_default ] default_days = 730 ... [ req ] distinguished_name = server default_bits = 2048 input_password = key_password output_password = key_password ... [server] countryName = US stateOrProvinceName = North Carolina localityName = Raleigh organizationName = Example Inc. emailAddress = admin@example.org commonName = "Example Server Certificate" ...
Optional: Customize the client configuration:
... [ CA_default ] default_days = 365 ... [ req ] distinguished_name = client default_bits = 2048 input_password = password_on_private_key output_password = password_on_private_key ... [client] countryName = US stateOrProvinceName = North Carolina localityName = Raleigh organizationName = Example Inc. emailAddress = user@example.org commonName = user@example.org ...
Create the certificates:
# make all
Change the group on the
/etc/raddb/certs/server.pem
file toradiusd
:# chgrp radiusd /etc/raddb/certs/server.pem*
Additional resources
-
/etc/raddb/certs/README.md
18.5. Configuring FreeRADIUS to authenticate network clients securely using EAP
FreeRADIUS supports different methods of the Extensible authentication protocol (EAP). However, for a secure network, this documentation describes how to configure FreeRADIUS to support only the following secure EAP authentication methods:
- EAP-TLS (transport layer security) uses a secure TLS connection to authenticate clients using certificates. To use EAP-TLS, you need TLS client certificates for each network client and a server certificate for the server. Note that the same certificate authority (CA) must have issued the certificates. Always use your own CA to create certificates, because all client certificates issued by the CA you use can authenticate to your FreeRADIUS server.
- EAP-TTLS (tunneled transport layer security) uses a secure TLS connection and authenticates clients using mechanisms, such as password authentication protocol (PAP) or challenge handshake authentication protocol (CHAP). To use EAP-TTLS, you need a TLS server certificate.
- EAP-PEAP (protected extensible authentication protocol) uses a secure TLS connection as the outer authentication protocol to set up the tunnel. The authenticator authenticates the certificate of the RADIUS server. Afterwards, the supplicant authenticates through the encrypted tunnel using Microsoft challenge handshake authentication protocol version 2 (MS-CHAPv2) or other methods.
The default FreeRADIUS configuration files serve as documentation and describe all parameters and directives. If you want to disable certain features, comment them out instead of removing the corresponding parts in the configuration files. This enables you to preserve the structure of the configuration files and the included documentation.
Prerequisites
-
You installed the
freeradius
package. -
The configuration files in the
/etc/raddb/
directory are unchanged and as provided by thefreeradius
package. The following files exist on the server:
-
TLS private key of the FreeRADIUS host:
/etc/raddb/certs/server.key
-
TLS server certificate of the FreeRADIUS host:
/etc/raddb/certs/server.pem
-
TLS CA certificate:
/etc/raddb/certs/ca.pem
If you store the files in a different location or if they have different names, set the
private_key_file
,certificate_file
, andca_file
parameters in the/etc/raddb/mods-available/eap
file accordingly.-
TLS private key of the FreeRADIUS host:
Procedure
If the
/etc/raddb/certs/dh
with Diffie-Hellman (DH) parameters does not exist, create one. For example, to create a DH file with a 2048 bits prime, enter:# openssl dhparam -out /etc/raddb/certs/dh 2048
For security reasons, do not use a DH file with less than a 2048 bits prime. Depending on the number of bits, the creation of the file can take several minutes.
Set secure permissions on the TLS private key, server certificate, CA certificate, and the file with DH parameters:
# chmod 640 /etc/raddb/certs/server.key /etc/raddb/certs/server.pem /etc/raddb/certs/ca.pem /etc/raddb/certs/dh # chown root:radiusd /etc/raddb/certs/server.key /etc/raddb/certs/server.pem /etc/raddb/certs/ca.pem /etc/raddb/certs/dh
Edit the
/etc/raddb/mods-available/eap
file:Set the password of the private key in the
private_key_password
parameter:eap { ... tls-config tls-common { ... private_key_password = key_password ... } }
Depending on your environment, set the
default_eap_type
parameter in theeap
directive to your primary EAP type you use:eap { ... default_eap_type = ttls ... }
For a secure environment, use only
ttls
,tls
, orpeap
.Comment out the
md5
directives to disable the insecure EAP-MD5 authentication method:eap { ... # md5 { # } ... }
Note that, in the default configuration file, other insecure EAP authentication methods are commented out by default.
Edit the
/etc/raddb/sites-available/default
file, and comment out all authentication methods other thaneap
:authenticate { ... # Auth-Type PAP { # pap # } # Auth-Type CHAP { # chap # } # Auth-Type MS-CHAP { # mschap # } # mschap # digest ... }
This leaves only EAP enabled and disables plain-text authentication methods.
Edit the
/etc/raddb/clients.conf
file:Set a secure password in the
localhost
andlocalhost_ipv6
client directives:client localhost { ipaddr = 127.0.0.1 ... secret = client_password ... } client localhost_ipv6 { ipv6addr = ::1 secret = client_password }
If RADIUS clients, such as network authenticators, on remote hosts should be able to access the FreeRADIUS service, add corresponding client directives for them:
client hostapd.example.org { ipaddr = 192.0.2.2/32 secret = client_password }
The
ipaddr
parameter accepts IPv4 and IPv6 addresses, and you can use the optional classless inter-domain routing (CIDR) notation to specify ranges. However, you can set only one value in this parameter. For example, to grant access to an IPv4 and IPv6 address, add two client directives.Use a descriptive name for the client directive, such as a hostname or a word that describes where the IP range is used.
If you want to use EAP-TTLS or EAP-PEAP, add the users to the
/etc/raddb/users
file:example_user Cleartext-Password := "user_password"
For users who should use certificate-based authentication (EAP-TLS), do not add any entry.
Verify the configuration files:
# radiusd -XC ... Configuration appears to be OK
Enable and start the
radiusd
service:# systemctl enable --now radiusd
Verification
Troubleshooting
Stop the
radiusd
service:# systemctl stop radiusd
Start the service in debug mode:
# radiusd -X ... Ready to process requests
-
Perform authentication tests on the FreeRADIUS host, as referenced in the
Verification
section.
Next steps
- Disable unrequired authentication methods and other features you do not use.
18.6. Configuring hostapd as an authenticator in a wired network
The host access point daemon (hostapd
) service can act as an authenticator in a wired network to provide 802.1X authentication. For this, the hostapd
service requires a RADIUS server that authenticates the clients.
The hostapd
service provides an integrated RADIUS server. However, use the integrated RADIUS server only for testing purposes. For production environments, use FreeRADIUS server, which supports additional features, such as different authentication methods and access control.
The hostapd
service does not interact with the traffic plane. The service acts only as an authenticator. For example, use a script or service that uses the hostapd
control interface to allow or deny traffic based on the result of authentication events.
Prerequisites
-
You installed the
hostapd
package. - The FreeRADIUS server has been configured, and it is ready to authenticate clients.
Procedure
Create the
/etc/hostapd/hostapd.conf
file with the following content:# General settings of hostapd # =========================== # Control interface settings ctrl_interface=/var/run/hostapd ctrl_interface_group=wheel # Enable logging for all modules logger_syslog=-1 logger_stdout=-1 # Log level logger_syslog_level=2 logger_stdout_level=2 # Wired 802.1X authentication # =========================== # Driver interface type driver=wired # Enable IEEE 802.1X authorization ieee8021x=1 # Use port access entry (PAE) group address # (01:80:c2:00:00:03) when sending EAPOL frames use_pae_group_addr=1 # Network interface for authentication requests interface=br0 # RADIUS client configuration # =========================== # Local IP address used as NAS-IP-Address own_ip_addr=192.0.2.2 # Unique NAS-Identifier within scope of RADIUS server nas_identifier=hostapd.example.org # RADIUS authentication server auth_server_addr=192.0.2.1 auth_server_port=1812 auth_server_shared_secret=client_password # RADIUS accounting server acct_server_addr=192.0.2.1 acct_server_port=1813 acct_server_shared_secret=client_password
For further details about the parameters used in this configuration, see their descriptions in the
/usr/share/doc/hostapd/hostapd.conf
example configuration file.Enable and start the
hostapd
service:# systemctl enable --now hostapd
Verification
See:
Troubleshooting
Stop the
hostapd
service:# systemctl stop hostapd
Start the service in debug mode:
# hostapd -d /etc/hostapd/hostapd.conf
-
Perform authentication tests on the FreeRADIUS host, as referenced in the
Verification
section.
Additional resources
-
hostapd.conf(5)
man page -
/usr/share/doc/hostapd/hostapd.conf
18.7. Testing EAP-TTLS authentication against a FreeRADIUS server or authenticator
To test if authentication using extensible authentication protocol (EAP) over tunneled transport layer security (EAP-TTLS) works as expected, run this procedure:
- After you set up the FreeRADIUS server
-
After you set up the
hostapd
service as an authenticator for 802.1X network authentication.
The output of the test utilities used in this procedure provide additional information about the EAP communication and help you to debug problems.
Prerequisites
When you want to authenticate to:
A FreeRADIUS server:
-
The
eapol_test
utility, provided by thehostapd
package, is installed. - The client, on which you run this procedure, has been authorized in the FreeRADIUS server’s client databases.
-
The
-
An authenticator, the
wpa_supplicant
utility, provided by the same-named package, is installed.
-
You stored the certificate authority (CA) certificate in the
/etc/pki/tls/certs/ca.pem
file.
Procedure
Create the
/etc/wpa_supplicant/wpa_supplicant-TTLS.conf
file with the following content:ap_scan=0 network={ eap=TTLS eapol_flags=0 key_mgmt=IEEE8021X # Anonymous identity (sent in unencrypted phase 1) # Can be any string anonymous_identity="anonymous" # Inner authentication (sent in TLS-encrypted phase 2) phase2="auth=PAP" identity="example_user" password="user_password" # CA certificate to validate the RADIUS server's identity ca_cert="/etc/pki/tls/certs/ca.pem" }
To authenticate to:
A FreeRADIUS server, enter:
# eapol_test -c /etc/wpa_supplicant/wpa_supplicant-TTLS.conf -a 192.0.2.1 -s client_password ... EAP: Status notification: remote certificate verification (param=success) ... CTRL-EVENT-EAP-SUCCESS EAP authentication completed successfully ... SUCCESS
The
-a
option defines the IP address of the FreeRADIUS server, and the-s
option specifies the password for the host on which you run the command in the FreeRADIUS server’s client configuration.An authenticator, enter:
# wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant-TTLS.conf -D wired -i enp0s31f6 ... enp0s31f6: CTRL-EVENT-EAP-SUCCESS EAP authentication completed successfully ...
The
-i
option specifies the network interface name on whichwpa_supplicant
sends out extended authentication protocol over LAN (EAPOL) packets.For more debugging information, pass the
-d
option to the command.
Additional resources
-
/usr/share/doc/wpa_supplicant/wpa_supplicant.conf
18.8. Testing EAP-TLS authentication against a FreeRADIUS server or authenticator
To test if authentication using extensible authentication protocol (EAP) transport layer security (EAP-TLS) works as expected, run this procedure:
- After you set up the FreeRADIUS server
-
After you set up the
hostapd
service as an authenticator for 802.1X network authentication.
The output of the test utilities used in this procedure provide additional information about the EAP communication and help you to debug problems.
Prerequisites
When you want to authenticate to:
A FreeRADIUS server:
-
The
eapol_test
utility, provided by thehostapd
package, is installed. - The client, on which you run this procedure, has been authorized in the FreeRADIUS server’s client databases.
-
The
-
An authenticator, the
wpa_supplicant
utility, provided by the same-named package, is installed.
-
You stored the certificate authority (CA) certificate in the
/etc/pki/tls/certs/ca.pem
file. - The CA that issued the client certificate is the same that issued the server certificate of the FreeRADIUS server.
-
You stored the client certificate in the
/etc/pki/tls/certs/client.pem
file. -
You stored the private key of the client in the
/etc/pki/tls/private/client.key
Procedure
Create the
/etc/wpa_supplicant/wpa_supplicant-TLS.conf
file with the following content:ap_scan=0 network={ eap=TLS eapol_flags=0 key_mgmt=IEEE8021X identity="user@example.org" client_cert="/etc/pki/tls/certs/client.pem" private_key="/etc/pki/tls/private/client.key" private_key_passwd="password_on_private_key" # CA certificate to validate the RADIUS server's identity ca_cert="/etc/pki/tls/certs/ca.pem" }
To authenticate to:
A FreeRADIUS server, enter:
# eapol_test -c /etc/wpa_supplicant/wpa_supplicant-TLS.conf -a 192.0.2.1 -s client_password ... EAP: Status notification: remote certificate verification (param=success) ... CTRL-EVENT-EAP-SUCCESS EAP authentication completed successfully ... SUCCESS
The
-a
option defines the IP address of the FreeRADIUS server, and the-s
option specifies the password for the host on which you run the command in the FreeRADIUS server’s client configuration.An authenticator, enter:
# wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant-TLS.conf -D wired -i enp0s31f6 ... enp0s31f6: CTRL-EVENT-EAP-SUCCESS EAP authentication completed successfully ...
The
-i
option specifies the network interface name on whichwpa_supplicant
sends out extended authentication protocol over LAN (EAPOL) packets.For more debugging information, pass the
-d
option to the command.
Additional resources
-
/usr/share/doc/wpa_supplicant/wpa_supplicant.conf
18.9. Blocking and allowing traffic based on hostapd authentication events
The hostapd
service does not interact with the traffic plane. The service acts only as an authenticator. However, you can write a script to allow and deny traffic based on the result of authentication events.
This procedure is not supported and is no enterprise-ready solution. It only demonstrates how to block or allow traffic by evaluating events retrieved by hostapd_cli
.
When the 802-1x-tr-mgmt
systemd service starts, RHEL blocks all traffic on the listen port of hostapd
except extensible authentication protocol over LAN (EAPOL) packets and uses the hostapd_cli
utility to connect to the hostapd
control interface. The /usr/local/bin/802-1x-tr-mgmt
script then evaluates events. Depending on the different events received by hostapd_cli
, the script allows or blocks traffic for MAC addresses. Note that, when the 802-1x-tr-mgmt
service stops, all traffic is automatically allowed again.
Perform this procedure on the hostapd
server.
Prerequisites
-
The
hostapd
service has been configured, and the service is ready to authenticate clients.
Procedure
Create the
/usr/local/bin/802-1x-tr-mgmt
file with the following content:#!/bin/sh if [ "x$1" == "xblock_all" ] then nft delete table bridge tr-mgmt-br0 2>/dev/null || true nft -f - << EOF table bridge tr-mgmt-br0 { set allowed_macs { type ether_addr } chain accesscontrol { ether saddr @allowed_macs accept ether daddr @allowed_macs accept drop } chain forward { type filter hook forward priority 0; policy accept; meta ibrname "br0" jump accesscontrol } } EOF echo "802-1x-tr-mgmt Blocking all traffic through br0. Traffic for given host will be allowed after 802.1x authentication" elif [ "x$1" == "xallow_all" ] then nft delete table bridge tr-mgmt-br0 echo "802-1x-tr-mgmt Allowed all forwarding again" fi case ${2:-NOTANEVENT} in AP-STA-CONNECTED | CTRL-EVENT-EAP-SUCCESS | CTRL-EVENT-EAP-SUCCESS2) nft add element bridge tr-mgmt-br0 allowed_macs { $3 } echo "$1: Allowed traffic from $3" ;; AP-STA-DISCONNECTED | CTRL-EVENT-EAP-FAILURE) nft delete element bridge tr-mgmt-br0 allowed_macs { $3 } echo "802-1x-tr-mgmt $1: Denied traffic from $3" ;; esac
Create the
/etc/systemd/system/802-1x-tr-mgmt@.service
systemd service file with the following content:[Unit] Description=Example 802.1x traffic management for hostapd After=hostapd.service After=sys-devices-virtual-net-%i.device [Service] Type=simple ExecStartPre=-/bin/sh -c '/usr/sbin/tc qdisc del dev %i ingress > /dev/null 2>&1' ExecStartPre=-/bin/sh -c '/usr/sbin/tc qdisc del dev %i clsact > /dev/null 2>&1' ExecStartPre=/usr/sbin/tc qdisc add dev %i clsact ExecStartPre=/usr/sbin/tc filter add dev %i ingress pref 10000 protocol 0x888e matchall action ok index 100 ExecStartPre=/usr/sbin/tc filter add dev %i ingress pref 10001 protocol all matchall action drop index 101 ExecStart=/usr/sbin/hostapd_cli -i %i -a /usr/local/bin/802-1x-tr-mgmt ExecStopPost=-/usr/sbin/tc qdisc del dev %i clsact [Install] WantedBy=multi-user.target
Reload systemd:
# systemctl daemon-reload
Enable and start the
802-1x-tr-mgmt
service with the interface namehostapd
is listening on:# systemctl enable --now 802-1x-tr-mgmt@br0.service
Verification
Authenticate with a client to the network. See:
Additional resources
-
systemd.service(5)
man page
Chapter 19. Authenticating a RHEL client to the network using the 802.1X standard with a certificate stored on the file system
Administrators frequently use port-based Network Access Control (NAC) based on the IEEE 802.1X standard to protect a network from unauthorized LAN and Wi-Fi clients. The procedures in this section describe different options to configure network authentication.
19.1. Configuring 802.1X network authentication on an existing Ethernet connection using nmcli
Using the nmcli
utility, you can configure the client to authenticate itself to the network. This procedure describes how to configure TLS authentication in an existing NetworkManager Ethernet connection profile named enp1s0
to authenticate to the network.
Prerequisites
- The network supports 802.1X network authentication.
- The Ethernet connection profile exists in NetworkManager and has a valid IP configuration.
The following files required for TLS authentication exist on the client:
-
The client key stored is in the
/etc/pki/tls/private/client.key
file, and the file is owned and only readable by theroot
user. -
The client certificate is stored in the
/etc/pki/tls/certs/client.crt
file. -
The Certificate Authority (CA) certificate is stored in the
/etc/pki/tls/certs/ca.crt
file.
-
The client key stored is in the
-
The
wpa_supplicant
package is installed.
Procedure
Set the Extensible Authentication Protocol (EAP) to
tls
and the paths to the client certificate and key file:# nmcli connection modify enp1s0 802-1x.eap tls 802-1x.client-cert /etc/pki/tls/certs/client.crt 802-1x.private-key /etc/pki/tls/certs/certs/client.key
Note that you must set the
802-1x.eap
,802-1x.client-cert
, and802-1x.private-key
parameters in a single command.Set the path to the CA certificate:
# nmcli connection modify enp1s0 802-1x.ca-cert /etc/pki/tls/certs/ca.crt
Set the identity of the user used in the certificate:
# nmcli connection modify enp1s0 802-1x.identity user@example.com
Optionally, store the password in the configuration:
# nmcli connection modify enp1s0 802-1x.private-key-password password
ImportantBy default, NetworkManager stores the password in clear text in the
/etc/sysconfig/network-scripts/keys-connection_name
file, that is readable only by theroot
user. However, clear 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.Activate the connection profile:
# nmcli connection up enp1s0
Verification steps
- Access resources on the network that require network authentication.
Additional resources
- Configuring an Ethernet connection
-
The
802-1x settings
section in thenm-settings(5)
man page -
nmcli(1)
man page
19.2. Configuring a static Ethernet connection with 802.1X network authentication using nmstatectl
Using the nmstate
utility, you can create an Ethernet connection that uses the 802.1X standard to authenticate the client. This procedure describes how to add an Ethernet connection for the enp1s0
interface with the following settings:
-
A static IPv4 address -
192.0.2.1
with a/24
subnet mask -
A static IPv6 address -
2001:db8:1::1
with a/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
-
802.1X network authentication using the
TLS
Extensible Authentication Protocol (EAP)
The nmstate
library only supports the TLS
EAP method.
Prerequisites
- The network supports 802.1X network authentication.
- The managed node uses NetworkManager.
The following files required for TLS authentication exist on the client:
-
The client key stored is in the
/etc/pki/tls/private/client.key
file, and the file is owned and only readable by theroot
user. -
The client certificate is stored in the
/etc/pki/tls/certs/client.crt
file. -
The Certificate Authority (CA) certificate is stored in the
/etc/pki/tls/certs/ca.crt
file.
-
The client key stored is in the
Procedure
Create a YAML file, for example
~/create-ethernet-profile.yml
, with the following contents:--- 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 802.1x: ca-cert: /etc/pki/tls/certs/ca.crt client-cert: /etc/pki/tls/certs/client.crt eap-methods: - tls identity: client.example.org private-key: /etc/pki/tls/private/client.key private-key-password: password 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
Apply the settings to the system:
# nmstatectl apply ~/create-ethernet-profile.yml
Verification
- Access resources on the network that require network authentication.
19.3. Configuring a static Ethernet connection with 802.1X network authentication using RHEL System Roles
Using the Networking RHEL System Role, you can automate the creation of an Ethernet connection that uses the 802.1X standard to authenticate the client. This procedure describes how to remotely add an Ethernet connection for the enp1s0
interface with the following settings by running an Ansible playbook:
-
A static IPv4 address -
192.0.2.1
with a/24
subnet mask -
A static IPv6 address -
2001:db8:1::1
with a/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
-
802.1X network authentication using the
TLS
Extensible Authentication Protocol (EAP)
Run this procedure on the Ansible control node.
Prerequisites
-
The
ansible-core
andrhel-system-roles
packages are installed on the control node. -
If you use a different remote user than
root
when you run the playbook, you must have appropriatesudo
permissions on the managed node. - The network supports 802.1X network authentication.
- The managed node uses NetworkManager.
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 Certificate Authority (CA) certificate is stored in the
/srv/data/ca.crt
file.
-
The client key is stored in the
Procedure
If the host on which you want to execute the instructions in the playbook is not yet inventoried, add the IP or name of this host to the
/etc/ansible/hosts
Ansible inventory file:node.example.com
Create the
~/enable-802.1x.yml
playbook with the following content:--- - name: Configure an Ethernet connection with 802.1X authentication hosts: node.example.com become: true tasks: - name: Copy client key for 802.1X authentication copy: src: "/srv/data/client.key" dest: "/etc/pki/tls/private/client.key" mode: 0600 - name: Copy client certificate for 802.1X authentication copy: src: "/srv/data/client.crt" dest: "/etc/pki/tls/certs/client.crt" - name: Copy CA certificate for 802.1X authentication copy: src: "/srv/data/ca.crt" dest: "/etc/pki/ca-trust/source/anchors/ca.crt" - include_role: name: rhel-system-roles.network vars: network_connections: - name: enp1s0 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 ieee802_1x: identity: user_name eap: tls private_key: "/etc/pki/tls/private/client.key" private_key_password: "password" client_cert: "/etc/pki/tls/certs/client.crt" ca_cert: "/etc/pki/ca-trust/source/anchors/ca.crt" domain_suffix_match: example.com state: up
Run the playbook:
To connect as
root
user to the managed host, enter:# ansible-playbook -u root ~/enable-802.1x.yml
To connect as a user to the managed host, enter:
# ansible-playbook -u user_name --ask-become-pass ~/ethernet-static-IP.yml
The
--ask-become-pass
option makes sure that theansible-playbook
command prompts for thesudo
password of the user defined in the-u user_name
option.
If you do not specify the
-u user_name
option,ansible-playbook
connects to the managed host as the user that is currently logged in to the control node.
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
ansible-playbook(1)
man page
19.4. Configuring a Wi-Fi connection with 802.1X network authentication using the RHEL System Roles
Using RHEL System Roles, you can automate the creation of a Wi-Fi connection. This procedure describes how to remotely add a wireless connection profile for the wlp1s0
interface using an Ansible playbook. The created profile uses the 802.1X standard to authenticate the client to a Wi-Fi network. The playbook configures the connection profile to use DHCP. To configure static IP settings, adapt the parameters in the ip
dictionary accordingly.
Prerequisites
- You installed the ansible and rhel-system-roles packages on the control node.
- The network supports 802.1X network authentication.
-
If you use a different remote user than
root
when you run the playbook, you must have appropriatesudo
permissions on the managed node. -
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
Perform the following procedure on the Ansible control node.
Procedure
If the host on which you want to execute the instructions in the playbook is not yet inventoried, add the IP or name of this host to the
/etc/ansible/hosts
Ansible inventory file:node.example.com
Create the
~/enable-802.1x.yml
playbook with the following content:--- - name: Configure a Wi-Fi connection with 802.1X authentication hosts: "node.example.com" become: true tasks: - name: Copy client key for 802.1X authentication copy: src: "/srv/data/client.key" dest: "/etc/pki/tls/private/client.key" mode: 0400 - name: Copy client certificate for 802.1X authentication copy: src: "/srv/data/client.crt" dest: "/etc/pki/tls/certs/client.crt" - name: Copy CA certificate for 802.1X authentication copy: src: "/srv/data/ca.crt" dest: "/etc/pki/ca-trust/source/anchors/ca.crt" - block: - import_role: name: linux-system-roles.network vars: network_connections: - name: Configure the Example-Wi-Fi profile interface_name: wlp1s0 state: up type: wireless autoconnect: yes ip: dhcp4: true auto6: true wireless: ssid: "Example-Wi-Fi" key_mgmt: "wpa-eap" ieee802_1x: identity: "user_name" eap: tls private_key: "/etc/pki/tls/client.key" private_key_password: "password" private_key_password_flags: none client_cert: "/etc/pki/tls/client.pem" ca_cert: "/etc/pki/tls/cacert.pem" domain_suffix_match: "example.com"
Run the playbook:
To connect as a
root
user to the managed host, enter:# ansible-playbook -u root ~/enable-802.1x.yml
To connect as a user to the managed host, enter:
# ansible-playbook -u user_name --ask-become-pass ~/ethernet-static-IP.yml
The
--ask-become-pass
option makes sure that theansible-playbook
command prompts for thesudo
password of the user defined in the-u user_name
option.
If you do not specify the
-u user_name
option,ansible-playbook
connects to the managed host as the user that is currently logged in to the control node.
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
ansible-playbook(1)
man page
Chapter 20. Managing the default gateway setting
The default gateway is a router that forwards network packets when no other route matches the destination of a packet. In a local network, the default gateway is typically the host that is one hop closer to the internet.
20.1. Setting the default gateway on an existing connection using nmcli
In most situations, administrators set the default gateway when they create a connection as explained in, for example, Configuring a static Ethernet connection using nmcli.
This section describes how to set or update the default gateway on a previously created connection using the nmcli
utility.
Prerequisites
- At least one static IP address must be configured on the connection on which the default gateway will be set.
-
If the user is logged in on a physical console, user permissions are sufficient. Otherwise, user must have
root
permissions.
Procedure
Set the IP address of the default gateway.
For example, to set the IPv4 address of the default gateway on the
example
connection to192.0.2.1
:$
sudo nmcli connection modify example ipv4.gateway "192.0.2.1"
For example, to set the IPv6 address of the default gateway on the
example
connection to2001:db8:1::1
:$
sudo nmcli connection modify example ipv6.gateway "2001:db8:1::1"
Restart the network connection for changes to take effect. For example, to restart the
example
connection using the command line:$
sudo nmcli connection up example
WarningAll connections currently using this network connection are temporarily interrupted during the restart.
Optionally, verify that the route is active.
To display the IPv4 default gateway:
$
ip -4 route
default via 192.0.2.1 dev example proto static metric 100To display the IPv6 default gateway:
$
ip -6 route
default via 2001:db8:1::1 dev example proto static metric 100 pref medium
Additional resources
20.2. Setting the default gateway on an existing connection using the nmcli interactive mode
In most situations, administrators set the default gateway when they create a connection as explained in, for example, Configuring a dynamic Ethernet connection using the nmcli interactive editor.
This section describes how to set or update the default gateway on a previously created connection using the interactive mode of the nmcli
utility.
Prerequisites
- At least one static IP address must be configured on the connection on which the default gateway will be set.
-
If the user is logged in on a physical console, user permissions are sufficient. Otherwise, the user must have
root
permissions.
Procedure
Open the
nmcli
interactive mode for the required connection. For example, to open thenmcli
interactive mode for the example connection:$
sudo nmcli connection edit example
Set the default gateway.
For example, to set the IPv4 address of the default gateway on the
example
connection to192.0.2.1
:nmcli>
set ipv4.gateway 192.0.2.1
For example, to set the IPv6 address of the default gateway on the
example
connection to2001:db8:1::1
:nmcli>
set ipv6.gateway 2001:db8:1::1
Optionally, verify that the default gateway was set correctly:
nmcli>
print
... ipv4.gateway: 192.0.2.1 ... ipv6.gateway: 2001:db8:1::1 ...Save the configuration:
nmcli>
save persistent
Restart the network connection for changes to take effect:
nmcli>
activate example
WarningAll connections currently using this network connection are temporarily interrupted during the restart.
Leave the
nmcli
interactive mode:nmcli>
quit
Optionally, verify that the route is active.
To display the IPv4 default gateway:
$
ip -4 route
default via 192.0.2.1 dev example proto static metric 100To display the IPv6 default gateway:
$
ip -6 route
default via 2001:db8:1::1 dev example proto static metric 100 pref medium
Additional resources
20.3. Setting the default gateway on an existing connection using nm-connection-editor
In most situations, administrators set the default gateway when they create a connection. This section describes how to set or update the default gateway on a previously created connection using the nm-connection-editor
application.
Prerequisites
- At least one static IP address must be configured on the connection on which the default gateway will be set.
Procedure
Open a terminal, and enter
nm-connection-editor
:$
nm-connection-editor
- Select the connection to modify, and click the gear wheel icon to edit the existing connection.
Set the IPv4 default gateway. For example, to set the IPv4 address of the default gateway on the connection to
192.0.2.1
:-
Open the
IPv4 Settings
tab. Enter the address in the
gateway
field next to the IP range the gateway’s address is within:
-
Open the
Set the IPv6 default gateway. For example, to set the IPv6 address of the default gateway on the connection to
2001:db8:1::1
:-
Open the
IPv6
tab. Enter the address in the
gateway
field next to the IP range the gateway’s address is within:
-
Open the
- Click OK.
- Click Save.
Restart the network connection for changes to take effect. For example, to restart the
example
connection using the command line:$
sudo nmcli connection up example
WarningAll connections currently using this network connection are temporarily interrupted during the restart.
Optionally, verify that the route is active.
To display the IPv4 default gateway:
$
ip -4 route
default via 192.0.2.1 dev example proto static metric 100To display the IPv6 default gateway:
$
ip -6 route
default via 2001:db8:1::1 dev example proto static metric 100 pref medium
Additional resources
20.4. Setting the default gateway on an existing connection using control-center
In most situations, administrators set the default gateway when they create a connection. This section describes how to set or update the default gateway on a previously created connection using the control-center
application.
Prerequisites
- At least one static IP address must be configured on the connection on which the default gateway will be set.
-
The network configuration of the connection is open in the
control-center
application.
Procedure
Set the IPv4 default gateway. For example, to set the IPv4 address of the default gateway on the connection to
192.0.2.1
:-
Open the
IPv4
tab. Enter the address in the
gateway
field next to the IP range the gateway’s address is within:
-
Open the
Set the IPv6 default gateway. For example, to set the IPv6 address of the default gateway on the connection to
2001:db8:1::1
:-
Open the
IPv6
tab. Enter the address in the
gateway
field next to the IP range the gateway’s address is within:
-
Open the
- Click Apply.
Back in the
Network
window, disable and re-enable the connection by switching the button for the connection to Off and back to On for changes to take effect.WarningAll connections currently using this network connection are temporarily interrupted during the restart.
Optionally, verify that the route is active.
To display the IPv4 default gateway:
$
ip -4 route
default via 192.0.2.1 dev example proto static metric 100To display the IPv6 default gateway:
$
ip -6 route
default via 2001:db8:1::1 dev example proto static metric 100 pref medium
Additional resources
20.5. Setting the default gateway on an existing connection using nmstatectl
You can set the default gateway of a network connection using the nmstatectl
utility. This procedure describes how to set the default gateway of the existing enp1s0
connection to 192.0.2.1
.
Prerequisites
- At least one static IP address must be configured on the connection on which the default gateway will be set.
-
The
enp1s0
interface is configured, and the IP address of the default gateway is within the subnet of the IP configuration of this interface. -
The
nmstate
package is installed.
Procedure
Create a YAML file, for example
~/set-default-gateway.yml
, with the following contents:--- routes: config: - destination: 0.0.0.0/0 next-hop-address: 192.0.2.1 next-hop-interface: enp1s0
Apply the settings to the system:
# nmstatectl apply ~/set-default-gateway.yml
Additional resources
-
For further details about
nmstatectl
, see thenmstatectl(8)
man page. -
For more configuration examples, see the
/usr/share/doc/nmstate/examples/
directory.
20.6. Setting the default gateway on an existing connection using System Roles
You can use the Networking RHEL System Role to set the default gateway.
When you run a play that uses the Networking RHEL System Role, the system role overrides an existing connection profile with the same name if the value of settings does not match the ones specified in the play. Therefore, always specify the whole configuration of the network connection profile in the play, even if, for example, the IP configuration already exists. Otherwise, the role resets these values to their defaults.
Depending on whether it already exists, the procedure creates or updates the enp1s0
connection profile with the following settings:
-
A static IPv4 address -
198.51.100.20
with a/24
subnet mask -
A static IPv6 address -
2001:db8:1::1
with a/64
subnet mask -
An IPv4 default gateway -
198.51.100.254
-
An IPv6 default gateway -
2001:db8:1::fffe
-
An IPv4 DNS server -
198.51.100.200
-
An IPv6 DNS server -
2001:db8:1::ffbb
-
A DNS search domain -
example.com
Prerequisites
-
The
ansible-core
andrhel-system-roles
packages are installed on the control node. -
If you use a different remote user than
root
when you run the playbook, this user has appropriatesudo
permissions on the managed node.
Procedure
If the host on which you want to execute the instructions in the playbook is not yet inventoried, add the IP or name of this host to the
/etc/ansible/hosts
Ansible inventory file:node.example.com
Create the
~/ethernet-connection.yml
playbook with the following content:--- - name: Configure an Ethernet connection with static IP and default gateway hosts: node.example.com become: true tasks: - include_role: name: rhel-system-roles.network vars: network_connections: - name: enp1s0 type: ethernet autoconnect: yes ip: address: - 198.51.100.20/24 - 2001:db8:1::1/64 gateway4: 198.51.100.254 gateway6: 2001:db8:1::fffe dns: - 198.51.100.200 - 2001:db8:1::ffbb dns_search: - example.com state: up
Run the playbook:
To connect as
root
user to the managed host, enter:# ansible-playbook -u root ~/ethernet-connection.yml
To connect as a user to the managed host, enter:
# ansible-playbook -u user_name --ask-become-pass ~/ethernet-connection.yml
The
--ask-become-pass
option makes sure that theansible-playbook
command prompts for thesudo
password of the user defined in the-u user_name
option.
If you do not specify the
-u user_name
option,ansible-playbook
connects to the managed host as the user that is currently logged in to the control node.
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
-
ansible-playbook(1)
man page
20.7. How NetworkManager manages multiple default gateways
In certain situations, for example for fallback reasons, you set multiple default gateways on a host. However, to avoid asynchronous routing issues, each default gateway of the same protocol requires a separate metric value. Note that RHEL only uses the connection to the default gateway that has the lowest metric set.
You can set the metric for both the IPv4 and IPv6 gateway of a connection using the following command:
# nmcli connection modify connection-name ipv4.route-metric value ipv6.route-metric value
Do not set the same metric value for the same protocol in multiple connection profiles to avoid routing issues.
If you set a default gateway without a metric value, NetworkManager automatically sets the metric value based on the interface type. For that, NetworkManager assigns the default value of this network type to the first connection that is activated, and sets an incremented value to each other connection of the same type in the order they are activated. For example, if two Ethernet connections with a default gateway exist, NetworkManager sets a metric of 100
on the route to the default gateway of the connection that you activate first. For the second connection, NetworkManager sets 101
.
The following is an overview of frequently-used network types and their default metrics:
Connection type | Default metric value |
---|---|
VPN | 50 |
Ethernet | 100 |
MACsec | 125 |
InfiniBand | 150 |
Bond | 300 |
Team | 350 |
VLAN | 400 |
Bridge | 425 |
TUN | 450 |
Wi-Fi | 600 |
IP tunnel | 675 |
20.8. Configuring NetworkManager to avoid using a specific profile to provide a default gateway
You can configure that NetworkManager never uses a specific profile to provide the default gateway. Follow this procedure for connection profiles that are not connected to the default gateway.
Prerequisites
- The NetworkManager connection profile for the connection that is not connected to the default gateway exists.
Procedure
If the connection uses a dynamic IP configuration, configure that NetworkManager does not use the connection as the default route for IPv4 and IPv6 connections:
# nmcli connection modify connection_name ipv4.never-default yes ipv6.never-default yes
Note that setting
ipv4.never-default
andipv6.never-default
toyes
, automatically removes the default gateway’s IP address for the corresponding protocol from the connection profile.Activate the connection:
# nmcli connection up connection_name
Verification steps
-
Use the
ip -4 route
andip -6 route
commands to verify that RHEL does not use the network interface for the default route for the IPv4 and IPv6 protocol.
20.9. Fixing unexpected routing behavior due to multiple default gateways
There are only a few scenarios, such as when using multipath TCP, in which you require multiple default gateways on a host. In most cases, you configure only a single default gateway to avoid unexpected routing behavior or asynchronous routing issues.
To route traffic to different internet providers, use policy-based routing instead of multiple default gateways.
Prerequisites
- The host uses NetworkManager to manage network connections, which is the default.
- The host has multiple network interfaces.
- The host has multiple default gateways configured.
Procedure
Display the routing table:
For IPv4, enter:
# ip -4 route default via 192.0.2.1 dev enp1s0 proto static metric 101 default via 198.51.100.1 dev enp7s0 proto static metric 102 ...
For IPv6, enter:
# ip -6 route default via 2001:db8:1::1 dev enp1s0 proto static metric 101 pref medium default via 2001:db8:2::1 dev enp7s0 proto static metric 102 pref medium ...
Entries starting with
default
indicate a default route. Note the interface names of these entries displayed next todev
.Use the following commands to display the NetworkManager connections that use the interfaces you identified in the previous step:
# nmcli -f GENERAL.CONNECTION,IP4.GATEWAY,IP6.GATEWAY device show enp1s0 GENERAL.CONNECTION: Corporate-LAN IP4.GATEWAY: 192.168.122.1 IP6.GATEWAY: 2001:db8:1::1 # nmcli -f GENERAL.CONNECTION,IP4.GATEWAY,IP6.GATEWAY device show enp7s0 GENERAL.CONNECTION: Internet-Provider IP4.GATEWAY: 198.51.100.1 IP6.GATEWAY: 2001:db8:2::1
In these examples, the profiles named
Corporate-LAN
andInternet-Provider
have the default gateways set. Because, in a local network, the default gateway is typically the host that is one hop closer to the internet, the rest of this procedure assumes that the default gateways in theCorporate-LAN
are incorrect.Configure that NetworkManager does not use the
Corporate-LAN
connection as the default route for IPv4 and IPv6 connections:# nmcli connection modify Corporate-LAN ipv4.never-default yes ipv6.never-default yes
Note that setting
ipv4.never-default
andipv6.never-default
toyes
, automatically removes the default gateway’s IP address for the corresponding protocol from the connection profile.Activate the
Corporate-LAN
connection:# nmcli connection up Corporate-LAN
Verification steps
Display the IPv4 and IPv6 routing tables and verify that only one default gateway is available for each protocol:
For IPv4, enter:
# ip -4 route default via 192.0.2.1 dev enp1s0 proto static metric 101 ...
For IPv6, enter:
# ip -6 route default via 2001:db8:1::1 dev enp1s0 proto static metric 101 pref medium ...
Chapter 21. Configuring static routes
Routing ensures that you can send and receive traffic between mutually-connected networks. In larger environments, administrators typically configure services so that routers can dynamically learn about other routers. In smaller environments, administrators often configure static routes to ensure that traffic can reach from one network to the next.
You need static routes to achieve a functioning communication among multiple networks if all of these conditions apply:
- The traffic has to pass multiple networks.
- The exclusive traffic flow through the default gateways is not sufficient.
Section 21.1, “Example of a network that requires static routes” describes scenarios and how the traffic flows between different networks when you do not configure static routes.
21.1. Example of a network that requires static routes
You require static routes in this example because not all IP networks are directly connected through one router. Without the static routes, some networks cannot communicate with each other. Additionally, traffic from some networks flows only in one direction.
The network topology in this example is artificial and only used to explain the concept of static routing. It is not a recommended topology in production environments.
For a functioning communication among all networks in this example, configure a static route to Raleigh (198.51.100.0/24
) with next the hop Router 2 (203.0.113.10
). The IP address of the next hop is the one of Router 2 in the data center network (203.0.113.0/24
).
You can configure the static route as follows:
-
For a simplified configuration, set this static route only on Router 1. However, this increases the traffic on Router 1 because hosts from the data center (
203.0.113.0/24
) send traffic to Raleigh (198.51.100.0/24
) always through Router 1 to Router 2. -
For a more complex configuration, configure this static route on all hosts in the data center (
203.0.113.0/24
). All hosts in this subnet then send traffic directly to Router 2 (203.0.113.10
) that is closer to Raleigh (198.51.100.0/24
).
For more details between which networks traffic flows or not, see the explanations below the diagram.

In case that the required static routes are not configured, the following describes in which situations the communication works and does not work:
Hosts in the Berlin network (
192.0.2.0/24
):- Can communicate with other hosts in the same subnet because they are directly connected.
-
Can communicate with the Internet because Router 1 is in the Berlin network (
192.0.2.0/24
) and has a default gateway, which leads to the Internet. -
Can communicate with the data center network (
203.0.113.0/24
) because Router 1 has interfaces in both the Berlin (192.0.2.0/24
) and the data center (203.0.113.0/24
) networks. -
Cannot communicate with the Raleigh network (
198.51.100.0/24
) because Router 1 has no interface in this network. Therefore, Router 1 sends the traffic to its own default gateway (Internet).
Hosts in the data center network (
203.0.113.0/24
):- Can communicate with other hosts in the same subnet because they are directly connected.
-
Can communicate with the Internet because they have their default gateway set to Router 1, and Router 1 has interfaces in both networks, the data center (
203.0.113.0/24
) and to the Internet. -
Can communicate with the Berlin network (
192.0.2.0/24
) because they have their default gateway set to Router 1, and Router 1 has interfaces in both the data center (203.0.113.0/24
) and the Berlin (192.0.2.0/24
) networks. -
Cannot communicate with the Raleigh network (
198.51.100.0/24
) because the data center network has no interface in this network. Therefore, hosts in the data center (203.0.113.0/24
) send traffic to their default gateway (Router 1). Router 1 also has no interface in the Raleigh network (198.51.100.0/24
) and, as a result, Router 1 sends this traffic to its own default gateway (Internet).
Hosts in the Raleigh network (
198.51.100.0/24
):- Can communicate with other hosts in the same subnet because they are directly connected.
-
Cannot communicate with hosts on the Internet. Router 2 sends the traffic to Router 1 because of the default gateway settings. The actual behavior of Router 1 depends on the reverse path filter (
rp_filter
) system control (sysctl
) setting. By default on RHEL, Router 1 drops the outgoing traffic instead of routing it to the Internet. However, regardless of the configured behavior, communication is not possible without the static route. -
Cannot communicate with the data center network (
203.0.113.0/24
). The outgoing traffic reaches the destination through Router 2 because of the default gateway setting. However, replies to packets do not reach the sender because hosts in the data center network (203.0.113.0/24
) send replies to their default gateway (Router 1). Router 1 then sends the traffic to the Internet. -
Cannot communicate with the Berlin network (
192.0.2.0/24
). Router 2 sends the traffic to Router 1 because of the default gateway settings. The actual behavior of Router 1 depends on therp_filter
sysctl
setting. By default on RHEL, Router 1 drops the outgoing traffic instead of sending it to the Berlin network (192.0.2.0/24
). However, regardless of the configured behavior, communication is not possible without the static route.
In addition to configuring the static routes, you must enable IP forwarding on both routers.
21.2. How to use the nmcli command to configure a static route
To configure a static route, use the nmcli
utility with the following syntax:
$ nmcli connection modify connection_name ipv4.routes "ip[/prefix] [next_hop] [metric] [attribute=value] [attribute=value] ..."
The command supports the following route attributes:
-
cwnd=n
: Sets the congestion window (CWND) size, defined in number of packets. -
lock-cwnd=true|false
: Defines whether or not the kernel can update the CWND value. -
lock-mtu=true|false
: Defines whether or not the kernel can update the MTU to path MTU discovery. -
lock-window=true|false
: Defines whether or not the kernel can update the maximum window size for TCP packets. -
mtu=n
: Sets the maximum transfer unit (MTU) to use along the path to the destination. -
onlink=true|false
: Defines whether the next hop is directly attached to this link even if it does not match any interface prefix. -
scope=n
: For an IPv4 route, this attribute sets the scope of the destinations covered by the route prefix. Set the value as an integer (0-255). -
src=address
: Sets the source address to prefer when sending traffic to the destinations covered by the route prefix. -
table=table_id
: Sets the ID of the table the route should be added to. If you omit this parameter, NetworkManager uses themain
table. -
tos=n
: Sets the type of service (TOS) key. Set the value as an integer (0-255). -
type=value
: Sets the route type. NetworkManager supports theunicast
,local
,blackhole
,unreachable
,prohibit
, andthrow
route types. The default isunicast
. -
window=n
: Sets the maximal window size for TCP to advertise to these destinations, measured in bytes.
If you use the ipv4.routes
sub-command, nmcli
overrides all current settings of this parameter.
To add a route:
$ nmcli connection modify connection_name +ipv4.routes "..."
Similarly, to remove a specific route:
$ nmcli connection modify connection_name -ipv4.routes "..."
21.3. Configuring a static route using an nmcli command
You can add a static route to the configuration of a network connection using the nmcli connection modify
command.
The procedure in this section describes how to add a route to the 192.0.2.0/24
network that uses the gateway running on 198.51.100.1
, which is reachable through the example
connection.
Prerequisites
- The network is configured
- The gateway for the static route must be directly reachable on the interface.
-
If the user is logged in on a physical console, user permissions are sufficient. Otherwise, the command requires
root
permissions.
Procedure
Add the static route to the
example
connection:$
sudo nmcli connection modify example +ipv4.routes "192.0.2.0/24 198.51.100.1"
To set multiple routes in one step, pass the individual routes comma-separated to the command. For example, to add a route to the
192.0.2.0/24
and203.0.113.0/24
networks, both routed through the198.51.100.1
gateway, enter:$
sudo nmcli connection modify example +ipv4.routes "192.0.2.0/24 198.51.100.1, 203.0.113.0/24 198.51.100.1"
Optionally, verify that the routes were added correctly to the configuration:
$
nmcli connection show example
... ipv4.routes: { ip = 192.0.2.1/24, nh = 198.51.100.1 } ...Restart the network connection:
$
sudo nmcli connection up example
WarningRestarting the connection briefly disrupts connectivity on that interface.
Optionally, verify that the route is active:
$
ip route
... 192.0.2.0/24 via 198.51.100.1 dev example proto static metric 100
Additional resources
-
nmcli(1)
man page
21.4. Configuring a static route using control-center
You can use control-center
in GNOME to add a static route to the configuration of a network connection.
The procedure in this section describes how to add a route to the 192.0.2.0/24
network that uses the gateway running on 198.51.100.1
.
Prerequisites
- The network is configured.
- The gateway for the static route must be directly reachable on the interface.
-
The network configuration of the connection is opened in the
control-center
application. See Configuring an Ethernet connection using nm-connection-editor.
Procedure
-
Open the
IPv4
tab. -
Optionally, disable automatic routes by clicking the On button in the
Routes
section of theIPv4
tab to use only static routes. If automatic routes are enabled, Red Hat Enterprise Linux uses static routes and routes received from a DHCP server. Enter the address, netmask, gateway, and optionally a metric value:
- Click Apply.
Back in the
Network
window, disable and re-enable the connection by switching the button for the connection to Off and back to On for changes to take effect.WarningRestarting the connection briefly disrupts connectivity on that interface.
Optionally, verify that the route is active:
$
ip route
... 192.0.2.0/24 via 198.51.100.1 dev example proto static metric 100
21.5. Configuring a static route using nm-connection-editor
You can use the nm-connection-editor
application to add a static route to the configuration of a network connection.
The procedure in this section describes how to add a route to the 192.0.2.0/24
network that uses the gateway running on 198.51.100.1
, which is reachable trough the example
connection.
Prerequisites
- The network is configured.
- The gateway for the static route must be directly reachable on the interface.
Procedure
Open a terminal and enter
nm-connection-editor
:$
nm-connection-editor
-
Select the
example
connection and click the gear wheel icon to edit the existing connection. -
Open the
IPv4
tab. - Click the Routes button.
Click the Add button and enter the address, netmask, gateway, and optionally a metric value.
- Click OK.
- Click Save.
Restart the network connection for changes to take effect. For example, to restart the
example
connection using the command line:$
sudo nmcli connection up example
Optionally, verify that the route is active:
$
ip route
... 192.0.2.0/24 via 198.51.100.1 dev example proto static metric 100
21.6. Configuring a static route using the nmcli interactive mode
You can use the interactive mode of the nmcli
utility to add a static route to the configuration of a network connection.
The procedure in this section describes how to add a route to the 192.0.2.0/24
network that uses the gateway running on 198.51.100.1
, which is reachable trough the example
connection.
Prerequisites
- The network is configured
- The gateway for the static route must be directly reachable on the interface.
-
If the user is logged in on a physical console, user permissions are sufficient. Otherwise, the command requires
root
permissions.
Procedure
Open the
nmcli
interactive mode for theexample
connection:$
sudo nmcli connection edit example
Add the static route:
nmcli>
set ipv4.routes 192.0.2.0/24 198.51.100.1
Optionally, verify that the routes were added correctly to the configuration:
nmcli>
print
... ipv4.routes: { ip = 192.0.2.1/24, nh = 198.51.100.1 } ...The
ip
attribute displays the network to route and thenh
attribute the gateway (next hop).Save the configuration:
nmcli>
save persistent
Restart the network connection:
nmcli>
activate example
WarningWhen you restart the connection, all connections currently using this connection will be temporarily interrupted.
Leave the
nmcli
interactive mode:nmcli>
quit
Optionally, verify that the route is active:
$
ip route
... 192.0.2.0/24 via 198.51.100.1 dev example proto static metric 100
21.7. Configuring a static route using nmstatectl
You can add a static route to the configuration of a network connection using the nmstatectl
utility.
The procedure in this section describes how to add a route to the 192.0.2.0/24
network that uses the gateway running on 198.51.100.1
, which is reachable through the enp1s0
interface.
Prerequisites
-
The
enp1s0
network interface is configured. - The gateway for the static route must be directly reachable on the interface.
-
The
nmstate
package is installed.
Procedure
Create a YAML file, for example
~/add-static-route-to-enp1s0.yml
, with the following contents:--- routes: config: - destination: 192.0.2.0/24 next-hop-address: 198.51.100.1 next-hop-interface: enp1s0
Apply the settings to the system:
# nmstatectl apply ~/add-static-route-to-enp1s0.yml
Additional resources
-
nmstatectl(8)
man page -
/usr/share/doc/nmstate/examples/
21.8. Configuring a static route using RHEL System Roles
You can use the Networking RHEL System Role to configure static routes.
When you run a play that uses the Networking RHEL System Role, the system role overrides an existing connection profile with the same name if the value of settings does not match the ones specified in the play. Therefore, always specify the whole configuration of the network connection profile in the play, even if, for example, the IP configuration already exists. Otherwise, the role resets these values to their defaults.
Depending on whether it already exists, the procedure creates or updates the enp7s0
connection profile with the following settings:
-
A static IPv4 address -
198.51.100.20
with a/24
subnet mask -
A static IPv6 address -
2001:db8:1::1
with a/64
subnet mask -
An IPv4 default gateway -
198.51.100.254
-
An IPv6 default gateway -
2001:db8:1::fffe
-
An IPv4 DNS server -
198.51.100.200
-
An IPv6 DNS server -
2001:db8:1::ffbb
-
A DNS search domain -
example.com
Static routes:
-
192.0.2.0/24
with gateway198.51.100.1
-
203.0.113.0/24
with gateway198.51.100.2
-
Prerequisites
-
The
ansible-core
andrhel-system-roles
packages are installed on the control node. -
If you use a different remote user than root when you run the playbook, this user has appropriate
sudo
permissions on the managed node.
Procedure
If the host on which you want to execute the instructions in the playbook is not yet inventoried, add the IP or name of this host to the
/etc/ansible/hosts
Ansible inventory file:node.example.com
Create the
~/add-static-routes.yml
playbook with the following content:--- - name: Configure an Ethernet connection with static IP and additional routes hosts: node.example.com become: true tasks: - include_role: name: rhel-system-roles.network vars: network_connections: - name: enp7s0 type: ethernet autoconnect: yes ip: address: - 198.51.100.20/24 - 2001:db8:1::1/64 gateway4: 198.51.100.254 gateway6: 2001:db8:1::fffe dns: - 198.51.100.200 - 2001:db8:1::ffbb dns_search: - example.com route: - network: 192.0.2.0 prefix: 24 gateway: 198.51.100.1 - network: 203.0.113.0 prefix: 24 gateway: 198.51.100.2 state: up
Run the playbook:
To connect as
root
user to the managed host, enter:# ansible-playbook -u root ~/add-static-routes.yml
To connect as a user to the managed host, enter:
# ansible-playbook -u user_name --ask-become-pass ~/add-static-routes.yml
The
--ask-become-pass
option makes sure that theansible-playbook
command prompts for thesudo
password of the user defined in the-u user_name
option.
If you do not specify the
-u user_name
option,ansible-playbook
connects to the managed host as the user that is currently logged in to the control node.
Verification steps
Display the routing table:
# ip -4 route default via 198.51.100.254 dev enp7s0 proto static metric 100 192.0.2.0/24 via 198.51.100.1 dev enp7s0 proto static metric 100 203.0.113.0/24 via 198.51.100.2 dev enp7s0 proto static metric 100 ...
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.network/README.md
file -
ansible-playbook(1)
man page
Chapter 22. Configuring policy-based routing to define alternative routes
By default, the kernel in RHEL decides where to forward network packets based on the destination address using a routing table. Policy-based routing enables you to configure complex routing scenarios. For example, you can route packets based on various criteria, such as the source address, packet metadata, or protocol.
This section describes of how to configure policy-based routing using NetworkManager.
On systems that use NetworkManager, only the nmcli
utility supports setting routing rules and assigning routes to specific tables.
22.1. Routing traffic from a specific subnet to a different default gateway using NetworkManager
This section describes how to configure RHEL as a router that, by default, routes all traffic to Internet provider A using the default route. Using policy-based routing, RHEL routes traffic received from the internal workstations subnet to provider B.
The procedure assumes the following network topology:
Prerequisites
-
The system uses
NetworkManager
to configure the network, which is the default. The RHEL router you want to set up in the procedure has four network interfaces:
-
The
enp7s0
interface is connected to the network of provider A. The gateway IP in the provider’s network is198.51.100.2
, and the network uses a/30
network mask. -
The
enp1s0
interface is connected to the network of provider B. The gateway IP in the provider’s network is192.0.2.2
, and the network uses a/30
network mask. -
The
enp8s0
interface is connected to the10.0.0.0/24
subnet with internal workstations. -
The
enp9s0
interface is connected to the203.0.113.0/24
subnet with the company’s servers.
-
The
-
Hosts in the internal workstations subnet use
10.0.0.1
as the default gateway. In the procedure, you assign this IP address to theenp8s0
network interface of the router. -
Hosts in the server subnet use
203.0.113.1
as the default gateway. In the procedure, you assign this IP address to theenp9s0
network interface of the router. -
The
firewalld
service is enabled and active.
Procedure
Configure the network interface to provider A:
# nmcli connection add type ethernet con-name Provider-A ifname enp7s0 ipv4.method manual ipv4.addresses 198.51.100.1/30 ipv4.gateway 198.51.100.2 ipv4.dns 198.51.100.200 connection.zone external
The
nmcli connection add
command creates a NetworkManager connection profile. The following list describes the options of the command:-
type
ethernet
: Defines that the connection type is Ethernet. -
con-name
connection_name
: Sets the name of the profile. Use a meaningful name to avoid confusion. -
ifname
network_device
: Sets the network interface. -
ipv4.method
manual
: Enables to configure a static IP address. -
ipv4.addresses
IP_address/subnet_mask
: Sets the IPv4 addresses and subnet mask. -
ipv4.gateway
IP_address
: Sets the default gateway address. -
ipv4.dns
IP_of_DNS_server
: Sets the IPv4 address of the DNS server. -
connection.zone
firewalld_zone
: Assigns the network interface to the definedfirewalld
zone. Note thatfirewalld
automatically enables masquerading for interfaces assigned to theexternal
zone.
-
Configure the network interface to provider B:
# nmcli connection add type ethernet con-name Provider-B ifname enp1s0 ipv4.method manual ipv4.addresses 192.0.2.1/30 ipv4.routes "0.0.0.0/0 192.0.2.2 table=5000" connection.zone external
This command uses the
ipv4.routes
parameter instead ofipv4.gateway
to set the default gateway. This is required to assign the default gateway for this connection to a different routing table (5000
) than the default. NetworkManager automatically creates this new routing table when the connection is activated.Configure the network interface to the internal workstations subnet:
# nmcli connection add type ethernet con-name Internal-Workstations ifname enp8s0 ipv4.method manual ipv4.addresses 10.0.0.1/24 ipv4.routes "10.0.0.0/24 table=5000" ipv4.routing-rules "priority 5 from 10.0.0.0/24 table 5000" connection.zone trusted
This command uses the
ipv4.routes
parameter to add a static route to the routing table with ID5000
. This static route for the10.0.0.0/24
subnet uses the IP of the local network interface to provider B (192.0.2.1
) as next hop.Additionally, the command uses the
ipv4.routing-rules
parameter to add a routing rule with priority5
that routes traffic from the10.0.0.0/24
subnet to table5000
. Low values have a high priority.Note that the syntax in the
ipv4.routing-rules
parameter is the same as in anip rule add
command, except thatipv4.routing-rules
always requires specifying a priority.Configure the network interface to the server subnet:
# nmcli connection add type ethernet con-name Servers ifname enp9s0 ipv4.method manual ipv4.addresses 203.0.113.1/24 connection.zone trusted
Verification steps
On a RHEL host in the internal workstation subnet:
Install the
traceroute
package:# dnf install traceroute
Use the
traceroute
utility to display the route to a host on the Internet:# traceroute redhat.com traceroute to redhat.com (209.132.183.105), 30 hops max, 60 byte packets 1 10.0.0.1 (10.0.0.1) 0.337 ms 0.260 ms 0.223 ms 2 192.0.2.1 (192.0.2.1) 0.884 ms 1.066 ms 1.248 ms ...
The output of the command displays that the router sends packets over
192.0.2.1
, which is the network of provider B.
On a RHEL host in the server subnet:
Install the
traceroute
package:# dnf install traceroute
Use the
traceroute
utility to display the route to a host on the Internet:# traceroute redhat.com traceroute to redhat.com (209.132.183.105), 30 hops max, 60 byte packets 1 203.0.113.1 (203.0.113.1) 2.179 ms 2.073 ms 1.944 ms 2 198.51.100.2 (198.51.100.2) 1.868 ms 1.798 ms 1.549 ms ...
The output of the command displays that the router sends packets over
198.51.100.2
, which is the network of provider A.
Troubleshooting steps
On the RHEL router:
Display the rule list:
# ip rule list 0: from all lookup local 5: from 10.0.0.0/24 lookup 5000 32766: from all lookup main 32767: from all lookup default
By default, RHEL contains rules for the tables
local
,main
, anddefault
.Display the routes in table
5000
:# ip route list table 5000 0.0.0.0/0 via 192.0.2.2 dev enp1s0 proto static metric 100 10.0.0.0/24 dev enp8s0 proto static scope link src 192.0.2.1 metric 102
Display the interfaces and firewall zones:
# firewall-cmd --get-active-zones external interfaces: enp1s0 enp7s0 trusted interfaces: enp8s0 enp9s0
Verify that the
external
zone has masquerading enabled:# firewall-cmd --info-zone=external external (active) target: default icmp-block-inversion: no interfaces: enp1s0 enp7s0 sources: services: ssh ports: protocols: masquerade: yes ...
Additional resources
-
The
IPv4 settings
section in thenm-settings(5)
man page -
The
Connection settings
section in thenm-settings(5)
man page -
The
Connection management commands
section in thenmcli(1)
man page - Is it possible to set up Policy Based Routing with NetworkManager in RHEL?
Chapter 23. 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.
23.1. Creating a dummy interface with both an IPv4 and IPv6 address using nmcli
You can create a dummy interface with various settings. This procedure describes how to create a dummy interface with both an IPv4 and IPv6 address. After creating the dummy interface, NetworkManager automatically assigns it to the default public
firewall zone.
To configure a dummy interface without IPv4 or IPv6 address, set the ipv4.method
and ipv6.method
parameters to disabled
. Otherwise, IP auto-configuration fails, and NetworkManager deactivates the connection and removes the dummy device.
Procedure
To create a dummy interface named dummy0 with static IPv4 and IPv6 addresses, enter:
# 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
Optional:To view the dummy interface, enter:
# nmcli connection show NAME UUID TYPE DEVICE enp1s0 db1060e9-c164-476f-b2b5-caec62dc1b05 ethernet ens3 dummy-dummy0 aaf6eb56-73e5-4746-9037-eed42caa8a65 dummy dummy0
Additional resources
- The nm-settings(5) man page
Chapter 24. Using nmstate-autoconf to automatically configure the network state using LLDP
Network devices can use the Link Layer Discovery Protocol (LLDP) to advertise their identity, capabilities, and neighbors in a LAN. The nmstate-autoconf
utility can use this information to automatically configure local network interfaces.
The nmstate-autoconf
utility is provided as a Technology Preview only. Technology Preview features are not supported with Red Hat production Service Level Agreements (SLAs), might not be functionally complete, and Red Hat does not recommend using them for production. These previews provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
See Technology Preview Features Support Scope on the Red Hat Customer Portal for information about the support scope for Technology Preview features.
24.1. Using nmstate-autoconf to automatically configure network interfaces
The nmstate-autoconf
utility uses LLDP to identify the VLAN settings of interfaces connected to a switch to configure local devices.
This procedure assumes the following scenario and that the switch broadcasts the VLAN settings using LLDP:
-
The
enp1s0
andenp2s0
interfaces of the RHEL server are connected to switch ports that are configured with VLAN ID100
and VLAN nameprod-net
. -
The
enp3s0
interface of the RHEL server is connected to a switch port that is configured with VLAN ID200
and VLAN namemgmt-net
.
The nmstate-autoconf
utility then uses this information to create the following interfaces on the server:
-
bond100
- A bond interface withenp1s0
andenp2s0
as ports. -
prod-net
- A VLAN interface on top ofbond100
with VLAN ID100
. -
mgmt-net
- A VLAN interface on top ofenp3s0
with VLAN ID200
If you connect multiple network interfaces to different switch ports for which LLDP broadcasts the same VLAN ID, nmstate-autoconf
creates a bond with these interfaces and, additionally, configures the common VLAN ID on top of it.
Prerequisites
-
The
nmstate
package is installed. - LLDP is enabled on the network switch.
- The Ethernet interfaces are up.
Procedure
Enable LLDP on the Ethernet interfaces:
Create a YAML file, for example
~/enable-lldp.yml
, with the following contents:interfaces: - name: enp1s0 type: ethernet lldp: enabled: true - name: enp2s0 type: ethernet lldp: enabled: true - name: enp3s0 type: ethernet lldp: enabled: true
Apply the settings to the system:
# nmstatectl apply ~/enable-lldp.yml
Configure the network interfaces using LLDP:
Optional, start a dry-run to display and verify the YAML configuration that
nmstate-autoconf
generates:# nmstate-autoconf -d enp1s0,enp2s0,enp3s0 --- interfaces: - name: prod-net type: vlan state: up vlan: base-iface: bond100 id: 100 - name: mgmt-net type: vlan state: up vlan: base-iface: enp3s0 id: 200 - name: bond100 type: bond state: up link-aggregation: mode: balance-rr port: - enp1s0 - enp2s0
Use
nmstate-autoconf
to generate the configuration based on information received from LLDP, and apply the settings to the system:# nmstate-autoconf enp1s0,enp2s0,enp3s0
Next steps
If there is no DHCP server in your network that provides the IP settings to the interfaces, configure them manual. For details, see:
Verification
Display the settings of the individual interfaces:
# nmstatectl show <interface_name>
Additional resources
-
The
nmstate-autoconf(8)
man page
Chapter 25. Using LLDP to debug network configuration problems
You can use the Link Layer Discovery Protocol (LLDP) to debug network configuration problems in the topology. This means that, LLDP can report configuration inconsistencies with other hosts or routers and switches.
25.1. Debugging an incorrect VLAN configuration using LLDP information
If you configured a switch port to use a certain VLAN and a host does not receive these VLAN packets, you can use the Link Layer Discovery Protocol (LLDP) to debug the problem. Perform this procedure on the host that does not receive the packets.
Prerequisites
-
The
nmstate
package is installed. - The switch supports LLDP.
- LLDP is enabled on neighbor devices.
Procedure
Create the
~/enable-LLDP-enp1s0.yml
file with the following content:interfaces: - name: enp1s0 type: ethernet lldp: enabled: true
Use the
~/enable-LLDP-enp1s0.yml
file to enable LLDP on interfaceenp1s0
:# nmstatectl apply ~/enable-LLDP-enp1s0.yml
Display the LLDP information:
# nmstatectl show enp1s0 - name: enp1s0 type: ethernet state: up ipv4: enabled: false dhcp: false ipv6: enabled: false autoconf: false dhcp: false lldp: enabled: true neighbors: - - type: 5 system-name: Summit300-48 - type: 6 system-description: Summit300-48 - Version 7.4e.1 (Build 5) 05/27/05 04:53:11 - type: 7 system-capabilities: - MAC Bridge component - Router - type: 1 _description: MAC address chassis-id: 00:01:30:F9:AD:A0 chassis-id-type: 4 - type: 2 _description: Interface name port-id: 1/1 port-id-type: 5 - type: 127 ieee-802-1-vlans: - name: v2-0488-03-0505 vid: 488 oui: 00:80:c2 subtype: 3 - type: 127 ieee-802-3-mac-phy-conf: autoneg: true operational-mau-type: 16 pmd-autoneg-cap: 27648 oui: 00:12:0f subtype: 1 - type: 127 ieee-802-1-ppvids: - 0 oui: 00:80:c2 subtype: 2 - type: 8 management-addresses: - address: 00:01:30:F9:AD:A0 address-subtype: MAC interface-number: 1001 interface-number-subtype: 2 - type: 127 ieee-802-3-max-frame-size: 1522 oui: 00:12:0f subtype: 4 mac-address: 82:75:BE:6F:8C:7A mtu: 1500
Verify the output to ensure that the settings match your expected configuration. For example, the LLDP information of the interface connected to the switch shows that the switch port this host is connected to uses VLAN ID
448
:- type: 127 ieee-802-1-vlans: - name: v2-0488-03-0505 vid: 488
If the network configuration of the
enp1s0
interface uses a different VLAN ID, change it accordingly.
Additional resources
Chapter 26. Manually creating NetworkManager profiles in keyfile format
By default, NetworkManager stores profiles in the keyfile format. For example, the nmcli
utility, the networking
RHEL System Role, or the nmstate
API to manage profiles use this format. However, NetworkManager still supports profiles in the deprecated ifcfg
format.
26.1. The keyfile format of NetworkManager profiles
NetworkManager uses the INI-style keyfile format when it stores connection profiles on disk.
Example of an Ethernet connection profile in keyfile format
[connection] id=example_connection uuid=82c6272d-1ff7-4d56-9c7c-0eb27c300029 type=ethernet autoconnect=true [ipv4] method=auto [ipv6] method=auto [ethernet] mac-address=00:53:00:8f:fa:66
Each section corresponds to a NetworkManager setting name as described in the nm-settings(5)
and nm-settings-keyfile(5)
man pages. Each key-value-pair in a section is one of the properties listed in the settings specification of the man page.
Most variables in NetworkManager keyfiles have a one-to-one mapping. This means that a NetworkManager property is stored in the keyfile as a variable of the same name and in the same format. However, there are exceptions, mainly to make the keyfile syntax easier to read. For a list of these exceptions, see the nm-settings-keyfile(5)
man page.
For security reasons, because connection profiles can contain sensitive information, such as private keys and passphrases, NetworkManager uses only configuration files owned by the root
and that are only readable and writable by root
.
Depending on the purpose of the connection profile, save it in one of the following directories:
-
/etc/NetworkManager/system-connections/
: The general location for persistent profiles created by the user that can also be edited. NetworkManager copies them automatically to/etc/NetworkManager/system-connections/
. -
/run/NetworkManager/system-connections/
: For temporary profiles that are automatically removed when you reboot the system. -
/usr/lib/NetworkManager/system-connections/
: For pre-deployed immutable profiles. When you edit such a profile using the NetworkManager API, NetworkManager copies this profile to either the persistent or temporary storage.
NetworkManager does not automatically reload profiles from disk. When you create or update a connection profile in keyfile format, use the nmcli connection reload
command to inform NetworkManager about the changes.
26.2. Creating a NetworkManager profile in keyfile format
This section explains a general procedure on how to manually create a NetworkManager connection profile in keyfile format.
Manually creating or updating the configuration files can result in an unexpected or non-functional network configuration. Red Hat recommends that you use NetworkManager utilities, such as nmcli
, the network
RHEL System Role, or the nmstate
API to manage NetworkManager connections.
Procedure
If you create a profile for a hardware interface, such as Ethernet, display the MAC address of this interface:
# ip address show enp1s0 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:53:00:8f:fa:66 brd ff:ff:ff:ff:ff:ff
Create a connection profile. For example, for a connection profile of an Ethernet device that uses DHCP, create the
/etc/NetworkManager/system-connections/example.nmconnection
file with the following content:[connection] id=example_connection type=ethernet autoconnect=true [ipv4] method=auto [ipv6] method=auto [ethernet] mac-address=00:53:00:8f:fa:66
NoteYou can use any file name with a
.nmconnection
suffix. However, when you later usenmcli
commands to manage the connection, you must use the connection name set in theid
variable when you refer to this connection. When you omit theid
variable, use the file name without the.nmconnection
to refer to this connection.Set permissions on the configuration file so that only the
root
user can read and update it:# chown root:root /etc/NetworkManager/system-connections/example.nmconnection # chmod 600 /etc/NetworkManager/system-connections/example.nmconnection
Reload the connection profiles:
# nmcli connection reload
Verify that NetworkManager read the profile from the configuration file:
# nmcli -f NAME,UUID,FILENAME connection NAME UUID FILENAME example-connection 86da2486-068d-4d05-9ac7-957ec118afba /etc/NetworkManager/system-connections/example.nmconnection ...
If the command does not show the newly added connection, verify that the file permissions and the syntax you used in the file are correct.
Optional: If you set the
autoconnect
variable in the profile tofalse
, activate the connection:# nmcli connection up example_connection
Verification
Display the connection profile:
# nmcli connection show example_connection
Display the IP settings of the interface:
# ip address show enp1s0
Additional resources
-
nm-settings-keyfile (5)
26.3. Migrating NetworkManager profiles from ifcfg to keyfile format
You can use the nmcli connection migrate
command to migrate your existing ifcfg
connection profiles to the keyfile format. This way, all your connection profiles will be in one location and in the preferred format.
Prerequisites
-
You have connection profiles in
ifcfg
format in the/etc/sysconfig/network-scripts/
directory.
Procedure
Migrate the connection profiles:
# nmcli connection migrate Connection 'enp1s0' (43ed18ab-f0c4-4934-af3d-2b3333948e45) successfully migrated. Connection 'enp2s0' (883333e8-1b87-4947-8ceb-1f8812a80a9b) successfully migrated. ...
Verification
Optionally, you can verify that you successfully migrated all your connection profiles:
# nmcli -f TYPE,FILENAME,NAME connection TYPE FILENAME NAME ethernet /etc/NetworkManager/system-connections/enp1s0.nmconnection enp1s0 ethernet /etc/NetworkManager/system-connections/enp2s0.nmconnection enp2s0 ...
Additional resources
-
nm-settings-keyfile(5)
-
nm-settings-ifcfg-rh(5)
-
nmcli(1)
26.4. Using nmcli to create keyfile connection profiles in offline mode
Red Hat recommends using NetworkManager utilities, such as nmcli
, the network
RHEL System Role, or the nmstate
API to manage NetworkManager connections, to create and update configuration files. However, you can also create various connection profiles in the keyfile format in offline mode using the nmcli --offline connection add
command.
The offline mode ensures that nmcli
operates without the NetworkManager
service to produce keyfile connection profiles through standard output. This feature can be useful if:
- You want to create your connection profiles that need to be pre-deployed somewhere. For example in a container image, or as an RPM package.
-
You want to create your connection profiles in an environment where the
NetworkManager
service is not available. For example when you want to use thechroot
utility. Alternatively, when you want to create or modify the network configuration of the RHEL system to be installed through the Kickstart%post
script.
You can create the following connection profile types:
- static Ethernet connection
- dynamic Ethernet connection
- network bond
- network bridge
- VLAN or any kind of supported connections
Manually creating or updating the configuration files can result in an unexpected or non-functional network configuration.
Prerequisites
-
The
NetworkManager
service is stopped.
Procedure
Create a new connection profile in the keyfile format. For example, for a connection profile of an Ethernet device that does not use DHCP, run a similar
nmcli
command:# nmcli --offline connection add type ethernet con-name Example-Connection ipv4.addresses 192.0.2.1/24 ipv4.dns 192.0.2.200 ipv4.method manual > /etc/NetworkManager/system-connections/output.nmconnection
NoteThe connection name you specified with the
con-name
key is saved into theid
variable of the generated profile. When you use thenmcli
command to manage this connection later, specify the connection as follows:-
When the
id
variable is not omitted, use the connection name, for exampleExample-Connection
. -
When the
id
variable is omitted, use the file name without the.nmconnection
suffix, for exampleoutput
.
-
When the
Set permissions to the configuration file so that only the
root
user can read and update it:# chmod 600 /etc/NetworkManager/system-connections/output.nmconnection # chown root:root /etc/NetworkManager/system-connections/output.nmconnection
Start the
NetworkManager
service:# systemctl start NetworkManager.service
Optional: If you set the
autoconnect
variable in the profile tofalse
, activate the connection:# nmcli connection up Example-Connection
Verification
Verify that the
NetworkManager
service is running:# systemctl status NetworkManager.service ● NetworkManager.service - Network Manager Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2022-08-03 13:08:32 CEST; 1min 40s ago Docs: man:NetworkManager(8) Main PID: 7138 (NetworkManager) Tasks: 3 (limit: 22901) Memory: 4.4M CGroup: /system.slice/NetworkManager.service └─7138 /usr/sbin/NetworkManager --no-daemon Aug 03 13:08:33 example.com NetworkManager[7138]: <info> [1659524913.3600] device (vlan20): state change: secondaries -> activated (reason 'none', sys-iface-state: 'assume') Aug 03 13:08:33 example.com NetworkManager[7138]: <info> [1659524913.3607] device (vlan20): Activation: successful, device activated. ...
Verify that NetworkManager can read the profile from the configuration file:
# nmcli -f TYPE,FILENAME,NAME connection TYPE FILENAME NAME ethernet /etc/NetworkManager/system-connections/output.nmconnection Example-Connection ethernet /etc/sysconfig/network-scripts/ifcfg-enp1s0 enp1s0 ...
If the output does not show the newly created connection, verify that the keyfile permissions and the syntax you used are correct.
Display the connection profile:
# nmcli connection show Example-Connection connection.id: Example-Connection connection.uuid: 232290ce-5225-422a-9228-cb83b22056b4 connection.stable-id: -- connection.type: 802-3-ethernet connection.interface-name: -- connection.autoconnect: yes ...
Additional resources
-
nmcli(1)
-
nm-settings-keyfile(5)
- The keyfile format of NetworkManager profiles
- Configuring a static Ethernet connection using nmcli
- Configuring a dynamic Ethernet connection using nmcli
- Configuring VLAN tagging using nmcli commands
- Configuring a network bridge using nmcli commands
- Configuring a network bond using nmcli commands
Chapter 27. Using netconsole to log kernel messages over a network
Using the netconsole
kernel module and the same-named service, you can log kernel messages over a network to debug the kernel when logging to disk fails or when using a serial console is not possible.
27.1. Configuring the netconsole service to log kernel messages to a remote host
Using the netconsole
kernel module, you can log kernel messages to a remote system log service.
Prerequisites
-
A system log service, such as
rsyslog
is installed on the remote host. - The remote system log service is configured to receive incoming log entries from this host.
Procedure
Install the
netconsole-service
package:# dnf install netconsole-service
Edit the
/etc/sysconfig/netconsole
file and set theSYSLOGADDR
parameter to the IP address of the remote host:# SYSLOGADDR=192.0.2.1
Enable and start the
netconsole
service:# systemctl enable --now netconsole
Verification steps
-
Display the
/var/log/messages
file on the remote system log server.
Additional resources
Chapter 28. Systemd network targets and services
NetworkManager configures the network during the system boot process. However, when booting with a remote root (/), such as if the root directory is stored on an iSCSI device, the network settings are applied in the initial RAM disk (initrd
) before RHEL is started. For example, if the network configuration is specified on the kernel command line using rd.neednet=1
or a configuration is specified to mount remote file systems, then the network settings are applied on initrd
.
This section describes different targets such as network
, network-online
, and NetworkManager-wait-online
service that are used while applying network settings, and how to configure the systemd
service to start after the network-online
service is started.
28.1. Differences between the network and network-online systemd target
Systemd maintains the network
and network-online
target units. The special units such as NetworkManager-wait-online.service
, have WantedBy=network-online.target
and Before=network-online.target
parameters. If enabled, these units get started with network-online.target
and delay the target to be reached until some form of network connectivity is established. They delay the network-online
target until the network is connected.
The network-online
target starts a service, which adds substantial delays to further execution. Systemd automatically adds dependencies with Wants
and After
parameters for this target unit to all the System V (SysV) init
script service units with a Linux Standard Base (LSB) header referring to the $network
facility. The LSB header is metadata for init
scripts. You can use it to specify dependencies. This is similar to the systemd
target.
The network
target does not significantly delay the execution of the boot process. Reaching the network
target means that the service that is responsible for setting up the network has started. However, it does not mean that a network device was configured. This target is important during the shutdown of the system. For example, if you have a service that was ordered after the network
target during bootup, then this dependency is reversed during the shutdown. The network does not get disconnected until your service has been stopped. All mount units for remote network file systems automatically start the network-online
target unit and order themselves after it.
The network-online
target unit is only useful during the system starts. After the system has completed booting up, this target does not track the online state of the network. Therefore, you cannot use network-online
to monitor the network connection. This target provides a one-time system startup concept.
28.2. Overview of NetworkManager-wait-online
The NetworkManager-wait-online
service waits with a timeout for the network to be configured. This network configuration involves plugging-in an Ethernet device, scanning for a Wi-Fi device, and so forth. NetworkManager automatically activates suitable profiles that are configured to start automatically. The failure of the automatic activation process due to a DHCP timeout or similar event might keep NetworkManager busy for an extended period of time. Depending on the configuration, NetworkManager retries activating the same profile or a different profile.
When the startup completes, either all profiles are in a disconnected state or are successfully activated. You can configure profiles to auto-connect. The following are a few examples of parameters that set timeouts or define when the connection is considered active:
-
connection.wait-device-timeout
- sets the timeout for the driver to detect the device -
ipv4.may-fail
andipv6.may-fail
- sets activation with one IP address family ready, or whether a particular address family must have completed configuration. -
ipv4.gateway-ping-timeout
- delays activation.
Additional resources
-
The
nm-settings(5)
man page
28.3. Configuring a systemd service to start after the network has been started
Red Hat Enterprise Linux installs systemd
service files in the /usr/lib/systemd/system/
directory. This procedure creates a drop-in snippet for a service file in /etc/systemd/system/service_name.service.d/
that is used together with the service file in /usr/lib/systemd/system/
to start a particular service after the network is online. It has a higher priority if settings in the drop-in snippet overlap with the ones in the service file in /usr/lib/systemd/system/
.
Procedure
To open the service file in the editor, enter:
# systemctl edit service_name
Enter the following, and save the changes:
[Unit] After=network-online.target
Reload the
systemd
service.# systemctl daemon-reload
Chapter 29. Linux traffic control
Linux offers tools for managing and manipulating the transmission of packets. The Linux Traffic Control (TC) subsystem helps in policing, classifying, shaping, and scheduling network traffic. TC also mangles the packet content during classification by using filters and actions. The TC subsystem achieves this by using queuing disciplines (qdisc
), a fundamental element of the TC architecture.
The scheduling mechanism arranges or rearranges the packets before they enter or exit different queues. The most common scheduler is the First-In-First-Out (FIFO) scheduler. You can do the qdiscs
operations temporarily using the tc
utility or permanently using NetworkManager.
This section explains queuing disciplines and describes how to update the default qdiscs
in RHEL.
29.1. Overview of queuing disciplines
Queuing disciplines (qdiscs
) help with queuing up and, later, scheduling of traffic transmission by a network interface. A qdisc
has two operations;
- enqueue requests so that a packet can be queued up for later transmission and
- dequeue requests so that one of the queued-up packets can be chosen for immediate transmission.
Every qdisc
has a 16-bit hexadecimal identification number called a handle
, with an attached colon, such as 1:
or abcd:
. This number is called the qdisc
major number. If a qdisc
has classes, then the identifiers are formed as a pair of two numbers with the major number before the minor, <major>:<minor>
, for example abcd:1
. The numbering scheme for the minor numbers depends on the qdisc
type. Sometimes the numbering is systematic, where the first-class has the ID <major>:1
, the second one <major>:2
, and so on. Some qdiscs
allow the user to set class minor numbers arbitrarily when creating the class.
- Classful
qdiscs
Different types of
qdiscs
exist and help in the transfer of packets to and from a networking interface. You can configureqdiscs
with root, parent, or child classes. The point where children can be attached are called classes. Classes inqdisc
are flexible and can always contain either multiple children classes or a single child,qdisc
. There is no prohibition against a class containing a classfulqdisc
itself, this facilitates complex traffic control scenarios.Classful
qdiscs
do not store any packets themselves. Instead, they enqueue and dequeue requests down to one of their children according to criteria specific to theqdisc
. Eventually, this recursive packet passing ends up where the packets are stored (or picked up from in the case of dequeuing).- Classless
qdiscs
-
Some
qdiscs
contain no child classes and they are called classlessqdiscs
. Classlessqdiscs
require less customization compared to classfulqdiscs
. It is usually enough to attach them to an interface.
Additional resources
-
tc(8)
man page -
tc-actions.8
man page
29.2. Available qdiscs in RHEL
Each qdisc
addresses unique networking-related issues. The following is the list of qdiscs
available in RHEL. You can use any of the following qdisc
to shape network traffic based on your networking requirements.
Table 29.1. Available schedulers in RHEL
qdisc name | Included in | Offload support |
---|---|---|
Asynchronous Transfer Mode (ATM) |
| |
Class-Based Queueing |
| |
Credit-Based Shaper |
| Yes |
CHOose and Keep for responsive flows, CHOose and Kill for unresponsive flows (CHOKE) |
| |
Controlled Delay (CoDel) |
| |
Deficit Round Robin (DRR) |
| |
Differentiated Services marker (DSMARK) |
| |
Enhanced Transmission Selection (ETS) |
| Yes |
Fair Queue (FQ) |
| |
Fair Queuing Controlled Delay (FQ_CODel) |
| |
Generalized Random Early Detection (GRED) |
| |
Hierarchical Fair Service Curve (HSFC) |
| |
Heavy-Hitter Filter (HHF) |
| |
Hierarchy Token Bucket (HTB) |
| |
INGRESS |
| Yes |
Multi Queue Priority (MQPRIO) |
| Yes |
Multiqueue (MULTIQ) |
| Yes |
Network Emulator (NETEM) |
| |
Proportional Integral-controller Enhanced (PIE) |
| |
PLUG |
| |
Quick Fair Queueing (QFQ) |
| |
Random Early Detection (RED) |
| Yes |
Stochastic Fair Blue (SFB) |
| |
Stochastic Fairness Queueing (SFQ) |
| |
Token Bucket Filter (TBF) |
| Yes |
Trivial Link Equalizer (TEQL) |
|
The qdisc
offload requires hardware and driver support on NIC.
Additional resources
-
The
tc(8)
,cbq
,cbs
,choke
,CoDel
,drr
,fq
,htb
,mqprio
,netem
,pie
,sfb
,pfifo
,tc-red
,sfq
,tbf
, andprio
man pages.
29.3. Inspecting qdiscs of a network interface using the tc utility
By default, Red Hat Enterprise Linux systems use fq_codel
qdisc
. This procedure describes how to inspect qdisc
counters.
Procedure
Optional: View your current
qdisc
:# tc qdisc show dev enp0s1
Inspect the current
qdisc
counters:# tc -s qdisc show dev enp0s1 qdisc fq_codel 0: root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn Sent 1008193 bytes 5559 pkt (dropped 233, overlimits 55 requeues 77) backlog 0b 0p requeues 0 ....
-
dropped
- the number of times a packet is dropped because all queues are full -
overlimits
- the number of times the configured link capacity is filled -
sent
- the number of dequeues
29.4. Updating the default qdisc
If you observe networking packet losses with the current qdisc
, you can change the qdisc
based on your network-requirements. You can select the qdisc
, which meets your network requirements. This procedure describes how to change the default qdisc
in Red Hat Enterprise Linux.
Procedure
View the current default
qdisc
:# sysctl -a | grep qdisc net.core.default_qdisc = fq_codel
View the
qdisc
of current Ethernet connection:# tc -s qdisc show dev enp0s1 qdisc fq_codel 0: root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 maxpacket 0 drop_overlimit 0 new_flow_count 0 ecn_mark 0 new_flows_len 0 old_flows_len 0
Update the existing
qdisc
:# sysctl -w net.core.default_qdisc=pfifo_fast
To apply the changes, reload the network driver:
# rmmod NETWORKDRIVERNAME
# modprobe NETWORKDRIVERNAME
Start the network interface:
# ip link set enp0s1 up
Verification steps
View the
qdisc
of the Ethernet connection:# tc -s qdisc show dev enp0s1 qdisc pfifo_fast 0: root refcnt 2 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1 Sent 373186 bytes 5333 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 ....
Additional resources
29.5. Temporarily setting the current qdisk of a network interface using the tc utility
You can update the current qdisc
without changing the default one. This procedure describes how to change the current qdisc
in Red Hat Enterprise Linux.
Procedure
Optional: View the current
qdisc
:# tc -s qdisc show dev enp0s1
Update the current
qdisc
:# tc qdisc replace dev enp0s1 root htb
Verification step
View the updated current
qdisc
:# tc -s qdisc show dev enp0s1 qdisc htb 8001: root refcnt 2 r2q 10 default 0 direct_packets_stat 0 direct_qlen 1000 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
29.6. Permanently setting the current qdisk of a network interface using NetworkManager
You can update the current qdisc
value of a NetworkManager connection.
Procedure
Optional: View the current
qdisc
:# tc qdisc show dev enp0s1 qdisc fq_codel 0: root refcnt 2
Update the current
qdisc
:# nmcli connection modify enp0s1 tc.qdiscs ‘root pfifo_fast’
Optional: To add another
qdisc
over the existingqdisc
, use the+tc.qdisc
option:# nmcli connection modify enp0s1 +tc.qdisc ‘ingress handle ffff:’
Activate the changes:
# nmcli connection up enp0s1
Verification steps
View current
qdisc
the network interface:# tc qdisc show dev enp0s1 qdisc pfifo_fast 8001: root refcnt 2 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1 qdisc ingress ffff: parent ffff:fff1 ----------------
Additional resources
-
nm-settings(5)
man page
Chapter 30. Getting started with Multipath TCP
Multipath TCP (MPTCP) is an extension to the Transmission Control Protocol (TCP). Using Internet Protocol (IP), a host can send packets to a destination. TCP ensures reliable delivery of the data through the Internet and automatically adjusts its bandwidth in response to network load.
This section describes how to:
- Create a new MPTCP connection
- Enable the server to use MPTCP
- Disable MPTCP in the kernel
It also includes the advantages of using MPTCP.
30.1. MPTCP benefits
The Multipath TCP (MPTCP) design improves connection stability. Note, that in MPTCP terminology, links are considered as paths.
The following are the advantages of MPTCP:
- It allows a connection to simultaneously use multiple network interfaces.
- In case a connection is bound to a link speed, the usage of multiple links can increase the connection throughput. Note, that in case of the connection is bound to a CPU, the usage of multiple links causes the connection slowdown.
- It increases the resilience to link failures.
30.2. Preparing RHEL to enable MPTCP support
By default the MPTCP support is disabled in RHEL. Enable MPTCP so that applications that support this feature can use it. Additionally, you have to configure user space applications to force use MPTCP sockets if those applications have TCP sockets by default.
Prerequisites
The following packages are installed:
-
iperf3
-
mptcpd
Procedure
Enable MPTCP sockets in the kernel:
# echo "net.mptcp.enabled=1" > /etc/sysctl.d/90-enable-MPTCP.conf # sysctl -p /etc/sysctl.d/90-enable-MPTCP.conf
Start the
iperf3
server, and force it to create MPTCP sockets instead of TCP sockets:# mptcpize run iperf3 -s Server listening on 5201
Connect the client to the server, and force it to create MPTCP sockets instead of TCP sockets:
# mptcpize iperf3 -c 127.0.0.1 -t 3
After the connection is established, verify the
ss
output to see the subflow-specific status:# ss -nti '( dport :5201 )' State Recv-Q Send-Q Local Address:Port Peer Address:Port Process ESTAB 0 0 127.0.0.1:41842 127.0.0.1:5201 cubic wscale:7,7 rto:205 rtt:4.455/8.878 ato:40 mss:21888 pmtu:65535 rcvmss:536 advmss:65483 cwnd:10 bytes_sent:141 bytes_acked:142 bytes_received:4 segs_out:8 segs_in:7 data_segs_out:3 data_segs_in:3 send 393050505bps lastsnd:2813 lastrcv:2772 lastack:2772 pacing_rate 785946640bps delivery_rate 10944000000bps delivered:4 busy:41ms rcv_space:43690 rcv_ssthresh:43690 minrtt:0.008 tcp-ulp-mptcp flags:Mmec token:0000(id:0)/2ff053ec(id:0) seq:3e2cbea12d7673d4 sfseq:3 ssnoff:ad3d00f4 maplen:2
Verify MPTCP counters by using
nstat MPTcp*
command:# nstat MPTcp* #kernel MPTcpExtMPCapableSYNRX 2 0.0 MPTcpExtMPCapableSYNTX 2 0.0 MPTcpExtMPCapableSYNACKRX 2 0.0 MPTcpExtMPCapableACKRX 2 0.0
Additional resources
-
tcp(7)
man page -
mptcpize(8)
man page
30.3. Using iproute2 to configure and enable multiple paths for MPTCP applications
Each MPTCP connection uses a single subflow similar to plain TCP. To leverage the MPTCP benefits specify a higher limit for maximum number of subflows for each MPTCP connection and configure additional endpoints to create those subflows.
Note that MPTCP does not yet support mixed IPv6 and IPv4 endpoints for the same socket. Use endpoints belonging to the same address family.
Prerequisites
-
The
mptcpd
package is installed -
The
iperf3
package is installed Server network interface settings:
- enp4s0: 192.0.2.1/24
- enp1s0: 198.51.100.1/24
Client network interface settings:
- enp4s0f0: 192.0.2.2/24
- enp4s0f1: 198.51.100.2/24
Procedure
Set the per connection additional subflow limits to
1
on the server:# ip mptcp limits set subflow 1
Note, that sets a maximum number of additional subflows which each connection can have, excluding the initial one.
Set the per connection and additional subflow limits to
1
on the client:# ip mptcp limits set subflow 1 add_addr_accepted 1
Add IP address
198.51.100.1
as a new MPTCP endpoint on the server:# ip mptcp endpoint add 198.51.100.1 dev enp1s0 signal
ImportantYou can set the following values for flags to
subflow
,backup
,signal
. Setting the flag to;-
signal
, sends anADD_ADDR
packet after the three-way-handshake is completed -
subflow
, sends anMP_JOIN SYN
by the client -
backup
, sets the endpoint as a backup address
-
Start the
iperf3
server, and force it to create MPTCP sockets instead of TCP sockets:# mptcpize run iperf3 -s Server listening on 5201
Connect the client to the server, and force it to create MPTCP sockets instead of TCP sockets:
# mptcpize iperf3 -c 192.0.2.1 -t 3
Verification steps
Verify the connection is established:
# ss -nti '( sport :5201 )'
Verify the connection and IP address limit:
# ip mptcp limit show
Verify the newly added endpoint:
# ip mptcp endpoint show
Verify MPTCP counters by using the
nstat MPTcp*
command on a server:# nstat MPTcp* #kernel MPTcpExtMPCapableSYNRX 2 0.0 MPTcpExtMPCapableACKRX 2 0.0 MPTcpExtMPJoinSynRx 2 0.0 MPTcpExtMPJoinAckRx 2 0.0 MPTcpExtEchoAdd 2 0.0
Additional resources
-
ip-mptcp(8)
man page -
mptcpize(8)
man page
30.4. Monitoring MPTCP sub-flows
The life cycle of a multipath TCP (MPTCP) socket can be complex: The main MPTCP socket is created, the MPTCP path is validated, one or more sub-flows are created and eventually removed. Finally, the MPTCP socket is terminated.
The MPTCP protocol allows monitoring MPTCP-specific events related to socket and sub-flow creation and deletion, using the ip
utility provided by the iproute
package. This utility uses the netlink
interface to monitor MPTCP events.
This procedure demonstrates how to monitor MPTCP events. For that, it simulates a MPTCP server application, and a client connects to this service. The involved clients in this example use the following interfaces and IP addresses:
-
Server:
192.0.2.1
-
Client (Ethernet connection):
192.0.2.2
-
Client (WiFi connection):
192.0.2.3
To simplify this example, all interfaces are within the same subnet. This is not a requirement. However, it is important that routing has been configured correctly, and the client can reach the server via both interfaces.
Prerequisites
- A RHEL client with two network interfaces, such as a laptop with Ethernet and WiFi
- The client can connect to the server via both interfaces
- A RHEL server
- Both the client and the server run RHEL 9.0 or later
-
You installed the
mptcpd
package on both the client and the server
Procedure
Set the per connection additional subflow limits to
1
on both client and server:# ip mptcp limits set add_addr_accepted 0 subflows 1
On the server, to simulate a MPTCP server application, start
netcat
(nc
) in listen mode with enforced MPTCP sockets instead of TCP sockets:# mptcpize run nc -l -k -p 12345
The
-k
option causes thatnc
does not close the listener after the first accepted connection. This is required to demonstrate the monitoring of sub-flows.On the client:
Identify the interface with the lowest metric:
# ip -4 route 192.0.2.0/24 dev enp1s0 proto kernel scope link src 192.0.2.2 metric 100 192.0.2.0/24 dev wlp1s0 proto kernel scope link src 192.0.2.3 metric 600
The
enp1s0
interface has a lower metric thanwlp1s0
. Therefore, RHEL usesenp1s0
by default.On the first terminal, start the monitoring:
# ip mptcp monitor
On the second terminal, start a MPTCP connection to the server:
# mptcpize run nc 192.0.2.1 12345
RHEL uses the
enp1s0
interface and its associated IP address as a source for this connection.On the monitoring terminal, the `ip mptcp monitor ` command now logs:
[ CREATED] token=63c070d2 remid=0 locid=0 saddr4=192.0.2.2 daddr4=192.0.2.1 sport=36444 dport=12345
The token identifies the MPTCP socket as an unique ID, and later it enables you to correlate MPTCP events on the same socket.
On the terminal with the running
nc
connection to the server, press Enter. This first data packet fully establishes the connection. Note that, as long as no data has been sent, the connection is not established.On the monitoring terminal,
ip mptcp monitor
now logs:[ ESTABLISHED] token=63c070d2 remid=0 locid=0 saddr4=192.0.2.2 daddr4=192.0.2.1 sport=36444 dport=12345
Optional: Display the connections to port
12345
on the server:# ss -taunp | grep ":12345" tcp ESTAB 0 0 192.0.2.2:36444 192.0.2.1:12345
At this point, only one connection to the server has been established.
On a third terminal, create another