Select Your Language

Infrastructure and management.

  • Red Hat Enterprise Linux
  • Red Hat Satellite
  • Red Hat Subscription Management
  • Red Hat Insights
  • Red Hat Ansible Automation Platform

Cloud Computing

  • Red Hat OpenShift
  • Red Hat OpenStack Platform
  • Red Hat OpenShift Container Platform
  • Red Hat OpenShift AI
  • Red Hat OpenShift Dedicated
  • Red Hat Advanced Cluster Security for Kubernetes
  • Red Hat Advanced Cluster Management for Kubernetes
  • Red Hat Quay
  • OpenShift Dev Spaces
  • Red Hat OpenShift Service on AWS
  • Red Hat Gluster Storage
  • Red Hat Hyperconverged Infrastructure
  • Red Hat Ceph Storage
  • Red Hat OpenShift Data Foundation
  • Red Hat Runtimes
  • Red Hat JBoss Enterprise Application Platform
  • Red Hat Data Grid
  • Red Hat JBoss Web Server
  • Red Hat build of Keycloak
  • Red Hat support for Spring Boot
  • Red Hat build of Node.js
  • Red Hat build of Quarkus

Integration and Automation

  • Red Hat Application Foundations
  • Red Hat Fuse
  • Red Hat AMQ
  • Red Hat 3scale API Management
  • Single-page

Language and Page Formatting Options

Red hat training.

A Red Hat training course is available for RHEL 8

Configuring and managing networking

Managing network interfaces, firewalls, and advanced networking features.

  • You can configure bonds, VLANs, bridges, tunnels and other network types to connect the host to the network.
  • You can build performance-critical firewalls for the local host and the entire network. RHEL contains packet filtering software, such as the firewalld service, the nftables framework, and Express Data Path (XDP).
  • RHEL also supports advanced networking features, such as policy-based routing and MultiPath TCP (MPTCP).

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 feedback on our documentation. Let us know how we can improve it.

Submitting feedback through Jira (account required)

  • Log in to the Jira website.
  • Click Create in the top navigation bar.
  • Enter a descriptive title in the Summary field.
  • Enter your suggestion for improvement in the Description field. Include links to the relevant parts of the documentation.
  • Click Create at the bottom of the dialogue.

Chapter 1. Implementing consistent network interface naming

The udev device manager implements consistent device naming in Red Hat Enterprise Linux. The device manager supports different naming schemes and, by default, assigns fixed names based on firmware, topology, and location information.

Without consistent device naming, the Linux kernel assigns names to network interfaces by combining a fixed prefix and an index. The index increases as the kernel initializes the network devices. For example, eth0 represents the first Ethernet device being probed on start-up. If you add another network interface controller to the system, the assignment of the kernel device names is no longer fixed because, after a reboot, the devices can initialize in a different order. In that case, the kernel can name the devices differently.

To solve this problem, udev assigns consistent device names. This has the following advantages:

  • Device names are stable across reboots.
  • Device names stay fixed even if you add or remove hardware.
  • Defective hardware can be seamlessly replaced.
  • The network naming is stateless and does not require explicit configuration files.

Generally, Red Hat does not support systems where consistent device naming is disabled. For exceptions, see the Is it safe to set net.ifnames=0 solution.

1.1. How the udev device manager renames network interfaces

To implement a consistent naming scheme for network interfaces, the udev device manager processes the following rule files in the listed order:

Optional: /usr/lib/udev/rules.d/60-net.rules

The /usr/lib/udev/rules.d/60-net.rules file defines that the deprecated /usr/lib/udev/rename_device helper utility searches for the HWADDR 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 the DEVICE parameter of the ifcfg file.

If the system uses only NetworkManager connection profiles in keyfile format, udev skips this step.

Only on Dell systems: /usr/lib/udev/rules.d/71-biosdevname.rules

This file exists only if the biosdevname package is installed, and the rules file defines that the biosdevname utility renames the interface according to its naming policy, if it was not renamed in the previous step.

Install and use biosdevname only on Dell systems.

/usr/lib/udev/rules.d/75-net-description.rules

This file defines how udev examines the network interface and sets the properties in udev -internal variables. These variables are then processed in the next step by the /usr/lib/udev/rules.d/80-net-setup-link.rules file. Some of the properties can be undefined.

/usr/lib/udev/rules.d/80-net-setup-link.rules

This file calls the net_setup_link builtin of the udev service, and udev renames the interface based on the order of the policies in the NamePolicy parameter in the /usr/lib/systemd/network/99-default.link file. For further details, see Network interface naming policies .

If none of the policies applies, udev does not rename the interface.

Additional resources

  • Why are systemd network interface names different between major RHEL versions solution

1.2. Network interface naming policies

By default, the udev device manager uses the /usr/lib/systemd/network/99-default.link file to determine which device naming policies to apply when it renames interfaces. The NamePolicy parameter in this file defines which policies udev uses and in which order:

The following table describes the different actions of udev based on which policy matches first as specified by the NamePolicy parameter:

  • How the udev device manager renames network interfaces
  • systemd.link(5) man page

1.3. Network interface naming schemes

The udev device manager uses certain stable interface attributes to generate consistent device names. For details about the naming schemes for different device types and platforms, see the systemd.net-naming-scheme(7) man page.

1.4. Determining a predictable RoCE device name on the IBM Z platform

On Red Hat Enterprise Linux (RHEL) 8.7 and later, the udev device manager sets names for RoCE interfaces on IBM Z as follows:

  • If the host enforces a unique identifier (UID) for a device, udev assigns a consistent device name that is based on the UID, for example eno <UID_in_decimal> .

If the host does not enforce a UID for a device, the behavior depends on your settings:

  • By default, udev uses unpredictable names for the device.
  • If you set the net.naming-scheme=rhel-8.7 kernel command line option, udev assigns a consistent device name that is based on the function identifier (FID) of the device, for example ens <FID_in_decimal> .

Manually configure predictable device name for RoCE interfaces on IBM Z in the following cases:

Your host runs RHEL 8.6 or earlier and enforces a UID for a device, and you plan to update to RHEL 8.7 or later.

After an update to RHEL 8.7 or later, udev uses consistent interface names. However, if you used unpredictable device names before the update, NetworkManager connection profiles still use these names and fail to activate until you update the affected profiles.

  • Your host runs RHEL 8.7 or later and does not enforce a UID, and you plan to upgrade to RHEL 9.

Before you can use a udev rule or a systemd link file to rename an interface manually, you must determine a predictable device name.

Prerequisites

  • An RoCE controller is installed in the system.
  • The sysfsutils package is installed.

Display the available network devices, and note the names of the RoCE devices:

Display the device path in the /sys/ file system:

Use the path shown in the Device path field in the next steps.

Display the value of the <device_path> /uid_id_unique file, for example:

The displayed value indicates whether UID uniqueness is enforced or not, and you require this value in later steps.

Determine a unique identifier:

If UID uniqueness is enforced ( 1 ), display the UID stored in the <device_path> /uid file, for example:

If UID uniqueness is not enforced ( 0 ), display the FID stored in the <device_path> /function_id file, for example:

The outputs of the commands display the UID and FID values in hexadecimal.

Convert the hexadecimal identifier to decimal, for example:

To determine the predictable device name, append the identifier in decimal format to the corresponding prefix based on whether UID uniqueness is enforced or not:

  • If UID uniqueness is enforced, append the identifier to the eno prefix, for example eno5122 .
  • If UID uniqueness is not enforced, append the identifier to the ens prefix, for example ens5122 .

Use one of the following methods to rename the interface to the predictable name:

  • Configuring user-defined network interface names by using udev rules
  • Configuring user-defined network interface names by using systemd link files
  • IBM documentation: Network interface names
  • systemd.net-naming-scheme(7) man page

1.5. Customizing the prefix for Ethernet interfaces during installation

If you do not want to use the default device-naming policy for Ethernet interfaces, you can set a custom device prefix during the Red Hat Enterprise Linux (RHEL) installation.

Red Hat supports systems with customized Ethernet prefixes only if you set the prefix during the RHEL installation. Using the prefixdevname utility on already deployed systems is not supported.

If you set a device prefix during the installation, the udev service uses the <prefix><index> format for Ethernet interfaces after the installation. For example, if you set the prefix net , the service assigns the names net0 , net1 , and so on to the Ethernet interfaces.

The udev service appends the index to the custom prefix, and preserves the index values of known Ethernet interfaces. If you add an interface, udev assigns an index value that is one greater than the previously-assigned index value to the new interface.

  • The prefix consists of ASCII characters.
  • The prefix is an alphanumeric string.
  • The prefix is shorter than 16 characters.
  • The prefix does not conflict with any other well-known network interface prefix, such as eth , eno , ens , and em .
  • Boot the Red Hat Enterprise Linux installation media.

In the boot manager, follow these steps:

  • Select the Install Red Hat Enterprise Linux <version> entry.
  • Press Tab to edit the entry.
  • Append net.ifnames.prefix= <prefix> to the kernel options.
  • Press Enter to start the installation program.
  • Install Red Hat Enterprise Linux.

Verification

To verify the interface names, display the network interfaces:

  • Performing a standard RHEL 8 installation

1.6. Configuring user-defined network interface names by using udev rules

You can use udev rules to implement custom network interface names that reflect your organization’s requirements.

Identify the network interface that you want to rename:

Record the MAC address of the interface.

Display the device type ID of the interface:

Create the /etc/udev/rules.d/70-persistent-net.rules file, and add a rule for each interface that you want to rename:

Use only 70-persistent-net.rules as a file name if you require consistent device names during the boot process. The dracut utility adds a file with this name to the initrd image if you regenerate the RAM disk image.

For example, use the following rule to rename the interface with MAC address 00:00:5e:00:53:1a to provider0 :

Optional: Regenerate the initrd RAM disk image:

You require this step only if you need networking capabilities in the RAM disk. For example, this is the case if the root file system is stored on a network device, such as iSCSI.

Identify which NetworkManager connection profile uses the interface that you want to rename:

Unset the connection.interface-name property in the connection profile:

Temporarily, configure the connection profile to match both the new and the previous interface name:

Reboot the system:

Verify that the device with the MAC address that you specified in the link file has been renamed to provider0 :

Configure the connection profile to match only the new interface name:

You have now removed the old interface name from the connection profile.

Reactivate the connection profile:

  • udev(7) man page

1.7. Configuring user-defined network interface names by using systemd link files

You can use systemd link files to implement custom network interface names that reflect your organization’s requirements.

  • You must meet one of these conditions: NetworkManager does not manage this interface, or the corresponding connection profile uses the keyfile format .

If it does not already exist, create the /etc/systemd/network/ directory:

For each interface that you want to rename, create a 70-*.link file in the /etc/systemd/network/ directory with the following content:

Use a file name with a 70- prefix to keep the file names consistent with the udev rules-based solution.

For example, create the /etc/systemd/network/70-provider0.link file with the following content to rename the interface with MAC address 00:00:5e:00:53:1a to provider0 :

Reactivate the connection profile.

1.8. Assigning alternative names to a network interface by using systemd link files

With alternative interface naming, the kernel can assign additional names to network interfaces. You can use these alternative names in the same way as the normal interface names in commands that require a network interface name.

  • You must use ASCII characters for the alternative name.
  • The alternative name must be shorter than 128 characters.

Display the network interface names and their MAC addresses:

Record the MAC address of the interface to which you want to assign an alternative name.

For each interface that must have an alternative name, create a *.link file in the /etc/systemd/network/ directory with the following content:

For example, create the /etc/systemd/network/70-altname.link file with the following content to assign provider as an alternative name to the interface with MAC address 00:00:5e:00:53:1a :

Regenerate the initrd RAM disk image:

Use the alternative interface name. For example, display the IP address settings of the device with the alternative name provider :

  • What is AlternativeNamesPolicy in Interface naming scheme?

Chapter 2. Configuring an Ethernet connection

NetworkManager creates a connection profile for each Ethernet adapter that is installed in a host. By default, this profile uses DHCP for both IPv4 and IPv6 connections. Modify this automatically-created profile or add a new one in the following cases:

  • The network requires custom settings, such as a static IP address configuration.
  • You require multiple profiles because the host roams among different networks.

Red Hat Enterprise Linux provides administrators different options to configure Ethernet connections. For example:

  • Use nmcli to configure connections on the command line.
  • Use nmtui to configure connections in a text-based user interface.
  • Use the GNOME Settings menu or nm-connection-editor application to configure connections in a graphical interface.
  • Use nmstatectl to configure connections through the Nmstate API.
  • Use RHEL System Roles to automate the configuration of connections on one or multiple hosts.

If you want to manually configure Ethernet connections on hosts running in the Microsoft Azure cloud, disable the cloud-init service or configure it to ignore the network settings retrieved from the cloud environment. Otherwise, cloud-init will override on the next reboot the network settings that you have manually configured.

2.1. Configuring an Ethernet connection by using nmcli

If you connect a host to the network over Ethernet, you can manage the connection’s settings on the command line by using the nmcli utility.

  • A physical or virtual Ethernet Network Interface Controller (NIC) exists in the server’s configuration.

List the NetworkManager connection profiles:

By default, NetworkManager creates a profile for each NIC in the host. If you plan to connect this NIC only to a specific network, adapt the automatically-created profile. If you plan to connect this NIC to networks with different settings, create individual profiles for each network.

If you want to create an additional connection profile, enter:

Skip this step to modify an existing profile.

Optional: Rename the connection profile:

On hosts with multiple profiles, a meaningful name makes it easier to identify the purpose of a profile.

Display the current settings of the connection profile:

Configure the IPv4 settings:

To use DHCP, enter:

Skip this step if ipv4.method is already set to auto (default).

To set a static IPv4 address, network mask, default gateway, DNS servers, and search domain, enter:

Configure the IPv6 settings:

To use stateless address autoconfiguration (SLAAC), enter:

Skip this step if ipv6.method is already set to auto (default).

To set a static IPv6 address, network mask, default gateway, DNS servers, and search domain, enter:

To customize other settings in the profile, use the following command:

Enclose values with spaces or semicolons in quotes.

Activate the profile:

Display the IP settings of the NIC:

Display the IPv4 default gateway:

Display the IPv6 default gateway:

Display the DNS settings:

If multiple connection profiles are active at the same time, the order of nameserver entries depend on the DNS priority values in these profile and the connection types.

Use the ping utility to verify that this host can send packets to other hosts:

Troubleshooting

  • Verify that the network cable is plugged-in to the host and a switch.
  • Check whether the link failure exists only on this host or also on other hosts connected to the same switch.
  • Verify that the network cable and the network interface are working as expected. Perform hardware diagnosis steps and replace defect cables and network interface cards.
  • If the configuration on the disk does not match the configuration on the device, starting or restarting NetworkManager creates an in-memory connection that reflects the configuration of the device. For further details and how to avoid this problem, see the NetworkManager duplicates a connection after restart of NetworkManager service solution.
  • nm-settings(5) man page
  • Configuring NetworkManager to avoid using a specific profile to provide a default gateway
  • Configuring the order of DNS servers

2.2. Configuring an Ethernet connection by using the nmcli interactive editor

Start nmcli in interactive mode:

To create an additional connection profile, enter:

To modify an existing connection profile, enter:

Do not use quotes to set an ID that contains spaces to avoid that nmcli makes the quotes part of the name. For example, to set Example Connection as ID, enter set connection.id Example Connection .

If you create a new connection profile, set the network interface:

Save and activate the connection:

Leave the interactive mode:

  • If the configuration on the disk does not match the configuration on the device, starting or restarting NetworkManager creates an in-memory connection that reflects the configuration of the device. For further details and how to avoid this problem, see the NetworkManager duplicates a connection after restart of NetworkManager service solution
  • nmcli(1) man page

2.3. Configuring an Ethernet connection by using nmtui

If you connect a host to the network over Ethernet, you can manage the connection’s settings in a text-based user interface by using the nmtui application. Use nmtui to create new profiles and to update existing ones on a host without a graphical interface.

  • Navigate by using the cursor keys.
  • Press a button by selecting it and hitting Enter .
  • Select and deselect checkboxes by using Space .

If you do not know the network device name you want to use in the connection, display the available devices:

Start nmtui :

  • Select Edit a connection , and press Enter .

Choose whether to add a new connection profile or to modify an existing one:

To create a new profile:

  • Press the Add button.
  • Select Ethernet from the list of network types, and press Enter .
  • To modify an existing profile, select the profile from the list, and press Enter .

Optional: Update the name of the connection profile.

  • If you create a new connection profile, enter the network device name into the Device field.

Depending on your environment, configure the IP address settings in the IPv4 configuration and IPv6 configuration areas accordingly. For this, press the button next to these areas, and select:

  • Disabled , if this connection does not require an IP address.
  • Automatic , if a DHCP server dynamically assigns an IP address to this NIC.

Manual , if the network requires static IP address settings. In this case, you must fill further fields:

  • Press the Show button next to the protocol you want to configure to display additional fields.

Press the Add button next to Addresses , and enter the IP address and the subnet mask in Classless Inter-Domain Routing (CIDR) format.

If you do not specify a subnet mask, NetworkManager sets a /32 subnet mask for IPv4 addresses and /64 for IPv6 addresses.

  • Enter the address of the default gateway.
  • Press the Add button next to DNS servers , and enter the DNS server address.
  • Press the Add button next to Search domains , and enter the DNS search domain.

Figure 2.1. Example of an Ethernet connection with static IP address settings

nmtui ethernet static IP

Press the OK button to create and automatically activate the new connection.

  • Press the Back button to return to the main menu.
  • Select Quit , and press Enter to close the nmtui application.

2.4. Configuring an Ethernet connection by using control-center

If you connect a host to the network over Ethernet, you can manage the connection’s settings with a graphical interface by using the GNOME Settings menu.

Note that control-center does not support as many configuration options as the nm-connection-editor application or the nmcli utility.

  • GNOME is installed.
  • Press the Super key, enter Settings , and press Enter .
  • Select Network in the navigation on the left.
  • To create a new profile, click the + button next to the Ethernet entry.
  • To modify an existing profile, click the gear icon next to the profile entry.

Optional: On the Identity tab, update the name of the connection profile.

Depending on your environment, configure the IP address settings on the IPv4 and IPv6 tabs accordingly:

  • To use DHCP or IPv6 stateless address autoconfiguration (SLAAC), select Automatic (DHCP) as method (default).

To set a static IP address, network mask, default gateway, DNS servers, and search domain, select Manual as method, and fill the fields on the tabs:

IP settings gnome settings

Depending on whether you add or modify a connection profile, click the Add or Apply button to save the connection.

The GNOME control-center automatically activates the connection.

Troubleshooting steps

Additional Resources

2.5. Configuring an Ethernet connection by using nm-connection-editor

If you connect a host to the network over Ethernet, you can manage the connection’s settings with a graphical interface by using the nm-connection-editor application.

Open a terminal, and enter:

  • Click the + button
  • Select Ethernet as connection type, and click Create .
  • To modify an existing profile, double-click the profile entry.

Optional: Update the name of the profile in the Connection Name field.

If you create a new profile, select the device on the Ethernet tab:

ethernet connection settings

Depending on your environment, configure the IP address settings on the IPv4 Settings and IPv6 Settings tabs accordingly:

IP settings nm connection editor

  • Click Save .
  • Close nm-connection-editor .

2.6. Configuring an Ethernet connection with a static IP address by using nmstatectl

Use the nmstatectl utility to configure an Ethernet connection through the Nmstate API. The Nmstate API ensures that, after setting the configuration, the result matches the configuration file. If anything fails, nmstatectl automatically rolls back the changes to avoid leaving the system in an incorrect state.

  • The nmstate package is installed.

Create a YAML file, for example ~/create-ethernet-profile.yml , with the following content:

These settings define an Ethernet connection profile for the enp1s0 device with the following settings:

  • A static IPv4 address - 192.0.2.1 with the /24 subnet mask
  • A static IPv6 address - 2001:db8:1::1 with the /64 subnet mask
  • An IPv4 default gateway - 192.0.2.254
  • An IPv6 default gateway - 2001:db8:1::fffe
  • An IPv4 DNS server - 192.0.2.200
  • An IPv6 DNS server - 2001:db8:1::ffbb
  • A DNS search domain - example.com

Apply the settings to the system:

Display the current state in YAML format:

  • nmstatectl(8) man page
  • /usr/share/doc/nmstate/examples/ directory

2.7. Configuring an Ethernet connection with a static IP address by using the network RHEL System Role with an interface name

You can remotely configure an Ethernet connection by using the network RHEL System Role.

Perform this procedure on the Ansible control node.

  • You have prepared the control node and the managed nodes
  • You are logged in to the control node as a user who can run playbooks on the managed nodes.
  • The account you use to connect to the managed nodes has sudo permissions on them.
  • The managed nodes or groups of managed nodes on which you want to run this playbook are listed in the Ansible inventory file.
  • A physical or virtual Ethernet device exists in the server’s configuration.
  • The managed nodes use NetworkManager to configure the network.

Create a playbook file, for example ~/ethernet-static-IP.yml , with the following content:

  • 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

Validate the playbook syntax:

Note that this command only validates the syntax and does not protect against a wrong but valid configuration.

Run the playbook:

  • /usr/share/ansible/roles/rhel-system-roles.network/README.md file

2.8. Configuring an Ethernet connection with a static IP address by using the network RHEL System Role with a device path

You can remotely configure an Ethernet connection using the network RHEL System Role.

You can identify the device path with the following command:

These settings define an Ethernet connection profile with the following settings:

The match parameter in this example defines that Ansible applies the play to devices that match PCI ID 0000:00:0[1-3].0 , but not 0000:00:02.0 . For further details about special modifiers and wild cards you can use, see the match parameter description in the /usr/share/ansible/roles/rhel-system-roles.network/README.md file.

2.9. Configuring an Ethernet connection with a dynamic IP address by using nmstatectl

  • A DHCP server is available in the network.

These settings define an Ethernet connection profile for the enp1s0 device. The connection retrieves IPv4 addresses, IPv6 addresses, default gateway, routes, DNS servers, and search domains from a DHCP server and IPv6 stateless address autoconfiguration (SLAAC).

2.10. Configuring an Ethernet connection with a dynamic IP address by using the network RHEL System Role with an interface name

You can remotely configure an Ethernet connection using the network RHEL System Role. For connections with dynamic IP address settings, NetworkManager requests the IP settings for the connection from a DHCP server.

  • A DHCP server is available in the network

Create a playbook file, for example ~/ethernet-dynamic-IP.yml , with the following content:

2.11. Configuring an Ethernet connection with a dynamic IP address by using the network RHEL System Role with a device path

  • The managed hosts use NetworkManager to configure the network.

These settings define an Ethernet connection profile. The connection retrieves IPv4 addresses, IPv6 addresses, default gateway, routes, DNS servers, and search domains from a DHCP server and IPv6 stateless address autoconfiguration (SLAAC).

2.12. Configuring multiple Ethernet interfaces by using a single connection profile by interface name

In most cases, one connection profile contains the settings of one network device. However, NetworkManager also supports wildcards when you set the interface name in connection profiles. If a host roams between Ethernet networks with dynamic IP address assignment, you can use this feature to create a single connection profile that you can use for multiple Ethernet interfaces.

  • Multiple physical or virtual Ethernet devices exist in the server’s configuration.
  • No connection profile exists on the host.

Add a connection profile that applies to all interface names starting with enp :

Display all settings of the single connection profile:

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 the match.interface-name parameter and, therefore, the connection profiles have the same Universally Unique Identifier (UUID).

Display the status of the connections:

2.13. Configuring a single connection profile for multiple Ethernet interfaces using PCI IDs

The PCI ID is a unique identifier of the devices connected to the system. The connection profile adds multiple devices by matching interfaces based on a list of PCI IDs. You can use this procedure to connect multiple device PCI IDs to the single connection profile.

Identify the device path. For example, to display the device paths of all interfaces starting with enp , enter :

Add a connection profile that applies to all PCI IDs matching the 0000:00:0[7-8].0 expression:

Display the status of the connection:

To display all settings of the connection profile:

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).

Chapter 3. Configuring network bonding

A network bond is a method to combine or aggregate physical and virtual network interfaces to provide a logical interface with higher throughput or redundancy. In a bond, the kernel handles all operations exclusively. You can create bonds on different types of devices, such as Ethernet devices or VLANs.

Red Hat Enterprise Linux provides administrators different options to configure team devices. For example:

  • Use nmcli to configure bond connections using the command line.
  • Use the RHEL web console to configure bond connections using a web browser.
  • Use nmtui to configure bond connections in a text-based user interface.
  • Use the nm-connection-editor application to configure bond connections in a graphical interface.
  • Use nmstatectl to configure bond connections through the Nmstate API.
  • Use RHEL System Roles to automate the bond configuration on one or multiple hosts.

3.1. Understanding the default behavior of controller and port interfaces

Consider the following default behavior when managing or troubleshooting team or bond port interfaces using the NetworkManager service:

  • Starting the controller interface does not automatically start the port interfaces.
  • Starting a port interface always starts the controller interface.
  • Stopping the controller interface also stops the port interface.
  • A controller without ports can start static IP connections.
  • A controller without ports waits for ports when starting DHCP connections.
  • A controller with a DHCP connection waiting for ports completes when you add a port with a carrier.
  • A controller with a DHCP connection waiting for ports continues waiting when you add a port without carrier.

3.2. Upstream switch configuration depending on the bonding modes

Depending on the bonding mode you want to use, you must configure the ports on the switch:

For details how to configure your switch, see the documentation of the switch.

Certain network bonding features, such as the fail-over mechanism, do not support direct cable connections without a network switch. For further details, see the Is bonding supported with direct connection using crossover cables? KCS solution.

3.3. Configuring a network bond by using nmcli

To configure a network bond on the command line, use the nmcli utility.

  • 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:

  • Configuring a network team by using nmcli
  • Configuring a network bridge by using nmcli
  • Configuring VLAN tagging by using nmcli

Create a bond interface:

This command creates a bond named bond0 that uses the active-backup mode.

To additionally set a Media Independent Interface (MII) monitoring interval, add the miimon= interval option to the bond.options property, for example:

Display the network interfaces, and note names of interfaces you plan to add to the bond:

In this example:

  • enp7s0 and enp8s0 are not configured. To use these devices as ports, add connection profiles in the next step.
  • bridge0 and bridge1 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:

These commands create profiles for enp7s0 and enp8s0 , and add them to the bond0 connection.

To assign an existing connection profile to the bond:

Set the master parameter of these connections to bond0 :

These commands assign the existing connection profiles named bridge0 and bridge1 to the bond0 connection.

Reactivate the connections:

To use this bond device as a port of other devices, enter:

  • To use DHCP, no action is required.

To set a static IPv4 address, network mask, default gateway, and DNS server to the bond0 connection, enter:

To set a static IPv6 address, network mask, default gateway, and DNS server to the bond0 connection, enter:

Optional: If you want to set any parameters on the bond ports, use the following command:

Activate the connection:

Verify that the ports are connected, and the CONNECTION column displays the port’s connection name:

When you activate any port of the connection, NetworkManager also activates the bond, but not the other ports of it. You can configure that Red Hat Enterprise Linux enables all ports automatically when the bond is enabled:

Enable the connection.autoconnect-slaves parameter of the bond’s connection:

Reactivate the bridge:

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:

  • Network bonding documentation

3.4. Configuring a network bond by using the RHEL web console

Use the RHEL web console to configure a network bond if you prefer to manage network settings using a web browser-based interface.

  • You are logged in to the RHEL web console.
  • 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:

  • Configuring a network team by using the RHEL web console
  • Configuring a network bridge by using the RHEL web console
  • Configuring VLAN tagging by using the RHEL web console
  • 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 field Primary in which you can select the preferred active device.

  • Set the link monitoring mode. For example, when you use the Adaptive load balancing mode, set it to ARP .

Optional: Adjust the monitoring interval, link up delay, and link down delay settings. Typically, you only change the defaults for troubleshooting purposes.

bond settings

  • 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 to Addresses , and enter the IP address, prefix, and default gateway.
  • In the DNS section, click the + button, and enter the IP address of the DNS server. Repeat this step to set multiple DNS servers.
  • In the DNS search domains section, click the + button, and enter the search domain.

If the interface requires static routes, configure them in the Routes section.

bond team bridge vlan.ipv4

  • Click Apply

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:

bond verify

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.

3.5. Configuring a network bond by using nmtui

The nmtui application provides a text-based user interface for NetworkManager. You can use nmtui to configure a network bond on a host without a graphical interface.

If you do not know the network device names on which you want configure a network bond, display the available devices:

  • Select Bond from the list of network types, and press Enter .

Optional: Enter a name for the NetworkManager profile to be created.

  • Enter the bond device name to be created into the Device field.

Add ports to the bond to be created:

  • Press the Add button next to the Slaves list.
  • Select the type of the interface you want to add as port to the bond, for example, Ethernet .
  • Optional: Enter a name for the NetworkManager profile to be created for this bond port.
  • Enter the port’s device name into the Device field.

Press the OK button to return to the window with the bond settings.

Figure 3.1. Adding an Ethernet device as port to a bond

nmtui bond add port

  • Repeat these steps to add more ports to the bond.
  • Set the bond mode. Depending on the value you set, nmtui displays additional fields for settings that are related to the selected mode.
  • Disabled , if the bond does not require an IP address.
  • Automatic , if a DHCP server or stateless address autoconfiguration (SLAAC) dynamically assigns an IP address to the bond.

Figure 3.2. Example of a bond connection with static IP address settings

nmtui bond static IP

3.6. Configuring a network bond by using nm-connection-editor

If you use Red Hat Enterprise Linux with a graphical interface, you can configure network bonds using the nm-connection-editor application.

Note that nm-connection-editor can add only new ports to a bond. To use an existing connection profile as a port, create the bond by using the nmcli utility as described in Configuring a network bond by using nmcli .

  • To use team, bond, or VLAN devices as ports of the bond, ensure that these devices are not already configured.

Open a terminal, and enter nm-connection-editor :

  • Click the + button to add a new connection.
  • Select the Bond connection type, and click Create .

On 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 the Device field the network interface you want to add as a port to the bond. If you selected a different device type, configure it accordingly. Note that you can only use Ethernet interfaces in a bond that are not configured.

Repeat the previous step for each interface you want to add to the bond:

add nic to bond in nm connection editor

  • Optional: Set other options, such as the Media Independent Interface (MII) monitoring interval.

Configure the IP address settings on both the IPv4 Settings and IPv6 Settings tabs:

  • To use this bridge device as a port of other devices, set the Method field to Disabled .
  • To use DHCP, leave the Method field at its default, Automatic (DHCP) .

To use static IP settings, set the Method field to Manual and fill the fields accordingly:

bond IP settings nm connection editor

  • Configuring a network team by using nm-connection-editor
  • Configuring a network bridge by using nm-connection-editor
  • Configuring VLAN tagging by using nm-connection-editor

3.7. Configuring a network bond by using nmstatectl

Use the nmstatectl utility to configure a network bond through the Nmstate API. The Nmstate API ensures that, after setting the configuration, the result matches the configuration file. If anything fails, nmstatectl automatically rolls back the changes to avoid leaving the system in an incorrect state.

Depending on your environment, adjust the YAML file accordingly. For example, to use different devices than Ethernet adapters in the bond, adapt the base-iface attribute and type attributes of the ports you use in the bond.

  • 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.

Create a YAML file, for example ~/create-bond.yml , with the following content:

These settings define a network bond with the following settings:

  • Network interfaces in the bond: enp1s0 and enp7s0
  • 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

Display the status of the devices and connections:

Display all settings of the connection profile:

Display the connection settings in YAML format:

3.8. Configuring a network bond by using the network RHEL System Role

You can remotely configure a network bond by using the network RHEL System Role.

Create a playbook file, for example ~/bond-ethernet.yml , with the following content:

  • Ports of the bond - enp7s0 and enp8s0

Bond mode - active-backup

Set the IP configuration on the bond and not on the ports of the Linux bond.

3.9. Creating a network bond to enable switching between an Ethernet and wireless connection without interrupting the VPN

RHEL users who connect their workstation to their company’s network typically use a VPN to access remote resources. However, if the workstation switches between an Ethernet and Wi-Fi connection, for example, if you release a laptop from a docking station with an Ethernet connection, the VPN connection is interrupted. To avoid this problem, you can create a network bond that uses the Ethernet and Wi-Fi connection in active-backup mode.

  • 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 the enp11s0u1 Ethernet device
  • Wi-Fi associated with the wlp1s0 Wi-Fi device

Create a bond interface in active-backup mode:

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:

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:

Display the connection profiles:

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:

Assign the connection profile of the Wi-Fi connection to the bond:

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:

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:

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:

Activate the bond0 connection:

Display the currently active device, the status of the bond and its ports:

  • Configuring an Ethernet connection
  • Managing Wi-Fi connections
  • Configuring network bonding

3.10. The different network bonding modes

The Linux bonding driver provides link aggregation. Bonding is the process of aggregating multiple network interfaces in parallel to provide a single logical bonded interface. The actions of a bonded interface depend on the bonding policy that is also known as mode. The different modes provide either load-balancing or hot standby services.

The following modes exist:

Balance-rr uses the round-robin algorithm that sequentially transmits packets from the first available port to the last one. This mode provides load balancing and fault tolerance.

This mode requires switch configuration of a port aggregation group, also called EtherChannel or similar port grouping. An EtherChannel is a port link aggregation technology to group multiple physical Ethernet links to one logical Ethernet link.

The drawback of this mode is that it is not suitable for heavy workloads and if TCP throughput or ordered packet delivery is essential.

Active-backup uses the policy that determines that only one port is active in the bond. This mode provides fault tolerance and does not require any switch configuration.

If the active port fails, an alternate port becomes active. The bond sends a gratuitous address resolution protocol (ARP) response to the network. The gratuitous ARP forces the receiver of the ARP frame to update their forwarding table. The Active-backup mode transmits a gratuitous ARP to announce the new path to maintain connectivity for the host.

The primary option defines the preferred port of the bonding interface.

Balance-xor uses the selected transmit hash policy to send the packets. This mode provides load balancing, fault tolerance, and requires switch configuration to set up an Etherchannel or similar port grouping.

To alter packet transmission and balance transmit, this mode uses the xmit_hash_policy option. Depending on the source or destination of traffic on the interface, the interface requires an additional load-balancing configuration. See description xmit_hash_policy bonding parameter .

Broadcast uses a policy that transmits every packet on all interfaces. This mode provides fault tolerance and requires a switch configuration to set up an EtherChannel or similar port grouping.

802.3ad uses the same-named IEEE standard dynamic link aggregation policy. This mode provides fault tolerance. This mode requires switch configuration to set up a Link Aggregation Control Protocol (LACP) port grouping.

This mode creates aggregation groups that share the same speed and duplex settings and utilizes all ports in the active aggregator. Depending on the source or destination of traffic on the interface, this mode requires an additional load-balancing configuration.

By default, the port selection for outgoing traffic depends on the transmit hash policy. Use the xmit_hash_policy option of the transmit hash policy to change the port selection and balance transmit.

The difference between the 802.3ad and the Balance-xor is compliance. The 802.3ad policy negotiates LACP between the port aggregation groups. See description xmit_hash_policy bonding parameter

Balance-tlb uses the transmit load balancing policy. This mode provides fault tolerance, load balancing, and establishes channel bonding that does not require any switch support.

The active port receives the incoming traffic. In case of failure of the active port, another one takes over the MAC address of the failed port. To decide which interface processes the outgoing traffic, use one of the following modes:

  • Value 0 : Uses the hash distribution policy to distribute traffic without load balancing

Value 1 : Distributes traffic to each port by using load balancing

With the bonding option tlb_dynamic_lb=0 , this bonding mode uses the xmit_hash_policy bonding option to balance transmit. The primary option defines the preferred port of the bonding interface.

See description xmit_hash_policy bonding parameter .

Balance-alb uses an adaptive load balancing policy. This mode provides fault tolerance, load balancing, and does not require any special switch support.

This mode Includes balance-transmit load balancing ( balance-tlb ) and receive-load balancing for IPv4 and IPv6 traffic. The bonding intercepts ARP replies sent by the local system and overwrites the source hardware address of one of the ports in the bond. ARP negotiation manages the receive-load balancing. Therefore, different ports use different hardware addresses for the server.

The primary option defines the preferred port of the bonding interface. With the bonding option tlb_dynamic_lb=0 , this bonding mode uses the xmit_hash_policy bonding option to balance transmit. See description xmit_hash_policy bonding parameter .

  • /usr/share/doc/kernel-doc-< version >/Documentation/networking/bonding.rst provided by the kernel-doc package
  • /usr/share/doc/kernel-doc-< version >/Documentation/networking/bonding.txt provided by the kernel-doc package
  • Which bonding modes work when used with a bridge that virtual machine guests or containers connect to?
  • How are the values for different policies in "xmit_hash_policy" bonding parameter calculated?

3.11. The xmit_hash_policy bonding parameter

The xmit_hash_policy load balancing parameter selects the transmit hash policy for a node selection in the balance-xor , 802.3ad , balance-alb , and balance-tlb modes. It is only applicable to mode 5 and 6 if the tlb_dynamic_lb parameter is 0 . The possible values of this parameter are layer2 , layer2+3 , layer3+4 , encap2+3 , encap3+4 , and vlan+srcmac .

Refer the table for details:

Chapter 4. Configuring network teaming

A network team is a method to combine or aggregate physical and virtual network interfaces to provide a logical interface with higher throughput or redundancy. Network teaming uses a small kernel module to implement fast handling of packet flows and a user-space service for other tasks. This way, network teaming is an easily extensible and scalable solution for load-balancing and redundancy requirements.

  • Use nmcli to configure teams connections using the command line.
  • Use the RHEL web console to configure team connections using a web browser.
  • Use the nm-connection-editor application to configure team connections in a graphical interface.

Network teaming is deprecated in Red Hat Enterprise Linux 9. If you plan to upgrade your server to a future version of RHEL, consider using the kernel bonding driver as an alternative. For details, see Configuring network bonding .

4.1. Understanding the default behavior of controller and port interfaces

4.2. understanding the teamd service, runners, and link-watchers.

The team service, teamd , controls one instance of the team driver. This instance of the driver adds instances of a hardware device driver to form a team of network interfaces. The team driver presents a network interface, for example team0 , to the kernel.

The teamd service implements the common logic to all methods of teaming. Those functions are unique to the different load sharing and backup methods, such as round-robin, and implemented by separate units of code referred to as runners . Administrators specify runners in JavaScript Object Notation (JSON) format, and the JSON code is compiled into an instance of teamd when the instance is created. Alternatively, when using NetworkManager , you can set the runner in the team.runner parameter, and NetworkManager auto-creates the corresponding JSON code.

The following runners are available:

  • broadcast : Transmits data over all ports.
  • roundrobin : Transmits data over all ports in turn.
  • activebackup : Transmits data over one port while the others are kept as a backup.
  • loadbalance : Transmits data over all ports with active Tx load balancing and Berkeley Packet Filter (BPF)-based Tx port selectors.
  • random : Transmits data on a randomly selected port.
  • lacp : Implements the 802.3ad Link Aggregation Control Protocol (LACP).

The teamd services uses a link watcher to monitor the state of subordinate devices. The following link-watchers are available:

  • ethtool : The libteam library uses the ethtool utility to watch for link state changes. This is the default link-watcher.
  • arp_ping : The libteam library uses the arp_ping utility to monitor the presence of a far-end hardware address using Address Resolution Protocol (ARP).
  • nsna_ping : On IPv6 connections, the libteam library uses the Neighbor Advertisement and Neighbor Solicitation features from the IPv6 Neighbor Discovery protocol to monitor the presence of a neighbor’s interface.

Each runner can use any link watcher, with the exception of lacp . This runner can only use the ethtool link watcher.

4.3. Configuring a network team by using nmcli

To configure a network team on the command line, use the nmcli utility.

  • The teamd and NetworkManager-team packages are installed.
  • 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:

  • Configuring a network bond by using nmcli

Create a team interface:

This command creates a network team named team0 that uses the activebackup runner.

Optionally, set a link watcher. For example, to set the ethtool link watcher in the team0 connection profile:

Link watchers support different parameters. To set parameters for a link watcher, specify them space-separated in the name property. Note that the name property must be surrounded by quotation marks. For example, to use the ethtool link watcher and set its delay-up parameter to 2500 milliseconds (2.5 seconds):

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 the delay-up parameter and the arp_ping link watcher with the source-host and target-host parameter:

Display the network interfaces, and note the names of the interfaces you want to add to the team:

  • enp7s0 and enp8s0 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 and bond1 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:

These commands create profiles for enp7s0 and enp8s0 , and add them to the team0 connection.

To assign an existing connection profile to the team:

Set the master parameter of these connections to team0 :

These commands assign the existing connection profiles named bond0 and bond1 to the team0 connection.

To use this team device as a port of other devices, enter:

To set a static IPv4 address, network mask, default gateway, and DNS server to the team0 connection, enter:

To set a static IPv6 address, network mask, default gateway, and DNS server to the team0 connection, enter:

Display the status of the team:

In this example, both ports are up.

  • Understanding the teamd service, runners, and link-watchers
  • teamd.conf(5) man page

4.4. Configuring a network team by using the RHEL web console

Use the RHEL web console to configure a network team if you prefer to manage network settings using a web browser-based interface.

To use bond, bridge, or VLAN devices as ports of the team, create them in advance as described in:

  • Configuring a network bond by using the RHEL web console
  • 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 or 802.3ad LACP , the web console shows the additional field Balancer .

Set the link watcher:

  • If you select Ethtool , additionally, set a link up and link down delay.
  • If you set ARP ping or NSNA ping , additionally, set a ping interval and ping target.

team settings

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.

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.

team verify

  • Network team runners

4.5. Configuring a network team by using nm-connection-editor

If you use Red Hat Enterprise Linux with a graphical interface, you can configure network teams using the nm-connection-editor application.

Note that nm-connection-editor can add only new ports to a team. To use an existing connection profile as a port, create the team using the nmcli utility as described in Configuring a network team by using nmcli .

  • 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.
  • Select the Team connection type, and click Create .

On 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.

  • If you create a connection profile for an Ethernet device, open the Ethernet tab, and select in the Device field the network interface you want to add as a port to the team. If you selected a different device type, configure it accordingly. Note that you can only use Ethernet interfaces in a team that are not assigned to any connection.

Repeat the previous step for each interface you want to add to the team.

add nic to team in nm connection editor

Click the Advanced button to set advanced options to the team connection.

  • On the Runner tab, select the runner.
  • On the Link Watcher tab, set the link watcher and its optional settings.

team IP settings nm connection editor

  • Configuring a network bond by using nm-connection-editor
  • NetworkManager duplicates a connection after restart of NetworkManager service

Chapter 5. Configuring VLAN tagging

A Virtual Local Area Network (VLAN) is a logical network within a physical network. The VLAN interface tags packets with the VLAN ID as they pass through the interface, and removes tags of returning packets. You create VLAN interfaces on top of another interface, such as Ethernet, bond, team, or bridge devices. These interfaces are called the parent interface .

Red Hat Enterprise Linux provides administrators different options to configure VLAN devices. For example:

  • Use nmcli to configure VLAN tagging using the command line.
  • Use the RHEL web console to configure VLAN tagging using a web browser.
  • Use nmtui to configure VLAN tagging in a text-based user interface.
  • Use the nm-connection-editor application to configure connections in a graphical interface.
  • Use RHEL System Roles to automate the VLAN configuration on one or multiple hosts.

5.1. Configuring VLAN tagging by using nmcli

You can configure Virtual Local Area Network (VLAN) tagging on the command line using the nmcli utility.

  • 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 and ipv6.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.

Display the network interfaces:

Create the VLAN interface. For example, to create a VLAN interface named vlan10 that uses enp1s0 as its parent interface and that tags packets with VLAN ID 10 , enter:

Note that the VLAN must be within the range from 0 to 4094 .

By default, the VLAN connection inherits the maximum transmission unit (MTU) from the parent interface. Optionally, set a different MTU value:

To use this VLAN device as a port of other devices, enter:

To set a static IPv4 address, network mask, default gateway, and DNS server to the vlan10 connection, enter:

To set a static IPv6 address, network mask, default gateway, and DNS server to the vlan10 connection, enter:

Verify the settings:

5.2. Configuring VLAN tagging by using the RHEL web console

Use the RHEL web console to configure VLAN tagging if you prefer to manage network settings using a web browser-based interface.

  • 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.
  • 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.

vlan settings

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.

vlan verify

5.3. Configuring VLAN tagging by using nmtui

The nmtui application provides a text-based user interface for NetworkManager. You can use nmtui to configure VLAN tagging on a host without a graphical interface.

  • The bond is not configured with the fail_over_mac=follow option. A VLAN virtual device cannot change its MAC address to match the parent’s new MAC address. In such a case, the traffic would still be sent with the then incorrect source MAC address.
  • The switch the host is connected to is configured to support VLAN tags. For details, see the documentation of your switch.

If you do not know the network device name on which you want configure VLAN tagging, display the available devices:

  • Select VLAN from the list of network types, and press Enter .
  • Enter the VLAN device name to be created into the Device field.
  • Enter the name of the device on which you want to configure VLAN tagging into the Parent field.
  • Enter the VLAN ID. The ID must be within the range from 0 to 4094 .
  • Disabled , if this VLAN device does not require an IP address or you want to use it as a port of other devices.
  • Automatic , if a DHCP server or stateless address autoconfiguration (SLAAC) dynamically assigns an IP address to the VLAN device.

Figure 5.1. Example of a VLAN connection with static IP address settings

nmtui vlan static IP

5.4. Configuring VLAN tagging by using nm-connection-editor

You can configure Virtual Local Area Network (VLAN) tagging in a graphical interface using the nm-connection-editor application.

  • The switch, the host is connected, to is configured to support VLAN tags. For details, see the documentation of your switch.
  • 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 to 4094 .
  • 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.

vlan settings nm connection editor

5.5. Configuring VLAN tagging by using nmstatectl

Use the nmstatectl utility to configure Virtual Local Area Network VLAN through the Nmstate API. The Nmstate API ensures that, after setting the configuration, the result matches the configuration file. If anything fails, nmstatectl automatically rolls back the changes to avoid leaving the system in an incorrect state.

Depending on your environment, adjust the YAML file accordingly. For example, to use different devices than Ethernet adapters in the VLAN, adapt the base-iface attribute and type attributes of the ports you use in the VLAN.

  • To use Ethernet devices as ports in the VLAN, the physical or virtual Ethernet devices must be installed on the server.

Create a YAML file, for example ~/create-vlan.yml , with the following content:

These settings define a VLAN with ID 10 that uses the enp1s0 device. As the child device, the VLAN connection has the following settings:

5.6. Configuring VLAN tagging by using the network RHEL System Role

You can use the network RHEL System Role to configure VLAN tagging. This example adds 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 and type attributes of the ports you use in the VLAN.

Create a playbook file, for example ~/vlan-ethernet.yml , with the following content:

These settings define a VLAN to operate on top of the enp1s0 device. The VLAN interface has the following settings:

  • VLAN ID - 10

The parent attribute in the VLAN profile configures the VLAN to operate on top of the enp1s0 device. As the child device, the VLAN connection contains the IP, default gateway, and DNS configurations.

5.7. Additional resources

  • VLANs for sysadmins: The basics

Chapter 6. Configuring a network bridge

A network bridge is a link-layer device which forwards traffic between networks based on a table of MAC addresses. The bridge builds the MAC addresses table by listening to network traffic and thereby learning what hosts are connected to each network. For example, you can use a software bridge on a Red Hat Enterprise Linux host to emulate a hardware bridge or in virtualization environments, to integrate virtual machines (VM) to the same network as the host.

A bridge requires a network device in each network the bridge should connect. When you configure a bridge, the bridge is called controller and the devices it uses ports .

You can create bridges on different types of devices, such as:

  • Physical and virtual Ethernet devices
  • Network bonds
  • Network teams
  • VLAN devices

Due to the IEEE 802.11 standard which specifies the use of 3-address frames in Wi-Fi for the efficient use of airtime, you cannot configure a bridge over Wi-Fi networks operating in Ad-Hoc or Infrastructure modes.

6.1. Configuring a network bridge by using nmcli

To configure a network bridge on the command line, use the nmcli utility.

  • 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:

Create a bridge interface:

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:

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:

These commands create profiles for enp7s0 and enp8s0 , and add them to the bridge0 connection.

If you want to assign an existing connection profile to the bridge:

Set the master parameter of these connections to bridge0 :

These commands assign the existing connection profiles named bond0 and bond1 to the bridge0 connection.

To use this bridge device as a port of other devices, enter:

To set a static IPv4 address, network mask, default gateway, and DNS server to the bridge0 connection, enter:

To set a static IPv6 address, network mask, default gateway, and DNS server to the bridge0 connection, enter:

Optional: Configure further properties of the bridge. For example, to set the Spanning Tree Protocol (STP) priority of bridge0 to 16384 , enter:

By default, STP is enabled.

When you activate any port of the connection, NetworkManager also activates the bridge, but not the other ports of it. You can configure that Red Hat Enterprise Linux enables all ports automatically when the bridge is enabled:

Enable the connection.autoconnect-slaves parameter of the bridge connection:

Use the ip utility to display the link status of Ethernet devices that are ports of a specific bridge:

Use the bridge utility to display the status of Ethernet devices that are ports of any bridge device:

To display the status for a specific Ethernet device, use the bridge link show dev ethernet_device_name command.

  • bridge(8) man page
  • How to configure a bridge with VLAN information?

6.2. Configuring a network bridge by using the RHEL web console

Use the RHEL web console to configure a network bridge if you prefer to manage network settings using a web browser-based interface.

  • Configuring a network team using the RHEL web console
  • 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.

bridge settings

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.

bridge verify

6.3. Configuring a network bridge by using nmtui

The nmtui application provides a text-based user interface for NetworkManager. You can use nmtui to configure a network bridge on a host without a graphical interface.

If you do not know the network device names on which you want configure a network bridge, display the available devices:

  • Select Bridge from the list of network types, and press Enter .
  • Enter the bridge device name to be created into the Device field.

Add ports to the bridge to be created:

  • Select the type of the interface you want to add as port to the bridge, for example, Ethernet .
  • Optional: Enter a name for the NetworkManager profile to be created for this bridge port.

Press the OK button to return to the window with the bridge settings.

Figure 6.1. Adding an Ethernet device as port to a bridge

nmtui bridge add port

  • Repeat these steps to add more ports to the bridge.
  • Disabled , if the bridge does not require an IP address.
  • Automatic , if a DHCP server or stateless address autoconfiguration (SLAAC) dynamically assigns an IP address to the bridge.

Figure 6.2. Example of a bridge connection without IP address settings

nmtui bridge no IP

6.4. Configuring a network bridge by using nm-connection-editor

If you use Red Hat Enterprise Linux with a graphical interface, you can configure network bridges using the nm-connection-editor application.

Note that nm-connection-editor can add only new ports to a bridge. To use an existing connection profile as a port, create the bridge using the nmcli utility as described in Configuring a network bridge by using nmcli .

  • To use team, bond, or VLAN devices as ports of the bridge, ensure that these devices are not already configured.
  • Select the Bridge connection type, and click Create .

On 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.

  • 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 the Device field the network interface you want to add as a port to the bridge. If you selected a different device type, configure it accordingly.

Repeat the previous step for each interface you want to add to the bridge.

add nic to bridge in nm connection editor

  • Optional: Configure further bridge settings, such as Spanning Tree Protocol (STP) options.

bridge IP settings nm connection editor

Use the ip utility to display the link status of Ethernet devices that are ports of a specific bridge.

Use the bridge utility to display the status of Ethernet devices that are ports in any bridge device:

6.5. Configuring a network bridge by using nmstatectl

Use the nmstatectl utility to configure a network bridge through the Nmstate API. The Nmstate API ensures that, after setting the configuration, the result matches the configuration file. If anything fails, nmstatectl automatically rolls back the changes to avoid leaving the system in an incorrect state.

Depending on your environment, adjust the YAML file accordingly. For example, to use different devices than Ethernet adapters in the bridge, adapt the base-iface attribute and type attributes of the ports you use in the bridge.

  • 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.

Create a YAML file, for example ~/create-bridge.yml , with the following content:

These settings define a network bridge with the following settings:

  • Network interfaces in the bridge: enp1s0 and enp7s0
  • 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

6.6. Configuring a network bridge by using the network RHEL System Role

You can remotely configure a network bridge by using the network RHEL System Role.

Create a playbook file, for example ~/bridge-ethernet.yml , with the following content:

Ports of the bridge - enp7s0 and enp8s0

Set the IP configuration on the bridge and not on the ports of the Linux bridge.

Chapter 7. Configuring a VPN connection

A virtual private network (VPN) is a way of connecting to a local network over the internet. IPsec provided by Libreswan is the preferred method for creating a VPN. Libreswan is a user-space IPsec implementation for VPN. A VPN enables the communication between your LAN, and another, remote LAN by setting up a tunnel across an intermediate network such as the internet. For security reasons, a VPN tunnel always uses authentication and encryption. For cryptographic operations, Libreswan uses the NSS library.

7.1. Configuring a VPN connection with control-center

If you use Red Hat Enterprise Linux with a graphical interface, you can configure a VPN connection in the GNOME control-center .

  • The NetworkManager-libreswan-gnome package is installed.
  • Press the Super key, type Settings , and press Enter to open the control-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:

Gateway — The name or IP address of the remote VPN gateway.

Authentication

  • IKEv2 (Certificate) - client is authenticated by certificate. It is more secure (default).

IKEv1 (XAUTH) - client is authenticated by user name and password, or a pre-shared key (PSK).

The following configuration settings are available under the Advanced section:

Figure 7.1. Advanced options of a VPN connection

networking vpn advanced options

When configuring an IPsec-based VPN connection using the gnome-control-center application, the Advanced dialog displays the configuration, but it does not allow any changes. As a consequence, users cannot change any advanced IPsec options. Use the nm-connection-editor or nmcli tools instead to perform configuration of the advanced properties.

Identification

Domain — If required, enter the Domain Name.

  • Phase1 Algorithms — corresponds to the ike Libreswan parameter — enter the algorithms to be used to authenticate and set up an encrypted channel.

Phase2 Algorithms — corresponds to the esp Libreswan parameter — enter the algorithms to be used for the IPsec 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 the ikelifetime Libreswan parameter — how long the key used to encrypt the traffic will be valid.

Phase2 Lifetime — corresponds to the salifetime 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 the rightsubnet 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 the fragmentation Libreswan parameter — whether or not to allow IKE fragmentation. Valid values are yes (default) or no .
  • Enable Mobike — corresponds to the mobike 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 are no (default) or yes .

Select the IPv4 menu entry:

IPv4 Method

  • Automatic (DHCP) — Choose this option if the network you are connecting to uses a DHCP server to assign dynamic IP addresses.
  • Link-Local Only — Choose this option if the network you are connecting to does not have a DHCP server and you do not want to assign IP addresses manually. Random addresses will be assigned as per RFC 3927 with prefix 169.254/16 .
  • Manual — Choose this option if you want to assign IP addresses manually.

Disable — IPv4 is disabled for this connection.

In the DNS section, when Automatic is ON , switch it to OFF to enter the IP address of a DNS server you want to use separating the IPs by comma.

Note that in the Routes section, when Automatic is ON , routes from DHCP are used, but you can also add additional static routes. When OFF , only static routes are used.

  • Address — Enter the IP address of a remote network 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 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 a VPN connection, select the IPv6 menu entry:

IPv6 Method

  • Automatic — Choose this option to use IPv6 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 from DHCPv6 directly to create a stateful configuration.
  • Link-Local Only — Choose this option if the network you are connecting to does not have a DHCP server and you do not want to assign IP addresses manually. Random addresses will be assigned as per RFC 4862 with prefix FE80::0 .

Disable — IPv6 is disabled for this connection.

Note that DNS , Routes , Use this connection only for resources on its network are common to IPv4 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 the VPN connection.
  • nm-settings-libreswan(5)

7.2. Configuring a VPN connection using nm-connection-editor

If you use Red Hat Enterprise Linux with a graphical interface, you can configure a VPN connection in the nm-connection-editor application.

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.
  • 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:

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’s leftid parameter.

nm connection editor vpn tab

Optionally, configure additional settings by clicking the Advanced button. You can configure the following settings:

  • Domain — If required, enter the domain name.
  • Phase1 Algorithms corresponds to the ike Libreswan parameter. Enter the algorithms to be used to authenticate and set up an encrypted channel.

Phase2 Algorithms corresponds to the esp Libreswan parameter. Enter the algorithms to be used for the IPsec negotiations.

  • Phase1 Lifetime corresponds to the ikelifetime Libreswan parameter. This parameter defines how long the key used to encrypt the traffic is valid.
  • Phase2 Lifetime corresponds to the salifetime Libreswan parameter. This parameter defines how long a security association is valid.

Connectivity

Remote network corresponds to the rightsubnet 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 the fragmentation Libreswan parameter and defines whether or not to allow IKE fragmentation. Valid values are yes (default) or no .
  • Enable Mobike corresponds to the mobike 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 are no (default) or yes .

On the IPv4 Settings tab, select the IP assignment method and, optionally, set additional static addresses, DNS servers, search domains, and routes.

IPsec IPv4 tab

  • Save the connection.

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.

  • nm-settings-libreswan(5) man page

7.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. In case that the feature was disabled or explicitly enabled, you can switch back to automatic detection.

  • The network card supports ESP hardware offload.
  • The network driver supports ESP hardware offload.
  • The IPsec connection is configured and works.
  • 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 the ipsec service:

If the network card supports ESP hardware offload support, following these steps to verify the result:

Display the tx_ipsec and rx_ipsec counters of the Ethernet device the IPsec connection uses:

Send traffic through the IPsec tunnel. For example, ping a remote IP address:

Display the tx_ipsec and rx_ipsec counters of the Ethernet device again:

If the counter values have increased, ESP hardware offload works.

  • Configuring a VPN with IPsec

7.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.

  • 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.

Enable ESP hardware offload support on the network bond:

This command enables ESP hardware offload support on the bond0 connection.

Reactivate the bond0 connection:

Edit the Libreswan configuration file in the /etc/ipsec.d/ directory of the connection that should use ESP hardware offload, and append the nic-offload=yes statement to the connection entry:

Restart the ipsec service:

Display the active port of the bond:

Display the tx_ipsec and rx_ipsec counters of the active port:

Display the tx_ipsec and rx_ipsec counters of the active port again:

  • Configuring a VPN with IPsec section in the Securing networks document

Chapter 8. Configuring IP tunnels

Similar to a VPN, an IP tunnel directly connects two networks over a third network, such as the internet. However, not all tunnel protocols support encryption.

The routers in both networks that establish the tunnel requires at least two interfaces:

  • One interface that is connected to the local network
  • One interface that is connected to the network through which the tunnel is established.

To establish the tunnel, you create a virtual interface on both routers with an IP address from the remote subnet.

NetworkManager supports the following IP tunnels:

  • Generic Routing Encapsulation (GRE)
  • Generic Routing Encapsulation over IPv6 (IP6GRE)
  • Generic Routing Encapsulation Terminal Access Point (GRETAP)
  • Generic Routing Encapsulation Terminal Access Point over IPv6 (IP6GRETAP)
  • IPv4 over IPv4 (IPIP)
  • IPv4 over IPv6 (IPIP6)
  • IPv6 over IPv6 (IP6IP6)
  • Simple Internet Transition (SIT)

Depending on the type, these tunnels act either on layer 2 or 3 of the Open Systems Interconnection (OSI) model.

8.1. Configuring an IPIP tunnel 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 .

For example, you can create an IPIP tunnel between two RHEL routers to connect two internal subnets over the internet as shown in the following diagram:

IPIP tunnel

  • 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.

On the RHEL router in network A:

Create an IPIP tunnel interface named tun0 :

The remote and local parameters set the public IP addresses of the remote and the local routers.

Set the IPv4 address to the tun0 device:

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:

Add a static route that routes traffic to the 172.16.0.0/24 network to the tunnel IP on router B:

Enable the tun0 connection.

Enable packet forwarding:

On the RHEL router in network B:

The remote and local parameters set the public IP addresses of the remote and local routers.

Add a static route that routes traffic to the 192.0.2.0/24 network to the tunnel IP on router A:

From each RHEL router, ping the IP address of the internal interface of the other router:

On Router A, ping 172.16.0.1 :

On Router B, ping 192.0.2.1 :

8.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.

For example, you can create a GRE tunnel between two RHEL routers to connect two internal subnets over the internet as shown in the following diagram:

GRE tunnel

The gre0 device name is reserved. Use gre1 or a different name for the device.

Create a GRE tunnel interface named gre1 :

Set the IPv4 address to the gre1 device:

Configure the gre1 connection to use a manual IPv4 configuration:

Enable the gre1 connection.

8.3. Configuring a GRETAP tunnel to transfer Ethernet frames over IPv4

A Generic Routing Encapsulation Terminal Access Point (GRETAP) tunnel operates on OSI level 2 and encapsulates Ethernet traffic in IPv4 packets as described in RFC 2784 .

Data sent through a GRETAP tunnel is not encrypted. For security reasons, establish the tunnel over a VPN or a different encrypted connection.

For example, you can create a GRETAP tunnel between two RHEL routers to connect two networks using a bridge as shown in the following diagram:

GRETAP tunnel

The gretap0 device name is reserved. Use gretap1 or a different name for the device.

  • Each RHEL router has a network interface that is connected to its local network, and the interface has no IP configuration assigned.

Create a bridge interface named bridge0 :

Configure the IP settings of the bridge:

Add a new connection profile for the interface that is connected to local network to the bridge:

Add a new connection profile for the GRETAP tunnel interface to the bridge:

Optional: Disable the Spanning Tree Protocol (STP) if you do not need it:

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:

Active the bridge0 connection:

On both routers, verify that the enp1s0 and gretap1 connections are connected and that the CONNECTION column displays the connection name of the port:

On Router A, ping 192.0.2.2 :

8.4. Additional resources

  • ip-link(8) 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:

vxlan tunnel

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.
  • /usr/share/doc/kernel-doc- <kernel_version> /Documentation/networking/vxlan.rst provided by the kernel-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.

  • The host is connected to the Ethernet.

Add a new Ethernet connection profile to NetworkManager:

Skip this step if the network uses DHCP.

Activate the Example connection:

Ping a host in a remote network to verify the IP settings:

Note that you cannot ping the other VM host before you have configured the network on that host as well.

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.

Create the bridge br0 :

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 :

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 the br0 connection.
  • ipv4.method disabled and ipv6.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 the destination-port <port_number> option to the command.

Activate the br0 connection profile:

Open port 8472 for incoming UDP connections in the local firewall:

Display the forwarding table:

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.

  • You installed the libvirt package.
  • You started and enabled the libvirtd service.
  • You configured the br0 device with the VXLAN on RHEL.

Create the ~/vxlan10-bridge.xml file with the following content:

Use the ~/vxlan10-bridge.xml file to create a new virtual network in libvirt :

Remove the ~/vxlan10-bridge.xml file:

Start the vxlan10-bridge virtual network:

Configure the vxlan10-bridge virtual network to start automatically when the libvirtd service starts:

Display the list of virtual networks:

  • 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.

  • You configured the vxlan10-bridge virtual network in libvirtd .

To create a new VM and configure it to use the vxlan10-bridge network, pass the --network network: vxlan10-bridge option to the virt-install command when you create the VM:

To change the network settings of an existing VM:

Connect the VM’s network interface to the vxlan10-bridge virtual network:

Shut down the VM, and start it again:

Display the virtual network interfaces of the VM on the host:

Display the interfaces attached to the vxlan10-bridge bridge:

Note that the libvirtd service dynamically updates the bridge’s configuration. When you start a VM which uses the vxlan10-bridge network, the corresponding vnet* 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:

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 the arping utility.

  • virt-install(1) man page
  • virt-xml(1) man page
  • arping(8) man page

Chapter 10. Managing wifi connections

RHEL provides multiple utilities and applications to configure and connect to wifi networks, for example:

  • Use the nmcli utility to configure connections by using the command line.
  • Use the nmtui application to configure connections in a text-based user interface.
  • Use the GNOME system menu to quickly connect to wifi networks that do not require any configuration.
  • Use the GNOME Settings application to configure connections by using the GNOME application.
  • Use the nm-connection-editor application to configure connections in a graphical user interface.
  • Use the network RHEL System Role to automate the configuration of connections on one or multiple hosts.

10.1. Supported wifi security types

Depending on the security type a wifi network supports, you can transmitted data more or less securely.

Do not connect to wifi networks that do not use encryption or which support only the insecure WEP or WPA standards.

RHEL 8 supports the following wifi security types:

  • None : Encryption is disabled, and data is transferred in plain text over the network.
  • Enhanced Open : With opportunistic wireless encryption (OWE), devices negotiate unique pairwise master keys (PMK) to encrypt connections in wireless networks without authentication.
  • WEP 40/128-bit Key (Hex or ASCII) : The Wired Equivalent Privacy (WEP) protocol in this mode uses pre-shared keys only in hex or ASCII format. WEP is deprecated and will be removed in RHEL 9.1.
  • WEP 128-bit Passphrase . The WEP protocol in this mode uses an MD5 hash of the passphrase to derive a WEP key. WEP is deprecated and will be removed in RHEL 9.1.
  • Dynamic WEP (802.1x) : A combination of 802.1X and EAP that uses the WEP protocol with dynamic keys. WEP is deprecated and will be removed in RHEL 9.1.
  • LEAP : The Lightweight Extensible Authentication Protocol, which was developed by Cisco, is a proprietary version of the extensible authentication protocol (EAP).
  • WPA & WPA2 Personal : In personal mode, the Wi-Fi Protected Access (WPA) and Wi-Fi Protected Access 2 (WPA2) authentication methods use a pre-shared key.
  • WPA & WPA2 Enterprise : In enterprise mode, WPA and WPA2 use the EAP framework and authenticate users to a remote authentication dial-in user service (RADIUS) server.
  • WPA3 Personal : Wi-Fi Protected Access 3 (WPA3) Personal uses simultaneous authentication of equals (SAE) instead of pre-shared keys (PSK) to prevent dictionary attacks. WPA3 uses perfect forward secrecy (PFS).

10.2. Connecting to a wifi network by using nmcli

You can use the nmcli utility to connect to a wifi network. When you attempt to connect to a network for the first time, the utility automatically creates a NetworkManager connection profile for it. If the network requires additional settings, such as static IP addresses, you can then modify the profile after it has been automatically created.

  • A wifi device is installed on the host.
  • The wifi device is enabled, if it has a hardware switch.

If the wifi radio has been disabled in NetworkManager, enable this feature:

Optional: Display the available wifi networks:

The service set identifier ( SSID ) column contains the names of the networks. If the column shows -- , the access point of this network does not broadcast an SSID.

Connect to the wifi network:

If you prefer to set the password in the command instead of entering it interactively, use the password wifi-password option in the command instead of --ask :

Note that, if the network requires static IP addresses, NetworkManager fails to activate the connection at this point. You can configure the IP addresses in later steps.

If the network requires static IP addresses:

Configure the IPv4 address settings, for example:

Configure the IPv6 address settings, for example:

Re-activate the connection:

Display the active connections:

If the output lists the wifi connection you have created, the connection is active.

Ping a hostname or IP address:

  • nm-settings-nmcli(5) man page

10.3. Connecting to a wifi network by using the GNOME system menu

You can use the GNOME system menu to connect to a wifi network. When you connect to a network for the first time, GNOME creates a NetworkManager connection profile for it. If you configure the connection profile to not automatically connect, you can also use the GNOME system menu to manually connect to a wifi network with an existing NetworkManager connection profile.

Using the GNOME system menu to establish a connection to a wifi network for the first time has certain limitations. For example, you can not configure IP address settings. In this case first configure the connections:

  • In the GNOME settings application
  • In the nm-connection-editor application
  • Using nmcli commands
  • Open the system menu on the right side of the top bar.
  • Expand the Wi-Fi Not Connected entry.

Click Select Network :

gnome select wifi

  • Select the wifi network you want to connect to.
  • Click Connect .
  • If this is the first time you connect to this network, enter the password for the network, and click Connect .

Open the system menu on the right side of the top bar, and verify that the wifi network is connected:

gnome wifi connected

If the network appears in the list, it is connected.

10.4. Connecting to a wifi network by using the GNOME settings application

You can use the GNOME settings application, also named gnome-control-center , to connect to a wifi network and configure the connection. When you connect to the network for the first time, GNOME creates a NetworkManager connection profile for it.

In GNOME settings , you can configure wifi connections for all wifi network security types that RHEL supports.

  • Press the Super key, type Wi-Fi , and press Enter .
  • Click on the name of the wifi network you want to connect to.
  • Enter the password for the network, and click Connect .

If the network requires additional settings, such as static IP addresses or a security type other than WPA2 Personal:

  • Click the gear icon next to the network’s name.

Optional: Configure the network profile on the Details tab to not automatically connect.

If you deactivate this feature, you must always manually connect to the network, for example, by using GNOME settings or the GNOME system menu.

  • Configure IPv4 settings on the IPv4 tab, and IPv6 settings on the IPv6 tab.

On the Security tab, select the authentication of the network, such as WPA3 Personal , and enter the password.

Depending on the selected security, the application shows additional fields. Fill them accordingly. For details, ask the administrator of the wifi network.

10.5. Configuring a wifi connection by using nmtui

The nmtui application provides a text-based user interface for NetworkManager. You can use nmtui to connect to a wifi network.

  • Select Wi-Fi from the list of network types, and press Enter .
  • Enter the network device name into the Device field.
  • Enter the name of the Wi-Fi network, the Service Set Identifier (SSID), into the SSID field.
  • Leave the Mode field set to its default, Client .

Select the Security field, press Enter , and set the authentication type of the network from the list.

Depending on the authentication type you have selected, nmtui displays different fields.

  • Fill the authentication type-related fields.

If the Wi-Fi network requires static IP addresses:

  • Press the Automatic button next to the protocol, and select Manual from the displayed list.
  • Press the Show button next to the protocol you want to configure to display additional fields, and fill them.

nmtui wi fi dynamic IP

10.6. Configuring a wifi connection by using nm-connection-editor

You can use the nm-connection-editor application to create a connection profile for a wireless network. In this application you can configure all wifi network authentication types that RHEL supports.

By default, NetworkManager enables the auto-connect feature for connection profiles and automatically connects to a saved network if it is available.

Open a terminal and enter:

  • Select the Wi-Fi connection type, and click Create .
  • Optional: Set a name for the connection profile.

Optional: Configure the network profile on the General tab to not automatically connect.

  • On the Wi-Fi tab, enter the service set identifier (SSID) in the SSID field.

On the Wi-Fi Security tab, select the authentication type for the network, such as WPA3 Personal , and enter the password.

  • Close the Network Connections window.

10.7. Configuring a wifi connection with 802.1X network authentication by using the network RHEL System Role

Using RHEL System Roles, you can automate the creation of a wifi connection. For example, you can 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 wifi network. The playbook configures the connection profile to use DHCP. To configure static IP settings, adapt the parameters in the ip dictionary accordingly.

  • The network supports 802.1X network authentication.
  • You installed the wpa_supplicant package on the managed node.
  • DHCP is available in the network of the managed node.

The following files required for TLS authentication exist on the control node:

  • The client key is stored in the /srv/data/client.key file.
  • The client certificate is stored in the /srv/data/client.crt file.
  • The CA certificate is stored in the /srv/data/ca.crt file.

Create a playbook file, for example ~/enable-802.1x.yml , with the following content:

These settings define a wifi connection profile for the wlp1s0 interface. The profile uses 802.1X standard to authenticate the client to the wifi network. The connection retrieves IPv4 addresses, IPv6 addresses, default gateway, routes, DNS servers, and search domains from a DHCP server and IPv6 stateless address autoconfiguration (SLAAC).

10.8. Configuring a wifi connection with 802.1X network authentication in an existing profile by using nmcli

Using the nmcli utility, you can configure the client to authenticate itself to the network. For example, you can configure Protected Extensible Authentication Protocol (PEAP) authentication with the Microsoft Challenge-Handshake Authentication Protocol version 2 (MSCHAPv2) in an existing NetworkManager wifi connection profile named wlp1s0 .

  • The network must have 802.1X network authentication.
  • The wifi connection profile exists in NetworkManager and has a valid IP configuration.
  • If the client is required to verify the certificate of the authenticator, the Certificate Authority (CA) certificate must be stored in the /etc/pki/ca-trust/source/anchors/ directory.
  • The wpa_supplicant package is installed.

Set the wifi security mode to wpa-eap , the Extensible Authentication Protocol (EAP) to peap , the inner authentication protocol to mschapv2 , and the user name:

Note that you must set the wireless-security.key-mgmt , 802-1x.eap , 802-1x.phase2-auth , and 802-1x.identity parameters in a single command.

Optionally, store the password in the configuration:

By default, NetworkManager stores the password in plain text in the /etc/sysconfig/network-scripts/keys- connection_name file, which is readable only by the root user. However, plain text passwords in a configuration file can be a security risk.

To increase the security, set the 802-1x.password-flags parameter to 0x1 . With this setting, on servers with the GNOME desktop environment or the nm-applet running, NetworkManager retrieves the password from these services. In other cases, NetworkManager prompts for the password.

If the client needs to verify the certificate of the authenticator, set the 802-1x.ca-cert parameter in the connection profile to the path of the CA certificate:

For security reasons, Red Hat recommends the certificate of the authenticator to enable clients to validate the identity of the authenticator.

Activate the connection profile:

  • Access resources on the network that require network authentication.
  • Managing wifi connections

10.9. Manually setting the wireless regulatory domain

On RHEL, a udev rule executes the setregdomain utility to set the wireless regulatory domain. The utility then provides this information to the kernel.

By default, setregdomain attempts to determine the country code automatically. If this fails, the wireless regulatory domain setting might be wrong. To work around this problem, you can manually set the country code.

Manually setting the regulatory domain disables the automatic detection. Therefore, if you later use the computer in a different country, the previously configured setting might no longer be correct. In this case, remove the /etc/sysconfig/regdomain file to switch back to automatic detection or use this procedure to manually update the regulatory domain setting again.

Optional: Display the current regulatory domain settings:

Create the /etc/sysconfig/regdomain file with the following content:

Set the COUNTRY variable to an ISO 3166-1 alpha2 country code, such as DE for Germany or US for the United States of America.

Set the regulatory domain:

Display the regulatory domain settings:

  • setregdomain(1) man page
  • iw(8) man page
  • regulatory.bin(5) man page
  • ISO 3166 Country Codes

Chapter 11. Configuring RHEL as a WPA2 or WPA3 Personal access point

On a host with a wifi device, you can use NetworkManager to configure this host as an access point. Wi-Fi Protected Access 2 (WPA2) and Wi-Fi Protected Access 3 (WPA3) Personal provide secure authentication methods, and wireless clients can use a pre-shared key (PSK) to connect to the access point and use services on the RHEL host and in the network.

When you configure an access point, NetworkManager automatically:

  • Configures the dnsmasq service to provide DHCP and DNS services for clients
  • Enables IP forwarding
  • Adds nftables firewall rules to masquerade traffic from the wifi device and configures IP forwarding
  • The wifi device supports running in access point mode.
  • The wifi device is not in use.
  • The host has internet access.

List the wifi devices to identify the one that should provide the access point:

Verify that the device supports the access point mode:

To use a wifi device as an access point, the device must support this feature.

Install the dnsmasq and NetworkManager-wifi packages:

NetworkManager uses the dnsmasq service to provide DHCP and DNS services to clients of the access point.

Create the initial access point configuration:

This command creates a connection profile for an access point on the wlp0s20f3 device that provides WPA2 and WPA3 Personal authentication. The name of the wireless network, the Service Set Identifier (SSID), is Example-Hotspot and uses the pre-shared key password .

Optional: Configure the access point to support only WPA3:

By default, NetworkManager uses the IP address 10.42.0.1 for the wifi device and assigns IP addresses from the remaining 10.42.0.0/24 subnet to clients. To configure a different subnet and IP address, enter:

The IP address you set, in this case 192.0.2.254 , is the one that NetworkManager assigns to the wifi device. Clients will use this IP address as default gateway and DNS server.

On the server:

Verify that NetworkManager started the dnsmasq service and that the service listens on port 67 (DHCP) and 53 (DNS):

Display the nftables rule set to ensure that NetworkManager enabled forwarding and masquerading for traffic from the 10.42.0.0/24 subnet:

On a client with a wifi adapter:

Display the list of available networks:

  • Connect to the Example-Hotspot wireless network. See Managing Wi-Fi connections .

Ping a host on the remote network or the internet to verify that the connection works:

Chapter 12. Changing a hostname

The hostname of a system is the name on the system itself. You can set the name when you install RHEL, and you can change it afterwards.

12.1. Changing a hostname using nmcli

You can use the nmcli utility to update the system hostname. Note that other utilities might use a different term, such as static or persistent hostname.

Optional: Display the current hostname setting:

Set the new hostname:

NetworkManager automatically restarts the systemd-hostnamed to activate the new name. For the changes to take effect, reboot the host:

Alternatively, if you know which services use the hostname:

Restart all services that only read the hostname when the service starts:

  • Active shell users must re-login for the changes to take effect.

Display the hostname:

12.2. Changing a hostname using hostnamectl

You can use the hostnamectl utility to update the hostname. By default, this utility sets the following hostname types:

  • Static hostname: Stored in the /etc/hostname file. Typically, services use this name as the hostname.
  • Pretty hostname: A descriptive name, such as Proxy server in data center A .
  • Transient hostname: A fall-back value that is typically received from the network configuration.

This command sets the static, pretty, and transient hostname to the new value. To set only a specific type, pass the --static , --pretty , or --transient option to the command.

The hostnamectl utility automatically restarts the systemd-hostnamed to activate the new name. For the changes to take effect, reboot the host:

  • hostnamectl(1)
  • systemd-hostnamed.service(8)

Chapter 13. Legacy network scripts support in RHEL

By default, RHEL uses NetworkManager to configure and manage network connections, and the /usr/sbin/ifup and /usr/sbin/ifdown scripts use NetworkManager to process ifcfg files in the /etc/sysconfig/network-scripts/ directory.

The legacy scripts are deprecated in RHEL 8 and will be removed in a future major version of RHEL. If you still use the legacy network scripts, for example, because you upgraded from an earlier version to RHEL 8, Red Hat recommends that you migrate your configuration to NetworkManager.

13.1. Installing the legacy network scripts

If you require the deprecated network scripts that processes the network configuration without using NetworkManager, you can install them. In this case, the /usr/sbin/ifup and /usr/sbin/ifdown scripts link to the deprecated shell scripts that manage the network configuration.

Install the network-scripts package:

Chapter 14. Mirroring a network interface by using nmcli

Network administrators can use port mirroring to replicate inbound and outbound network traffic being communicated from one network device to another. Mirroring traffic of an interface can be helpful in the following situations:

  • To debug networking issues and tune the network flow
  • To inspect and analyze the network traffic
  • To detect an intrusion
  • A network interface to mirror the network traffic to.

Add a network connection profile that you want to mirror the network traffic from:

Attach a prio qdisc to enp1s0 for the egress (outgoing) traffic with the 10: handle:

The prio qdisc attached without children allows attaching filters.

Add a qdisc for the ingress traffic, with the ffff: handle:

Add the following filters to match packets on the ingress and egress qdiscs , and to mirror them to enp7s0 :

The matchall filter matches all packets, and the mirred action redirects packets to destination.

Install the tcpdump utility:

Display the traffic mirrored on the target device ( enp7s0 ):

  • How to capture network packets using tcpdump

Chapter 15. Configuring NetworkManager to ignore certain devices

By default, NetworkManager manages all devices except the loopback ( lo ) device. However, you can configure NetworkManager as unmanaged to ignore certain devices. With this setting, you can manually manage these devices, for example, using a script.

15.1. Permanently configuring a device as unmanaged in NetworkManager

You can permanently configure devices as unmanaged based on several criteria, such as the interface name, MAC address, or device type.

To temporarily configure network devices as unmanaged , see Temporarily configuring a device as unmanaged in NetworkManager .

Optional: Display the list of devices to identify the device or MAC address you want to set as unmanaged :

Create the /etc/NetworkManager/conf.d/99-unmanaged-devices.conf file with the following content:

To configure a specific interface as unmanaged, add:

To configure a device with a specific MAC address as unmanaged, add:

To configure all devices of a specific type as unmanaged, add:

To set multiple devices as unmanaged, separate the entries in the unmanaged-devices parameter with a semicolon, for example:

Reload the NetworkManager service:

Display the list of devices:

The unmanaged state next to the enp1s0 device indicates that NetworkManager does not manage this device.

If the device is not shown as unmanaged , display the NetworkManager configuration:

If the output does not match the settings that you configured, ensure that no configuration file with a higher priority overrides your settings. For details about how NetworkManager merges multiple configuration files, see the NetworkManager.conf(5) man page.

15.2. Temporarily configuring a device as unmanaged in NetworkManager

You can temporarily configure devices as unmanaged .

Use this method, for example, for testing purposes. To permanently configure network devices as unmanaged , see Permanently configuring a device as unmanaged in NetworkManager .

Optional: Display the list of devices to identify the device you want to set as unmanaged :

Set the enp1s0 device to the unmanaged state:

  • NetworkManager.conf(5) man page

Chapter 16. 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

You can enable this mode for any kind of network device, except InfiniBand .

16.1. Temporarily configuring a device to accept all traffic

You can use the ip utility to temporary configure a network device to accept all traffic regardless of the MAC addresses.

Optional: Display the network interfaces to identify the one for which you want to receive all traffic:

Modify the device to enable or disable this property:

To enable the accept-all-mac-addresses mode for enp1s0 :

To disable the accept-all-mac-addresses mode for enp1s0 :

Verify that the accept-all-mac-addresses mode is enabled:

The PROMISC flag in the device description indicates that the mode is enabled.

16.2. Permanently configuring a network device to accept all traffic using nmcli

You can use the nmcli utility to permanently configure a network device to accept all traffic regardless of the MAC addresses.

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 for enp1s0 :

Apply the changes, reactivate the connection:

Verify that the ethernet.accept-all-mac-addresses mode is enabled:

The 802-3-ethernet.accept-all-mac-addresses: true indicates that the mode is enabled.

16.3. Permanently configuring a network device to accept all traffic using nmstatectl

Use the nmstatectl utility to configure a device to accept all traffic regardless of the MAC addresses through the Nmstate API. The Nmstate API ensures that, after setting the configuration, the result matches the configuration file. If anything fails, nmstatectl automatically rolls back the changes to avoid leaving the system in an incorrect state.

  • The enp1s0.yml file that you used to configure the device is available.

Edit the existing enp1s0.yml file for the enp1s0 connection and add the following content to it:

These settings configure the enp1s0 device to accept all traffic.

Apply the network settings:

Verify that the 802-3-ethernet.accept-all-mac-addresses mode is enabled:

Chapter 17. Setting up an 802.1x network authentication service for LAN clients by using hostapd with FreeRADIUS backend

The IEEE 802.1X standard defines secure authentication and authorization methods to protect networks from unauthorized clients. By 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.

rhel authenticator 802 1x

17.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 by using the yum reinstall command, because the permissions and symbolic links in the /etc/raddb/ directory are then different.

17.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.

  • The server has multiple Ethernet interfaces.

Create the bridge interface:

Assign the Ethernet interfaces to the bridge:

Enable the bridge to forward extensible authentication protocol over LAN (EAPOL) packets:

Configure the connection to automatically activate the ports:

Display the link status of Ethernet devices that are ports of a specific bridge:

Verify if forwarding of EAPOL packets is enabled on the br0 device:

If the command returns 0x8 , forwarding is enabled.

17.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.

17.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
  • You installed the freeradius package.

Change into the /etc/raddb/certs/ directory:

Optional: Customize the CA configuration in the /etc/raddb/certs/ca.cnf file:

Optional: Customize the server configuration in the /etc/raddb/certs/server.cnf file::

Optional: Customize the client configuration in the /etc/raddb/certs/client.cnf file::

Create the certificates:

Change the group on the /etc/raddb/certs/server.pem file to radiusd :

  • /etc/raddb/certs/README.md

17.5. Configuring FreeRADIUS to authenticate network clients securely by using EAP

FreeRADIUS supports different methods of the Extensible authentication protocol (EAP). However, for a secure network, configure FreeRADIUS to support only the following secure EAP authentication methods:

  • EAP-TLS (transport layer security) uses a secure TLS connection to authenticate clients by 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 by 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 by 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.

  • The configuration files in the /etc/raddb/ directory are unchanged and as provided by the freeradius 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 , and ca_file parameters in the /etc/raddb/mods-available/eap file accordingly.

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:

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:

Edit the /etc/raddb/mods-available/eap file:

Set the password of the private key in the private_key_password parameter:

Depending on your environment, set the default_eap_type parameter in the eap directive to your primary EAP type you use:

For a secure environment, use only ttls , tls , or peap .

Comment out the md5 directives to disable the insecure EAP-MD5 authentication method:

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 than eap :

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 and localhost_ipv6 client directives:

If RADIUS clients, such as network authenticators, on remote hosts should be able to access the FreeRADIUS service, add corresponding client directives for them:

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:

For users who should use certificate-based authentication (EAP-TLS), do not add any entry.

Verify the configuration files:

Enable and start the radiusd service:

  • Testing EAP-TTLS authentication against a FreeRADIUS server or authenticator
  • Testing EAP-TLS authentication against a FreeRADIUS server or authenticator

Stop the radiusd service:

Start the service in debug mode:

  • Perform authentication tests on the FreeRADIUS host, as referenced in the Verification section.
  • Disable no longer required authentication methods and other features you do not use.

17.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.

  • You installed the hostapd package.
  • The FreeRADIUS server has been configured, and it is ready to authenticate clients.

Create the /etc/hostapd/hostapd.conf file with the following content:

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:

Stop the hostapd service:

  • hostapd.conf(5) man page
  • /usr/share/doc/hostapd/hostapd.conf file

17.7. Testing EAP-TTLS authentication against a FreeRADIUS server or authenticator

To test if authentication by 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.

When you want to authenticate to:

A FreeRADIUS server:

  • The eapol_test utility, provided by the hostapd package, is installed.
  • The client, on which you run this procedure, has been authorized in the FreeRADIUS server’s client databases.
  • 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.

Create the /etc/wpa_supplicant/wpa_supplicant-TTLS.conf file with the following content:

To authenticate to:

A FreeRADIUS server, enter:

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:

The -i option specifies the network interface name on which wpa_supplicant sends out extended authentication protocol over LAN (EAPOL) packets.

For more debugging information, pass the -d option to the command.

  • /usr/share/doc/wpa_supplicant/wpa_supplicant.conf file

17.8. Testing EAP-TLS authentication against a FreeRADIUS server or authenticator

To test if authentication by using extensible authentication protocol (EAP) transport layer security (EAP-TLS) works as expected, run this procedure:

  • 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

Create the /etc/wpa_supplicant/wpa_supplicant-TLS.conf file with the following content:

17.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.

  • The hostapd service has been configured, and the service is ready to authenticate clients.

Create the /usr/local/bin/802-1x-tr-mgmt file with the following content:

Create the /etc/systemd/system/[email protected] systemd service file with the following content:

Reload systemd:

Enable and start the 802-1x-tr-mgmt service with the interface name hostapd is listening on:

Authenticate with a client to the network. See:

  • systemd.service(5) man page

Chapter 18. Authenticating a RHEL client to the network by 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. To enable a client to connect to such networks, you must configure 802.1X authentication on this clients.

18.1. Configuring 802.1X network authentication on an existing Ethernet connection by using nmcli

You can use the nmcli utility to configure an Ethernet connection with 802.1X network authentication on the command line.

  • 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 the root 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.

Set the Extensible Authentication Protocol (EAP) to tls and the paths to the client certificate and key file:

Note that you must set the 802-1x.eap , 802-1x.client-cert , and 802-1x.private-key parameters in a single command.

Set the path to the CA certificate:

Set the identity of the user used in the certificate:

By default, NetworkManager stores the password in clear text in the /etc/sysconfig/network-scripts/keys- connection_name file, that is readable only by the root user. However, clear text passwords in a configuration file can be a security risk.

18.2. Configuring a static Ethernet connection with 802.1X network authentication by using nmstatectl

Use the nmstatectl utility to configure an Ethernet connection with 802.1X network authentication through the Nmstate API. The Nmstate API ensures that, after setting the configuration, the result matches the configuration file. If anything fails, nmstatectl automatically rolls back the changes to avoid leaving the system in an incorrect state.

The nmstate library only supports the TLS Extensible Authentication Protocol (EAP) method.

  • The managed node uses NetworkManager.
  • 802.1X network authentication using the TLS EAP protocol

18.3. Configuring a static Ethernet connection with 802.1X network authentication by using the network RHEL System Role

You can remotely configure an Ethernet connection with 802.1X network authentication by using the network RHEL System Role.

  • The managed nodes or groups of managed nodes on which you want to run this playbook are listed in the Ansible inventory file
  • The managed nodes uses NetworkManager.
  • The Certificate Authority (CA) certificate is stored in the /srv/data/ca.crt file.
  • 802.1X network authentication using the TLS Extensible Authentication Protocol (EAP)

Chapter 19. 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.

19.1. Setting the default gateway on an existing connection by using nmcli

In most situations, administrators set the default gateway when they create a connection as explained in, for example, Configuring an Ethernet connection by using nmcli .

In most situations, administrators set the default gateway when they create a connection. However, you can also set or update the default gateway setting on a previously created connection using the nmcli utility.

  • 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.

Set the IP address of the default gateway.

For example, to set the IPv4 address of the default gateway on the example connection to 192.0.2.1 :

For example, to set the IPv6 address of the default gateway on the example connection to 2001:db8:1::1 :

Restart the network connection for changes to take effect. For example, to restart the example connection using the command line:

All 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:

To display the IPv6 default gateway:

19.2. Setting the default gateway on an existing connection by using the nmcli interactive mode

In most situations, administrators set the default gateway when they create a connection as explained in, for example, Configuring an Ethernet connection by using the nmcli interactive editor

In most situations, administrators set the default gateway when they create a connection. However, you can also set or update the default gateway setting on a previously created connection using the interactive mode of the nmcli utility.

  • If the user is logged in on a physical console, user permissions are sufficient. Otherwise, the user must have root permissions.

Open the nmcli interactive mode for the required connection. For example, to open the nmcli interactive mode for the example connection:

Set the default gateway.

Optionally, verify that the default gateway was set correctly:

Save the configuration:

Restart the network connection for changes to take effect:

Leave the nmcli interactive mode:

  • Configuring an Ethernet connection by using the nmcli interactive editor

19.3. Setting the default gateway on an existing connection by using nm-connection-editor

In most situations, administrators set the default gateway when they create a connection. However, you can also set or update the default gateway setting on a previously created connection using the nm-connection-editor application.

  • 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:

set default gw in nm connection editor ipv4

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.

set default gw in nm connection editor ipv6

  • Configuring an Ethernet connection by using nm-connection-editor

19.4. Setting the default gateway on an existing connection by using control-center

In most situations, administrators set the default gateway when they create a connection. However, you can also set or update the default gateway setting on a previously created connection using the control-center application.

  • The network configuration of the connection is open in the control-center application.
  • Open the IPv4 tab.

set default gw in control center ipv4

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.

  • Configuring an Ethernet connection by using control-center

19.5. Setting the default gateway on an existing connection by using nmstatectl

Use the nmstatectl utility to set the default gateway through the Nmstate API. The Nmstate API ensures that, after setting the configuration, the result matches the configuration file. If anything fails, nmstatectl automatically rolls back the changes to avoid leaving the system in an incorrect state.

  • The enp1s0 interface is configured, and the IP address of the default gateway is within the subnet of the IP configuration of this interface.

Create a YAML file, for example ~/set-default-gateway.yml , with the following content:

These settings define 192.0.2.1 as the default gateway, and the default gateway is reachable through the enp1s0 interface.

19.6. Setting the default gateway on an existing connection by using the network RHEL System Role

You can use the network RHEL System Role to set the default gateway.

When you run a play that uses the network RHEL System Role and if the setting values do not match the values specified in the play, the role overrides the existing connection profile with the same name. To prevent resetting these values to their defaults, always specify the whole configuration of the network connection profile in the play, even if the configuration, for example the IP configuration, already exists.

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
  • An IPv4 default gateway - 198.51.100.254
  • An IPv4 DNS server - 198.51.100.200

Create a playbook file, for example ~/ethernet-connection.yml , with the following content:

19.7. Setting the default gateway on an existing connection when using the legacy network scripts

In most situations, administrators set the default gateway when they create a connection. However, you can also set or update the default gateway setting on a previously created connection when you use the legacy network scripts.

  • The NetworkManager package is not installed, or the NetworkManager service is disabled.
  • The network-scripts package is installed.

Set the GATEWAY parameter in the /etc/sysconfig/network-scripts/ifcfg-enp1s0 file to 192.0.2.1 :

Add the default entry in the /etc/sysconfig/network-scripts/route-enp0s1 file:

Restart the network:

19.8. 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:

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:

  • Configuring policy-based routing to define alternative routes
  • Getting started with Multipath TCP

19.9. 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.

  • The NetworkManager connection profile for the connection that is not connected to the default gateway exists.

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:

Note that setting ipv4.never-default and ipv6.never-default to yes , automatically removes the default gateway’s IP address for the corresponding protocol from the connection profile.

  • Use the ip -4 route and ip -6 route commands to verify that RHEL does not use the network interface for the default route for the IPv4 and IPv6 protocol.

19.10. 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.

  • 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.

Display the routing table:

For IPv4, enter:

For IPv6, enter:

Entries starting with default indicate a default route. Note the interface names of these entries displayed next to dev .

Use the following commands to display the NetworkManager connections that use the interfaces you identified in the previous step:

In these examples, the profiles named Corporate-LAN and Internet-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 the Corporate-LAN are incorrect.

Configure that NetworkManager does not use the Corporate-LAN connection as the default route for IPv4 and IPv6 connections:

Activate the Corporate-LAN connection:

Display the IPv4 and IPv6 routing tables and verify that only one default gateway is available for each protocol:

Chapter 20. 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 20.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.

20.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.

routing example

In case that the required static routes are not configured , the following are the situations in which the communication works and when it does not:

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 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 ):

  • 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 the rp_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.

  • Why cannot a server be pinged if net.ipv4.conf.all.rp_filter is set on the server?
  • Enabling IP forwarding

20.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:

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 the main 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 the unicast , local , blackhole , unreachable , prohibit , and throw route types. The default is unicast .
  • 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:

Similarly, to remove a specific route:

20.3. Configuring a static route by using nmcli

You can add a static route to an existing NetworkManager connection profile using the nmcli connection modify command.

The procedure below configures the following routes:

  • An IPv4 route to the remote 198.51.100.0/24 network. The corresponding gateway with the IP address 192.0.2.10 is reachable through the example connection.
  • An IPv6 route to the remote 2001:db8:2::/64 network. The corresponding gateway with the IP address 2001:db8:1::10 is reachable through the example connection.
  • The example connection profile exists and it configures this host to be in the same IP subnet as the gateways.

Add the static IPv4 route to the example connection profile:

To set multiple routes in one step, pass the individual routes comma-separated to the command. For example, to add a route to the 198.51.100.0/24 and 203.0.113.0/24 networks, both routed through the 192.0.2.10 gateway, enter:

Add the static IPv6 route to the example connection profile:

Display the IPv4 routes:

Display the IPv6 routes:

20.4. Configuring a static route by using nmtui

The nmtui application provides a text-based user interface for NetworkManager. You can use nmtui to configure static routes on a host without a graphical interface.

For example, the procedure below adds a route to the 192.0.2.0/24 network that uses the gateway running on 198.51.100.1 , which is reachable through an existing connection profile.

  • 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.
  • Select the connection profile through which you can reach the next hop to the destination network, and press Enter .
  • Depending on whether it is an IPv4 or IPv6 route, press the Show button next to the protocol’s configuration area.

Press the Edit button next to Routing . This opens a new window where you configure static routes:

Press the Add button and fill in:

  • The destination network, including the prefix in Classless Inter-Domain Routing (CIDR) format
  • The IP address of the next hop
  • A metric value, if you add multiple routes to the same network and want to prioritize the routes by efficiency
  • Repeat the previous step for every route you want to add and that is reachable through this connection profile.

Press the OK button to return to the window with the connection settings.

Figure 20.1. Example of a static route without metric

nmtui add static route

  • Press the OK button to return to the nmtui main menu.
  • Select Activate a connection and press Enter .

Select the connection profile that you edited, and press Enter twice to deactivate and activate it again.

Skip this step if you run nmtui over a remote connection, such as SSH, that uses the connection profile you want to reactivate. In this case, if you would deactivate it in nmtui , the connection is terminated and, consequently, you cannot activate it again. To avoid this problem, use the nmcli connection connection_profile_name up command to reactivate the connection in the mentioned scenario.

Verify that the route is active:

20.5. Configuring a static route by using control-center

You can use control-center in GNOME to add a static route to the configuration of a network connection.

  • An IPv4 route to the remote 198.51.100.0/24 network. The corresponding gateway has the IP address 192.0.2.10 .
  • An IPv6 route to the remote 2001:db8:2::/64 network. The corresponding gateway has the IP address 2001:db8:1::10 .
  • This host is in the same IP subnet as the gateways.
  • The network configuration of the connection is opened in the control-center application. See Configuring an Ethernet connection by using nm-connection-editor .

On the IPv4 tab:

  • Optional: Disable automatic routes by clicking the On button in the Routes section of the IPv4 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 of the IPv4 route:

IPv4 static route in control center

On the IPv6 tab:

  • Optional: Disable automatic routes by clicking the On button i the Routes section of the IPv4 tab to use only static routes.

Enter the address, netmask, gateway, and optionally a metric value of the IPv6 route:

IPv6 static route in control center

Restarting the connection briefly disrupts connectivity on that interface.

20.6. Configuring a static route by using nm-connection-editor

You can use the nm-connection-editor application to add a static route to the configuration of a network connection.

  • Select the example connection profile, and click the gear wheel icon to edit the existing connection.

On the IPv4 Settings tab:

  • Click the Routes button.

Click the Add button and enter the address, netmask, gateway, and optionally a metric value.

IPv4 static route in nm connection editor

On the IPv6 Settings tab:

IPv6 static route in nm connection editor

20.7. Configuring a static route by 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.

Open the nmcli interactive mode for the example connection:

Add the static IPv4 route:

Add the static IPv6 route:

Optionally, verify that the routes were added correctly to the configuration:

The ip attribute displays the network to route and the nh attribute the gateway (next hop).

Restart the network connection:

20.8. Configuring a static route by using nmstatectl

Use the nmstatectl utility to configure a static route through the Nmstate API. The Nmstate API ensures that, after setting the configuration, the result matches the configuration file. If anything fails, nmstatectl automatically rolls back the changes to avoid leaving the system in an incorrect state.

  • The enp1s0 network interface is configured and is in the same IP subnet as the gateways.

Create a YAML file, for example ~/add-static-route-to-enp1s0.yml , with the following content:

These settings define the following static routes:

  • An IPv4 route to the remote 198.51.100.0/24 network. The corresponding gateway with the IP address 192.0.2.10 is reachable through the enp1s0 interface.
  • An IPv6 route to the remote 2001:db8:2::/64 network. The corresponding gateway with the IP address 2001:db8:1::10 is reachable through the enp1s0 interface.

20.9. Configuring a static route by using the network RHEL System Role

You can use the network RHEL System Role to configure static routes.

Create a playbook file, for example ~/add-static-routes.yml , with the following content:

Depending on whether it already exists, the procedure creates or updates the enp7s0 connection profile with the following settings:

Static routes:

  • 198.51.100.0/24 with gateway 192.0.2.10
  • 2001:db8:2::/64 with gateway 2001:db8:1::10

On the managed nodes:

20.10. Creating static routes configuration files in key-value format when using the legacy network scripts

The legacy network scripts support setting statics routes in key-value format.

The procedure below configures an IPv4 route to the remote 198.51.100.0/24 network. The corresponding gateway with the IP address 192.0.2.10 is reachable through the enp1s0 interface.

The legacy network scripts support the key-value format only for static IPv4 routes. For IPv6 routes, use the ip -command format. See Creating static routes configuration files in ip-command format when using the legacy network scripts .

  • The gateways for the static route must be directly reachable on the interface.
  • The network service is enabled.

Add the static IPv4 route to the /etc/sysconfig/network-scripts/route-enp0s1 file:

  • The ADDRESS0 variable defines the network of the first routing entry.
  • The NETMASK0 variable defines the netmask of the first routing entry.

The GATEWAY0 variable defines the IP address of the gateway to the remote network or host for the first routing entry.

If you add multiple static routes, increase the number in the variable names. Note that the variables for each route must be numbered sequentially. For example, ADDRESS0 , ADDRESS1 , ADDRESS3 , and so on.

Display the journal entries of the network unit:

The following are possible error messages and their causes:

  • Error: Nexthop has invalid gateway : You specified an IPv4 gateway address in the route- enp1s0 file that is not in the same subnet as this router.
  • RTNETLINK answers: No route to host : You specified an IPv6 gateway address in the route6- enp1s0 file that is not in the same subnet as this router.
  • Error: Invalid prefix for given prefix length : You specified the remote network in the route- enp1s0 file by using an IP address within the remote network rather than the network address.
  • /usr/share/doc/network-scripts/sysconfig.txt file

20.11. Creating static routes configuration files in ip-command format when using the legacy network scripts

The legacy network scripts support setting statics routes.

IP addresses of the gateways (next hop) must be in the same IP subnet as the host on which you configure the static routes.

The examples in this procedure use configuration entries in ip -command format.

Add the static IPv4 route to the /etc/sysconfig/network-scripts/route-enp1s0 file:

Always specify the network address of the remote network, such as 198.51.100.0 . Setting an IP address within the remote network, such as 198.51.100.1 causes that the network scripts fail to add this route.

Add the static IPv6 route to the /etc/sysconfig/network-scripts/route6-enp1s0 file:

Restart the network service:

Chapter 21. 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.

On systems that use NetworkManager, only the nmcli utility supports setting routing rules and assigning routes to specific tables.

21.1. Routing traffic from a specific subnet to a different default gateway by using nmcli

You can use policy-based routing to configure a different default gateway for traffic from certain subnets. For example, you can configure RHEL as a router that, by default, routes all traffic to internet provider A using the default route. However, traffic received from the internal workstations subnet is routed to provider B.

The procedure assumes the following network topology:

policy based routing

  • 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 is 198.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 is 192.0.2.2 , and the network uses a /30 network mask.
  • The enp8s0 interface is connected to the 10.0.0.0/24 subnet with internal workstations.
  • The enp9s0 interface is connected to the 203.0.113.0/24 subnet with the company’s servers.
  • Hosts in the internal workstations subnet use 10.0.0.1 as the default gateway. In the procedure, you assign this IP address to the enp8s0 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 the enp9s0 network interface of the router.
  • The firewalld service is enabled and active.

Configure the network interface to provider A:

The nmcli connection add command creates a NetworkManager connection profile. The command uses the following options:

  • 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 defined firewalld zone. Note that firewalld automatically enables masquerading for interfaces assigned to the external zone.

Configure the network interface to provider B:

This command uses the ipv4.routes parameter instead of ipv4.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:

This command uses the ipv4.routes parameter to add a static route to the routing table with ID 5000 . This static route for the 10.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 priority 5 that routes traffic from the 10.0.0.0/24 subnet to table 5000 . Low values have a high priority.

Note that the syntax in the ipv4.routing-rules parameter is the same as in an ip rule add command, except that ipv4.routing-rules always requires specifying a priority.

Configure the network interface to the server subnet:

On a RHEL host in the internal workstation subnet:

Install the traceroute package:

Use the traceroute utility to display the route to a host on the internet:

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:

The output of the command displays that the router sends packets over 198.51.100.2 , which is the network of provider A.

On the RHEL router:

Display the rule list:

By default, RHEL contains rules for the tables local , main , and default .

Display the routes in table 5000 :

Display the interfaces and firewall zones:

Verify that the external zone has masquerading enabled:

  • Is it possible to set up Policy Based Routing with NetworkManager in RHEL?

21.2. Routing traffic from a specific subnet to a different default gateway by using the network RHEL System Role

To configure policy-based routing remotely and on multiple nodes, you can use the RHEL network System Role. Perform this procedure on the Ansible control node.

This procedure assumes the following network topology:

  • The account you use to connect to the managed nodes has sudo permissions on the them.
  • The managed nodes uses the NetworkManager and firewalld services.

The managed nodes you want to configure has four network interfaces:

Create a playbook file, for example ~/pbr.yml , with the following content:

On the RHEL router that you configured using the RHEL System Role:

21.3. Overview of configuration files involved in policy-based routing when using the legacy network scripts

If you use the legacy network scripts instead of NetworkManager to configure your network, you can also configure policy-based routing.

Configuring the network using the legacy network scripts provided by the network-scripts package is deprecated in RHEL 8. Red Hat recommends that you use NetworkManager to configure policy-based routing. For an example, see Routing traffic from a specific subnet to a different default gateway by using nmcli .

The following configuration files are involved in policy-based routing when you use the legacy network scripts:

/etc/sysconfig/network-scripts/route- interface : This file defines the IPv4 routes. Use the table option to specify the routing table. For example:

  • /etc/sysconfig/network-scripts/route6- interface : This file defines the IPv6 routes.

/etc/sysconfig/network-scripts/rule- interface : This file defines the rules for IPv4 source networks for which the kernel routes traffic to specific routing tables. For example:

  • /etc/sysconfig/network-scripts/rule6- interface : This file defines the rules for IPv6 source networks for which the kernel routes traffic to specific routing tables.

/etc/iproute2/rt_tables : This file defines the mappings if you want to use names instead of numbers to refer to specific routing tables. For example:

  • ip-route(8) man page
  • ip-rule(8) man page

21.4. Routing traffic from a specific subnet to a different default gateway by using the legacy network scripts

Configuring the network using the legacy network scripts provided by the network-scripts package is deprecated in RHEL 8. Follow the procedure only if you use the legacy network scripts instead of NetworkManager on your host. If you use NetworkManager to manage your network settings, see Routing traffic from a specific subnet to a different default gateway by using nmcli .

The legacy network scripts process configuration files in alphabetical order. Therefore, you must name the configuration files in a way that ensures that an interface, that is used in rules and routes of other interfaces, are up when a depending interface requires it. To accomplish the correct order, this procedure uses numbers in the ifcfg-* , route-* , and rules-* files.

Add the configuration for the network interface to provider A by creating the /etc/sysconfig/network-scripts/ifcfg-1_Provider-A file with the following content:

The configuration file uses the following parameters:

  • TYPE = Ethernet : Defines that the connection type is Ethernet.
  • IPADDR = IP_address : Sets the IPv4 address.
  • PREFIX = subnet_mask : Sets the subnet mask.
  • GATEWAY = IP_address : Sets the default gateway address.
  • DNS1 = IP_of_DNS_server : Sets the IPv4 address of the DNS server.
  • DEFROUTE = yes|no : Defines whether the connection is a default route or not.
  • NAME = connection_name : Sets the name of the connection profile. Use a meaningful name to avoid confusion.
  • DEVICE = network_device : Sets the network interface.
  • ONBOOT = yes : Defines that RHEL starts this connection when the system boots.
  • ZONE = firewalld_zone : Assigns the network interface to the defined firewalld zone. Note that firewalld automatically enables masquerading for interfaces assigned to the external zone.

Add the configuration for the network interface to provider B:

Create the /etc/sysconfig/network-scripts/ifcfg-2_Provider-B file with the following content:

Note that the configuration file for this interface does not contain a default gateway setting.

Assign the gateway for the 2_Provider-B connection to a separate routing table. Therefore, create the /etc/sysconfig/network-scripts/route-2_Provider-B file with the following content:

This entry assigns the gateway and traffic from all subnets routed through this gateway to table 5000.

Create the configuration for the network interface to the internal workstations subnet:

Create the /etc/sysconfig/network-scripts/ifcfg-3_Internal-Workstations file with the following content:

Add the routing rule configuration for the internal workstation subnet. Therefore, create the /etc/sysconfig/network-scripts/rule-3_Internal-Workstations file with the following content:

This configuration defines a routing rule with priority 5 that routes all traffic from the 10.0.0.0/24 subnet to table 5000 . Low values have a high priority.

Create the /etc/sysconfig/network-scripts/route-3_Internal-Workstations file with the following content to add a static route to the routing table with ID 5000 :

This static route defines that RHEL sends traffic from the 10.0.0.0/24 subnet to the IP of the local network interface to provider B ( 192.0.2.1 ). This interface is to routing table 5000 and used as the next hop.

Add the configuration for the network interface to the server subnet by creating the /etc/sysconfig/network-scripts/ifcfg-4_Servers file with the following content:

  • Overview of configuration files involved in policy-based routing when using the legacy network scripts

Chapter 22. Configuring NetworkManager DHCP settings

NetworkManager provides different configuration options related to DHCP. For example, you can configure NetworkManager to use the build-in DHCP client (default) or an external client, and you can influence DHCP settings of individual profiles.

22.1. Changing the DHCP client of NetworkManager

By default, NetworkManager uses its internal DHCP client. However, if you require a DHCP client with features that the built-in client does not provide, you can alternatively configure NetworkManager to use dhclient .

Note that RHEL does not provide dhcpcd and, therefore, NetworkManager can not use this client.

Create the /etc/NetworkManager/conf.d/dhcp-client.conf file with the following content:

You can set the dhcp parameter to internal (default) or dhclient .

If you set the dhcp parameter to dhclient , install the dhcp-client package:

Restart NetworkManager:

Note that the restart temporarily interrupts all network connections.

Search in the /var/log/messages log file for an entry similar to the following:

This log entry confirms that NetworkManager uses dhclient as DHCP client.

22.2. Configuring the DHCP behavior of a NetworkManager connection

A Dynamic Host Configuration Protocol (DHCP) client requests the dynamic IP address and corresponding configuration information from a DHCP server each time a client connects to the network.

When you configured a connection to retrieve an IP address from a DHCP server, the NetworkManager requests an IP address from a DHCP server. By default, the client waits 45 seconds for this request to be completed. When a DHCP connection is started, a dhcp client requests an IP address from a DHCP server.

  • A connection that uses DHCP is configured on the host.

Set the ipv4.dhcp-timeout and ipv6.dhcp-timeout properties. For example, to set both options to 30 seconds, enter:

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:

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 the autoconnect-retries property. The default is 4 .
  • 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.

Optional: Configure the behavior if NetworkManager does not receive an IPv6 address before the timeout:

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, such as IPv4 and IPv6 addresses. After creating the interface, NetworkManager automatically assigns it to the default public firewalld zone.

Create a dummy interface named dummy0 with static IPv4 and IPv6 addresses:

To configure a dummy interface without IPv4 and IPv6 addresses, set both the ipv4.method and ipv6.method parameters to disabled . Otherwise, IP auto-configuration fails, and NetworkManager deactivates the connection and removes the device.

List the connection profiles:

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 and enp2s0 interfaces of the RHEL server are connected to switch ports that are configured with VLAN ID 100 and VLAN name prod-net .
  • The enp3s0 interface of the RHEL server is connected to a switch port that is configured with VLAN ID 200 and VLAN name mgmt-net .

The nmstate-autoconf utility then uses this information to create the following interfaces on the server:

  • bond100 - A bond interface with enp1s0 and enp2s0 as ports.
  • prod-net - A VLAN interface on top of bond100 with VLAN ID 100 .
  • mgmt-net - A VLAN interface on top of enp3s0 with VLAN ID 200

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.

  • LLDP is enabled on the network switch.
  • The Ethernet interfaces are up.

Enable LLDP on the Ethernet interfaces:

Create a YAML file, for example ~/enable-lldp.yml , with the following content:

Configure the network interfaces using LLDP:

Optional, start a dry-run to display and verify the YAML configuration that nmstate-autoconf generates:

Use nmstate-autoconf to generate the configuration based on information received from LLDP, and apply the settings to the system:

If there is no DHCP server in your network that provides the IP settings to the interfaces, configure them manual. For details, see:

Display the settings of the individual interfaces:

  • 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.

  • The switch supports LLDP.
  • LLDP is enabled on neighbor devices.

Create the ~/enable-LLDP-enp1s0.yml file with the following content:

Use the ~/enable-LLDP-enp1s0.yml file to enable LLDP on interface enp1s0 :

Display the LLDP information:

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 :

If the network configuration of the enp1s0 interface uses a different VLAN ID, change it accordingly.

Configuring VLAN tagging

Chapter 26. NetworkManager connection profiles in keyfile format

By default, NetworkManager stores connection profiles in ifcfg format, but you can also use profiles in keyfile format. Unlike the deprecated ifcfg format, the keyfile format supports all connection settings that NetworkManager provides.

In the Red Hat Enterprise Linux 9, the keyfile format will be the default.

26.1. The keyfile format of NetworkManager profiles

The keyfile format is similar to the INI format. For example, the following is an Ethernet connection profile in keyfile format:

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 user 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 location of persistent profiles. If you modify a persistent profile by using the NetworkManager API, NetworkManager writes and overwrites files in this directory.
  • /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. 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 the chroot 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

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:

The connection name you specified with the con-name key is saved into the id variable of the generated profile. When you use the nmcli command to manage this connection later, specify the connection as follows:

  • When the id variable is not omitted, use the connection name, for example Example-Connection .
  • When the id variable is omitted, use the file name without the .nmconnection suffix, for example output .

Set permissions to the configuration file so that only the root user can read and update it:

Start the NetworkManager service:

If you set the autoconnect variable in the profile to false , activate the connection:

Verify that the NetworkManager service is running:

Verify that NetworkManager can read the profile from the configuration file:

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:

  • nm-settings-keyfile(5)
  • The keyfile format of NetworkManager profiles
  • Configuring an Ethernet connection by using nmcli

26.3. Manually creating a NetworkManager profile in keyfile format

You can 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. As an alternative, you can use nmcli in offline mode. See Using nmcli to create keyfile connection profiles in offline mode

If you create a profile for a hardware interface, such as Ethernet, display the MAC address of this interface:

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:

You can use any file name with a .nmconnection suffix. However, when you later use nmcli commands to manage the connection, you must use the connection name set in the id variable when you refer to this connection. When you omit the id 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:

Reload the connection profiles:

Verify that NetworkManager read the profile from the configuration file:

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.

  • nm-settings-keyfile (5)

26.4. The differences in interface renaming with profiles in ifcfg and keyfile format

You can define custom network interface names, such as provider or lan to make interface names more descriptive. In this case, the udev service renames the interfaces. The renaming process works differently depending on whether you use connection profiles in ifcfg or keyfile format.

  • The /usr/lib/udev/rules.d/60-net.rules udev rule calls the /lib/udev/rename_device helper utility.
  • The helper utility searches for the HWADDR 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 the DEVICE parameter of the file.
  • Create a systemd link file or a udev rule to rename an interface.
  • Use the custom interface name in the interface-name property of a NetworkManager connection profile.

26.5. Migrating NetworkManager profiles from ifcfg to keyfile format

If you use connection profiles in ifcfg format, you can convert them to the keyfile format to have all profiles in the preferred format and in one location.

If an ifcfg file contains the NM_CONTROLLED=no setting, NetworkManager does not control this profile and, consequently the migration process ignores it.

  • You have connection profiles in ifcfg format in the /etc/sysconfig/network-scripts/ directory.
  • If the connection profiles contain a DEVICE variable that is set to a custom device name, such as provider or lan , you created a systemd link file or a udev rule for each of the custom device names.

Migrate the connection profiles:

Optionally, you can verify that you successfully migrated all your connection profiles:

  • nm-settings-ifcfg-rh(5)

Chapter 27. 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 .

RHEL uses the network and network-online targets and the NetworkManager-wait-online service while applying network settings. Also, you can configure systemd services to start after the network is fully available if these services cannot dynamically reload.

27.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.

27.2. Overview of NetworkManager-wait-online

The synchronous legacy network scripts iterate through all configuration files to set up devices. They apply all network-related configurations and ensure that the network is 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 and ipv6.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.

27.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/ .

To open the service file in the editor, enter:

Enter the following, and save the changes:

Reload the systemd service.

Chapter 28. 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.

In Red Hat Enterprise Linux, you can configure default queueing disciplines in various ways to manage the traffic on a network interface.

28.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.

Different types of qdiscs exist and help in the transfer of packets to and from a networking interface. You can configure qdiscs with root, parent, or child classes. The point where children can be attached are called classes. Classes in qdisc are flexible and can always contain either multiple children classes or a single child, qdisc . There is no prohibition against a class containing a classful qdisc 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 the qdisc . Eventually, this recursive packet passing ends up where the packets are stored (or picked up from in the case of dequeuing).

  • tc(8) man page
  • tc-actions(8) man page

28.2. Inspecting qdiscs of a network interface using the tc utility

By default, Red Hat Enterprise Linux systems use fq_codel qdisc . You can inspect the qdisc counters using the tc utility.

Optional: View your current qdisc :

Inspect the current qdisc counters:

  • 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

28.3. Updating the default qdisc

If you observe networking packet losses with the current qdisc , you can change the qdisc based on your network-requirements.

View the current default qdisc :

View the qdisc of current Ethernet connection:

Update the existing qdisc :

To apply the changes, reload the network driver:

Start the network interface:

View the qdisc of the Ethernet connection:

  • How to set sysctl variables on Red Hat Enterprise Linux

28.4. Temporarily setting the current qdisc of a network interface using the tc utility

You can update the current qdisc without changing the default one.

Optional: View the current qdisc :

Update the current qdisc :

View the updated current qdisc :

28.5. Permanently setting the current qdisc of a network interface using NetworkManager

You can update the current qdisc value of a NetworkManager connection.

Optional: To add another qdisc over the existing qdisc , use the +tc.qdisc option:

Activate the changes:

View current qdisc the network interface:

28.6. 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 28.1. Available schedulers in RHEL

The qdisc offload requires hardware and driver support on NIC.

Chapter 29. Getting started with Multipath TCP

Transmission Control Protocol (TCP) ensures reliable delivery of the data through the internet and automatically adjusts its bandwidth in response to network load. Multipath TCP (MPTCP) is an extension to the original TCP protocol (single-path). MPTCP enables a transport connection to operate across multiple paths simultaneously, and brings network connection redundancy to user endpoint devices.

29.1. Understanding MPTCP

The Multipath TCP (MPTCP) protocol allows for simultaneous usage of multiple paths between connection endpoints. The protocol design improves connection stability and also brings other benefits compared to the single-path TCP.

In MPTCP terminology, links are considered as paths.

The following are some of the advantages of using 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.

For more details about MPTCP, we highly recommend you review the Additional resources .

  • Understanding Multipath TCP: High availability for endpoints and the networking highway of the future
  • RFC8684: TCP Extensions for Multipath Operation with Multiple Addresses
  • Multipath TCP on Red Hat Enterprise Linux 8.3: From 0 to 1 subflows

29.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.

You can use the sysctl utility to enable MPTCP support and prepare RHEL for enabling MPTCP for applications system-wide using a SystemTap script.

The following packages are installed:

Enable MPTCP sockets in the kernel:

Verify that MPTCP is enabled in the kernel:

Create a mptcp-app.stap file with the following content:

Force user space applications to create MPTCP sockets instead of TCP ones:

Note: This operation affects all TCP sockets which are started after the command. The applications will continue using TCP sockets after you interrupt the command above with Ctrl + C .

Alternatively, to allow MPTCP usage to only specific application, you can modify the mptcp-app.stap file with the following content:

In case of alternative choice, assuming, you want to force the iperf3 tool to use MPTCP instead of TCP. To do so, enter the following command:

After the mptcp-app.stap script installs the kernel probe, the following warnings appear in the kernel dmesg output

Start the iperf3 server:

Connect the client to the server:

After the connection is established, verify the ss output to see the subflow-specific status:

Verify MPTCP counters:

  • How can I download or install debuginfo packages for RHEL systems?
  • tcp(7) man page
  • mptcpize(8) man page

29.3. Using iproute2 to temporarily configure and enable multiple paths for MPTCP applications

Each MPTCP connection uses a single subflow similar to plain TCP. To get the MPTCP benefits, specify a higher limit for maximum number of subflows for each MPTCP connection. Then configure additional endpoints to create those subflows.

The configuration in this procedure will not persist after rebooting your machine.

Note that MPTCP does not yet support mixed IPv6 and IPv4 endpoints for the same socket. Use endpoints belonging to the same address family.

  • 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

Configure the client to accept up to 1 additional remote address, as provided by the server:

Add IP address 198.51.100.1 as a new MPTCP endpoint on the server:

The signal option ensures that the ADD_ADDR packet is sent after the three-way-handshake.

Verify the connection is established:

Verify the connection and IP address limit:

Verify the newly added endpoint:

Verify MPTCP counters by using the nstat MPTcp* command on a server:

  • ip-mptcp(8) man page

29.4. Permanently configuring multiple paths for MPTCP applications

You can configure MultiPath TCP (MPTCP) using the nmcli command to permanently establish multiple subflows between a source and destination system. The subflows can use different resources, different routes to the destination, and even different networks. Such as Ethernet, cellular, wifi, and so on. As a result, you achieve combined connections, which increase network resilience and throughput.

The server uses the following network interfaces in our example:

  • enp7s0: 192.0.2.3/24

The client uses the following network interfaces in our example:

  • enp6s0: 192.0.2.5/24
  • You configured the default gateway on the relevant interfaces.

Optional: The RHEL kernel default for subflow limit is 2. If you require more:

Create the /etc/systemd/system/set_mptcp_limit.service file with the following content:

The oneshot unit executes the ip mptcp limits set subflows 3 command after your network ( network.target ) is operational during every boot process.

The ip mptcp limits set subflows 3 command sets the maximum number of additional subflows for each connection, so 4 in total. It is possible to add maximally 3 additional subflows.

Enable the set_mptcp_limit service:

Enable MPTCP on all connection profiles that you want to use for connection aggregation:

The connection.mptcp-flags parameter configures MPTCP endpoints and the IP address flags. If MPTCP is enabled in a NetworkManager connection profile, the setting will configure the IP addresses of the relevant network interface as MPTCP endpoints.

By default, NetworkManager does not add MPTCP flags to IP addresses if there is no default gateway. If you want to bypass that check, you need to use also the also-without-default-route flag.

Verify that you enabled the MPTCP kernel parameter:

Verify that you set the subflow limit correctly, in case the default was not enough:

Verify that you configured the per-address MPTCP setting correctly:

  • nm-settings-nmcli(5)
  • ip-mptcp(8)
  • Section 29.1, “Understanding MPTCP”
  • Using Multipath TCP to better survive outages and increase bandwidth

29.5. 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.

  • 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 8.6 or later

Set the per connection additional subflow limits to 1 on both client and server:

On the server, to simulate a MPTCP server application, start netcat ( nc ) in listen mode with enforced MPTCP sockets instead of TCP sockets:

The -k option causes that nc 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:

The enp1s0 interface has a lower metric than wlp1s0 . Therefore, RHEL uses enp1s0 by default.

On the first terminal, start the monitoring:

On the second terminal, start a MPTCP connection to the server:

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:

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:

Optional: Display the connections to port 12345 on the server:

At this point, only one connection to the server has been established.

On a third terminal, create another endpoint:

This command sets the name and IP address of the WiFi interface of the client in this command.

The locid field displays the local address ID of the new sub-flow and identifies this sub-flow even if the connection uses network address translation (NAT). The saddr4 field matches the endpoint’s IP address from the ip mptcp endpoint add command.

The command now displays two connections:

  • The connection with source address 192.0.2.2 corresponds to the first MPTCP sub-flow that you established previously.
  • The connection from the sub-flow over the wlp1s0 interface with source address 192.0.2.3 .

On the third terminal, delete the endpoint:

Use the ID from the locid field from the ip mptcp monitor output, or retrieve the endpoint ID using the ip mptcp endpoint show command.

On the first terminal with the nc client, press Ctrl + C to terminate the session.

  • ip-mptcp(1) man page
  • How NetworkManager manages multiple default gateways

29.6. Disabling Multipath TCP in the kernel

You can explicitly disable the MPTCP option in the kernel.

Disable the mptcp.enabled option.

Verify whether the mptcp.enabled is disabled in the kernel.

Chapter 30. Configuring the order of DNS servers

Most applications use the getaddrinfo() function of the glibc library to resolve DNS requests. By default, glibc sends all DNS requests to the first DNS server specified in the /etc/resolv.conf file. If this server does not reply, RHEL uses the next server in this file. NetworkManager enables you to influence the order of DNS servers in etc/resolv.conf .

30.1. How NetworkManager orders DNS servers in /etc/resolv.conf

NetworkManager orders DNS servers in the /etc/resolv.conf file based on the following rules:

  • If only one connection profile exists, NetworkManager uses the order of IPv4 and IPv6 DNS server specified in that connection.

If multiple connection profiles are activated, NetworkManager orders DNS servers based on a DNS priority value. If you set DNS priorities, the behavior of NetworkManager depends on the value set in the dns parameter. You can set this parameter in the [main] section in the /etc/NetworkManager/NetworkManager.conf file:

dns=default or if the dns parameter is not set:

NetworkManager orders the DNS servers from different connections based on the ipv4.dns-priority and ipv6.dns-priority parameter in each connection.

If you set no value or you set ipv4.dns-priority and ipv6.dns-priority to 0 , NetworkManager uses the global default value. See Default values of DNS priority parameters .

dns=dnsmasq or dns=systemd-resolved :

When you use one of these settings, NetworkManager sets either 127.0.0.1 for dnsmasq or 127.0.0.53 as nameserver entry in the /etc/resolv.conf file.

Both the dnsmasq and systemd-resolved services forward queries for the search domain set in a NetworkManager connection to the DNS server specified in that connection, and forwardes queries to other domains to the connection with the default route. When multiple connections have the same search domain set, dnsmasq and systemd-resolved forward queries for this domain to the DNS server set in the connection with the lowest priority value.

Default values of DNS priority parameters

NetworkManager uses the following default values for connections:

  • 50 for VPN connections
  • 100 for other connections

Valid DNS priority values:

You can set both the global default and connection-specific ipv4.dns-priority and ipv6.dns-priority parameters to a value between -2147483647 and 2147483647 .

  • A lower value has a higher priority.
  • Negative values have the special effect of excluding other configurations with a greater value. For example, if at least one connection with a negative priority value exists, NetworkManager uses only the DNS servers specified in the connection profile with the lowest priority.

If multiple connections have the same DNS priority, NetworkManager prioritizes the DNS in the following order:

  • VPN connections
  • Connection with an active default route. The active default route is the default route with the lowest metric.
  • Using different DNS servers for different domains

30.2. Setting a NetworkManager-wide default DNS server priority value

NetworkManager uses the following DNS priority default values for connections:

You can override these system-wide defaults with a custom default value for IPv4 and IPv6 connections.

Edit the /etc/NetworkManager/NetworkManager.conf file:

Add the [connection] section, if it does not exist:

Add the custom default values to the [connection] section. For example, to set the new default for both IPv4 and IPv6 to 200 , add:

You can set the parameters to a value between -2147483647 and 2147483647 . Note that setting the parameters to 0 enables the built-in defaults ( 50 for VPN connections and 100 for other connections).

30.3. Setting the DNS priority of a NetworkManager connection

If you require a specific order of DNS servers you can set priority values in connection profiles. NetworkManager uses these values to order the servers when the service creates or updates the /etc/resolv.conf file.

Note that setting DNS priorities makes only sense if you have multiple connections with different DNS servers configured. If you have only one connection with multiple DNS servers configured, manually set the DNS servers in the preferred order in the connection profile.

  • The system has multiple NetworkManager connections configured.
  • The system either has no dns parameter set in the /etc/NetworkManager/NetworkManager.conf file or the parameter is set to default .

Optionally, display the available connections:

Set the ipv4.dns-priority and ipv6.dns-priority parameters. For example, to set both parameters to 10 for the Example_con_1 connection:

  • Optionally, repeat the previous step for other connections.

Re-activate the connection you updated:

Display the contents of the /etc/resolv.conf file to verify that the DNS server order is correct:

Chapter 31. Configuring ip networking with ifcfg files

Interface configuration ( ifcfg ) files control the software interfaces for individual network devices. As the system boots, it uses these files to determine what interfaces to bring up and how to configure them. These files are named ifcfg- name_pass , where the suffix name refers to the name of the device that the configuration file controls. By convention, the ifcfg file’s suffix is the same as the string given by the DEVICE directive in the configuration file itself.

NetworkManager supports profiles stored in the keyfile format. However, by default, NetworkManager uses the ifcfg format when you use the NetworkManager API to create or update profiles.

In a future major RHEL release, the keyfile format will be default. Consider using the keyfile format if you want to manually create and manage configuration files. For details, see NetworkManager connection profiles in keyfile format .

31.1. Configuring an interface with static network settings using ifcfg files

If you do not use the NetworkManager utilities and applications, you can manually configure a network interface by creating ifcfg files.

To configure an interface with static network settings using ifcfg files, for an interface with the name enp1s0 , create a file with the name ifcfg-enp1s0 in the /etc/sysconfig/network-scripts/ directory that contains:

For IPv4 configuration:

For IPv6 configuration:

  • nm-settings-ifcfg-rh(5) man page

31.2. Configuring an interface with dynamic network settings using ifcfg files

To configure an interface named em1 with dynamic network settings using ifcfg files, create a file with the name ifcfg-em1 in the /etc/sysconfig/network-scripts/ directory that contains:

To configure an interface to send:

A different host name to the DHCP server, add the following line to the ifcfg file:

A different fully qualified domain name (FQDN) to the DHCP server, add the following line to the ifcfg file:

You can use only one of these settings. If you specify both DHCP_HOSTNAME and DHCP_FQDN , only DHCP_FQDN is used.

To configure an interface to use particular DNS servers, add the following lines to the ifcfg file:

where ip-address is the address of a DNS server. This will cause the network service to update /etc/resolv.conf with the specified DNS servers specified. Only one DNS server address is necessary, the other is optional.

31.3. Managing system-wide and private connection profiles with ifcfg files

By default, all users on a host can use the connections defined in ifcfg files. You can limit this behavior to specific users by adding the USERS parameter to the ifcfg file.

Prerequisite

  • The ifcfg file already exists.

Edit the ifcfg file in the /etc/sysconfig/network-scripts/ directory that you want to limit to certain users, and add:

Reactive the connection:

Chapter 32. Using NetworkManager to disable IPv6 for a specific connection

On a system that uses NetworkManager to manage network interfaces, you can disable the IPv6 protocol if the network only uses IPv4. If you disable IPv6 , NetworkManager automatically sets the corresponding sysctl values in the Kernel.

If disabling IPv6 using kernel tunables or kernel boot parameters, additional consideration must be given to system configuration. For more information, see the How do I disable or enable the IPv6 protocol in RHEL? article.

32.1. Disabling IPv6 on a connection using nmcli

You can use the nmcli utility to disable the IPv6 protocol on the command line.

  • The system uses NetworkManager to manage network interfaces.

Optionally, display the list of network connections:

Set the ipv6.method parameter of the connection to disabled :

Display the IP settings of the device:

If no inet6 entry is displayed, IPv6 is disabled on the device.

Verify that the /proc/sys/net/ipv6/conf/ enp1s0 /disable_ipv6 file now contains the value 1 :

The value 1 means that IPv6 is disabled for the device.

Chapter 33. Manually configuring the /etc/resolv.conf file

By default, NetworkManager on Red Hat Enterprise Linux (RHEL) 8 dynamically updates the /etc/resolv.conf file with the DNS settings from active NetworkManager connection profiles. However, you can disable this behavior and manually configure DNS settings in /etc/resolv.conf .

Alternatively, if you require a specific order of DNS servers in /etc/resolv.conf , see Configuring the order of DNS servers .

33.1. Disabling DNS processing in the NetworkManager configuration

By default, NetworkManager manages DNS settings in the /etc/resolv.conf file, and you can configure the order of DNS servers. Alternatively, you can disable DNS processing in NetworkManager if you prefer to manually configure DNS settings in /etc/resolv.conf .

As the root user, create the /etc/NetworkManager/conf.d/90-dns-none.conf file with the following content by using a text editor:

After you reload the service, NetworkManager no longer updates the /etc/resolv.conf file. However, the last contents of the file are preserved.

  • Optionally, remove the Generated by NetworkManager comment from /etc/resolv.conf to avoid confusion.
  • Edit the /etc/resolv.conf file and manually update the configuration.

Display the /etc/resolv.conf file:

If you successfully disabled DNS processing, NetworkManager did not override the manually configured settings.

  • Configuring the order of DNS servers using NetworkManager

33.2. Replacing /etc/resolv.conf with a symbolic link to manually configure DNS settings

By default, NetworkManager manages DNS settings in the /etc/resolv.conf file, and you can configure the order of DNS servers. Alternatively, you can disable DNS processing in NetworkManager if you prefer to manually configure DNS settings in /etc/resolv.conf . For example, NetworkManager does not automatically update the DNS configuration if /etc/resolv.conf is a symbolic link.

  • The NetworkManager rc-manager configuration option is not set to file . To verify, use the NetworkManager --print-config command.
  • Create a file, such as /etc/resolv.conf.manually-configured , and add the DNS configuration for your environment to it. Use the same parameters and syntax as in the original /etc/resolv.conf .

Remove the /etc/resolv.conf file:

Create a symbolic link named /etc/resolv.conf that refers to /etc/resolv.conf.manually-configured :

  • resolv.conf(5) man page

Chapter 34. Configuring 802.3 link settings

Auto-negotiation is a feature of the IEEE 802.3u Fast Ethernet protocol. It targets the device ports to provide an optimal performance of speed, duplex mode, and flow control for information exchange over a link. Using the auto-negotiation protocol, you have optimal performance of data transfer over the Ethernet.

To utilize maximum performance of auto-negotiation, use the same configuration on both sides of a link.

34.1. Configuring 802.3 link settings using the nmcli utility

To configure the 802.3 link settings of an Ethernet connection, modify the following configuration parameters:

  • 802-3-ethernet.auto-negotiate
  • 802-3-ethernet.speed
  • 802-3-ethernet.duplex

Display the current settings of the connection:

You can use these values if you need to reset the parameters in case of any problems.

Set the speed and duplex link settings:

This command enables auto-negotiation and sets the speed of the connection to 10000 Mbit full duplex.

Reactivate the connection:

Use the ethtool utility to verify the values of Ethernet interface enp1s0 :

Chapter 35. Configuring ethtool settings in NetworkManager connection profiles

NetworkManager can configure certain network driver and hardware settings persistently. Compared to using the ethtool utility to manage these settings, this has the benefit of not losing the settings after a reboot.

You can set the following ethtool settings in NetworkManager connection profiles:

35.1. Configuring an ethtool offload feature by using nmcli

You can use NetworkManager to enable and disable ethtool offload features in a connection profile.

For example, to enable the RX offload feature and disable TX offload in the enp1s0 connection profile, enter:

This command explicitly enables RX offload and disables TX offload.

To remove the setting of an offload feature that you previously enabled or disabled, set the feature’s parameter to a null value. For example, to remove the configuration for TX offload, enter:

Reactivate the network profile:

Use the ethtool -k command to display the current offload features of a network device:

35.2. Configuring an ethtool offload feature by using the network RHEL System Role

You can use the network RHEL System Role to configure ethtool features of a NetworkManager connection.

Create a playbook file, for example ~/configure-ethernet-device-with-ethtool-features.yml , with the following content:

This playbook creates the enp1s0 connection profile with the following settings, or updates it if the profile already exists:

ethtool features:

  • Generic receive offload (GRO): disabled
  • Generic segmentation offload (GSO): enabled
  • TX stream control transmission protocol (SCTP) segmentation: disabled

35.3. Configuring an ethtool coalesce settings by using nmcli

You can use NetworkManager to set ethtool coalesce settings in connection profiles.

For example, to set the maximum number of received packets to delay to 128 in the enp1s0 connection profile, enter:

To remove a coalesce setting, set it to a null value. For example, to remove the ethtool.coalesce-rx-frames setting, enter:

To reactivate the network profile:

Use the ethtool -c command to display the current offload features of a network device:

35.4. Configuring an ethtool coalesce settings by using the network RHEL System Role

You can use the network RHEL System Role to configure ethtool coalesce settings of a NetworkManager connection.

Create a playbook file, for example ~/configure-ethernet-device-with-ethtoolcoalesce-settings.yml , with the following content:

ethtool coalesce settings:

  • RX frames: 128
  • TX frames: 128

35.5. Increasing the ring buffer size to reduce a high packet drop rate by using nmcli

Increase the size of an Ethernet device’s ring buffers if the packet drop rate causes applications to report a loss of data, timeouts, or other issues.

Receive ring buffers are shared between the device driver and network interface controller (NIC). The card assigns a transmit (TX) and receive (RX) ring buffer. As the name implies, the ring buffer is a circular buffer where an overflow overwrites existing data. There are two ways to move data from the NIC to the kernel, hardware interrupts and software interrupts, also called SoftIRQs.

The kernel uses the RX ring buffer to store incoming packets until the device driver can process them. The device driver drains the RX ring, typically by using SoftIRQs, which puts the incoming packets into a kernel data structure called an sk_buff or skb to begin its journey through the kernel and up to the application that owns the relevant socket.

The kernel uses the TX ring buffer to hold outgoing packets which should be sent to the network. These ring buffers reside at the bottom of the stack and are a crucial point at which packet drop can occur, which in turn will adversely affect network performance.

Display the packet drop statistics of the interface:

Note that the output of the command depends on the network card and the driver.

High values in discard or drop counters indicate that the available buffer fills up faster than the kernel can process the packets. Increasing the ring buffers can help to avoid such loss.

Display the maximum ring buffer sizes:

If the values in the Pre-set maximums section are higher than in the Current hardware settings section, you can change the settings in the next steps.

Identify the NetworkManager connection profile that uses the interface:

Update the connection profile, and increase the ring buffers:

To increase the RX ring buffer, enter:

To increase the TX ring buffer, enter:

Reload the NetworkManager connection:

Depending on the driver your NIC uses, changing in the ring buffer can shortly interrupt the network connection.

  • ifconfig and ip commands report packet drops
  • Should I be concerned about a 0.05% packet drop rate?
  • ethtool(8) man page

35.6. Increasing the ring buffer size to reduce a high packet drop rate by using the network RHEL System Role

Ring buffers are circular buffers where an overflow overwrites existing data. The network card assigns a transmit (TX) and receive (RX) ring buffer. Receive ring buffers are shared between the device driver and the network interface controller (NIC). Data can move from NIC to the kernel through either hardware interrupts or software interrupts, also called SoftIRQs.

  • You know the maximum ring buffer sizes that the device supports.

Create a playbook file, for example ~/configure-ethernet-device-with-ring-buffer-sizes.yml , with the following content:

Maximum number of ring buffer entries:

  • Receive (RX): 4096
  • Transmit (TX): 4096

Chapter 36. Using MACsec to encrypt layer-2 traffic in the same physical network

You can use MACsec to secure the communication between two devices (point-to-point). For example, your branch office is connected over a Metro-Ethernet connection with the central office, you can configure MACsec on the two hosts that connect the offices to increase the security.

Media Access Control security (MACsec) is a layer 2 protocol that secures different traffic types over the Ethernet links including:

  • dynamic host configuration protocol (DHCP)
  • address resolution protocol (ARP)
  • Internet Protocol version 4 / 6 ( IPv4 / IPv6 ) and
  • any traffic over IP such as TCP or UDP

MACsec encrypts and authenticates all traffic in LANs, by default with the GCM-AES-128 algorithm, and uses a pre-shared key to establish the connection between the participant hosts. If you want to change the pre-shared key, you need to update the NM configuration on all hosts in the network that uses MACsec.

A MACsec connection uses an Ethernet device, such as an Ethernet network card, VLAN, or tunnel device, as parent. You can either set an IP configuration only on the MACsec device to communicate with other hosts only using the encrypted connection, or you can also set an IP configuration on the parent device. In the latter case, you can use the parent device to communicate with other hosts using an unencrypted connection and the MACsec device for encrypted connections.

MACsec does not require any special hardware. For example, you can use any switch, except if you want to encrypt traffic only between a host and a switch. In this scenario, the switch must also support MACsec.

In other words, there are 2 common methods to configure MACsec;

  • host to host and
  • host to switch then switch to other host(s)

You can use MACsec only between hosts that are in the same (physical or virtual) LAN.

36.1. Configuring a MACsec connection using nmcli

You can configure Ethernet interfaces to use MACsec using the nmcli utility. For example, you can create a MACsec connection between two hosts that are connected over Ethernet.

On the first host on which you configure MACsec:

Create the connectivity association key (CAK) and connectivity-association key name (CKN) for the pre-shared key:

Create a 16-byte hexadecimal CAK:

Create a 32-byte hexadecimal CKN:

  • On both hosts you want to connect over a MACsec connection:

Create the MACsec connection:

Use the CAK and CKN generated in the previous step in the macsec.mka-cak and macsec.mka-ckn parameters. The values must be the same on every host in the MACsec-protected network.

Configure the IP settings on the MACsec connection.

Configure the IPv4 settings. For example, to set a static IPv4 address, network mask, default gateway, and DNS server to the macsec0 connection, enter:

Configure the IPv6 settings. For example, to set a static IPv6 address, network mask, default gateway, and DNS server to the macsec0 connection, enter:

Verify that the traffic is encrypted:

Optional: Display the unencrypted traffic:

Display MACsec statistics:

Display individual counters for each type of protection: integrity-only (encrypt off) and encryption (encrypt on)

36.2. Additional resources

  • MACsec: a different solution to encrypt network traffic blog.

Chapter 37. Using different DNS servers for different domains

By default, Red Hat Enterprise Linux (RHEL) sends all DNS requests to the first DNS server specified in the /etc/resolv.conf file. If this server does not reply, RHEL uses the next server in this file. In environments where one DNS server cannot resolve all domains, administrators can configure RHEL to send DNS requests for a specific domain to a selected DNS server.

For example, you connect a server to a Virtual Private Network (VPN), and hosts in the VPN use the example.com domain. In this case, you can configure RHEL to process DNS queries in the following way:

  • Send only DNS requests for example.com to the DNS server in the VPN network.
  • Send all other requests to the DNS server that is configured in the connection profile with the default gateway.

37.1. Using dnsmasq in NetworkManager to send DNS requests for a specific domain to a selected DNS server

You can configure NetworkManager to start an instance of dnsmasq . This DNS caching server then listens on port 53 on the loopback device. Consequently, this service is only reachable from the local system and not from the network.

With this configuration, NetworkManager adds the nameserver 127.0.0.1 entry to the /etc/resolv.conf file, and dnsmasq dynamically routes DNS requests to the corresponding DNS servers specified in the NetworkManager connection profiles.

A DNS server and search domain are configured in the NetworkManager connection profile that is responsible for resolving a specific domain.

For example, to ensure that the DNS server specified in a VPN connection resolves queries for the example.com domain, the VPN connection profile must contain the following settings:

  • A DNS server that can resolve example.com
  • A search domain set to example.com in the ipv4.dns-search and ipv6.dns-search parameters
  • The dnsmasq service is not running or configured to listen on a different interface then localhost .

Install the dnsmasq package:

Edit the /etc/NetworkManager/NetworkManager.conf file, and set the following entry in the [main] section:

Search in the systemd journal of the NetworkManager unit for which domains the service uses a different DNS server:

Use the tcpdump packet sniffer to verify the correct route of DNS requests:

Install the tcpdump package:

On one terminal, start tcpdump to capture DNS traffic on all interfaces:

On a different terminal, resolve host names for a domain for which an exception exists and another domain, for example:

Verify in the tcpdump output that Red Hat Enterprise Linux sends only DNS queries for the example.com domain to the designated DNS server and through the corresponding interface:

Red Hat Enterprise Linux sends the DNS query for www.example.com to the DNS server on 198.51.100.7 and the query for www.redhat.com to 192.0.2.1 .

Verify that the nameserver entry in the /etc/resolv.conf file refers to 127.0.0.1 :

If the entry is missing, check the dns parameter in the /etc/NetworkManager/NetworkManager.conf file.

Verify that the dnsmasq service listens on port 53 on the loopback device:

If the service does not listen on 127.0.0.1:53 , check the journal entries of the NetworkManager unit:

37.2. Using systemd-resolved in NetworkManager to send DNS requests for a specific domain to a selected DNS server

You can configure NetworkManager to start an instance of systemd-resolved . This DNS stub resolver then listens on port 53 on IP address 127.0.0.53 . Consequently, this stub resolver is only reachable from the local system and not from the network.

With this configuration, NetworkManager adds the nameserver 127.0.0.53 entry to the /etc/resolv.conf file, and systemd-resolved dynamically routes DNS requests to the corresponding DNS servers specified in the NetworkManager connection profiles.

The systemd-resolved service 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.

For a supported solution, see Using dnsmasq in NetworkManager to send DNS requests for a specific domain to a selected DNS server .

Enable and start the systemd-resolved service:

Display the DNS servers systemd-resolved uses and for which domains the service uses a different DNS server:

The output confirms that systemd-resolved uses different DNS servers for the example.com domain.

Verify that the nameserver entry in the /etc/resolv.conf file refers to 127.0.0.53 :

Verify that the systemd-resolved service listens on port 53 on the local IP address 127.0.0.53 :

If the service does not listen on 127.0.0.53:53 , check if the systemd-resolved service is running.

Chapter 38. Getting started with IPVLAN

IPVLAN is a driver for a virtual network device that can be used in container environment to access the host network. IPVLAN exposes a single MAC address to the external network regardless the number of IPVLAN device created inside the host network. This means that a user can have multiple IPVLAN devices in multiple containers and the corresponding switch reads a single MAC address. IPVLAN driver is useful when the local switch imposes constraints on the total number of MAC addresses that it can manage.

38.1. IPVLAN modes

The following modes are available for IPVLAN:

In IPVLAN L2 mode , virtual devices receive and respond to address resolution protocol (ARP) requests. The netfilter framework runs only inside the container that owns the virtual device. No netfilter chains are executed in the default namespace on the containerized traffic. Using L2 mode provides good performance, but less control on the network traffic.

In L3 mode , virtual devices process only L3 traffic and above. Virtual devices do not respond to ARP request and users must configure the neighbour entries for the IPVLAN IP addresses on the relevant peers manually. The egress traffic of a relevant container is landed on the netfilter POSTROUTING and OUTPUT chains in the default namespace while the ingress traffic is threaded in the same way as L2 mode . Using L3 mode provides good control but decreases the network traffic performance.

In L3S mode , virtual devices process the same way as in L3 mode , except that both egress and ingress traffics of a relevant container are landed on netfilter chain in the default namespace. L3S mode behaves in a similar way to L3 mode but provides greater control of the network.

The IPVLAN virtual device does not receive broadcast and multicast traffic in case of L3 and L3S modes.

38.2. Comparison of IPVLAN and MACVLAN

The following table shows the major differences between MACVLAN and IPVLAN:

Both IPVLAN and MACVLAN do not require any level of encapsulation.

38.3. Creating and configuring the IPVLAN device using iproute2

This procedure shows how to set up the IPVLAN device using iproute2 .

To create an IPVLAN device, enter the following command:

Note that network interface controller (NIC) is a hardware component which connects a computer to a network.

Example 38.1. Creating an IPVLAN device

To assign an IPv4 or IPv6 address to the interface, enter the following command:

In case of configuring an IPVLAN device in L3 mode or L3S mode , make the following setups:

Configure the neighbor setup for the remote peer on the remote host:

where MAC_address is the MAC address of the real NIC on which an IPVLAN device is based on.

Configure an IPVLAN device for L3 mode with the following command:

For L3S mode :

where IP-address represents the address of the remote peer.

To set an IPVLAN device active, enter the following command:

To check if the IPVLAN device is active, execute the following command on the remote host:

where the IP_address uses the IP address of the IPVLAN device.

Chapter 39. Reusing the same IP address on different interfaces

With Virtual routing and forwarding (VRF), administrators can use multiple routing tables simultaneously on the same host. For that, VRF partitions a network at layer 3. This enables the administrator to isolate traffic using separate and independent route tables per VRF domain. This technique is similar to virtual LANs (VLAN), which partitions a network at layer 2, where the operating system uses different VLAN tags to isolate traffic sharing the same physical medium.

One benefit of VRF over partitioning on layer 2 is that routing scales better considering the number of peers involved.

Red Hat Enterprise Linux uses a virtual vrt device for each VRF domain and adds routes to a VRF domain by adding existing network devices to a VRF device. Addresses and routes previously attached to the original device will be moved inside the VRF domain.

Note that each VRF domain is isolated from each other.

39.1. Permanently reusing the same IP address on different interfaces

You can use the virtual routing and forwarding (VRF) feature to permanently use the same IP address on different interfaces in one server.

To enable remote peers to contact both VRF interfaces while reusing the same IP address, the network interfaces must belong to different broadcasting domains. A broadcast domain in a network is a set of nodes, which receive broadcast traffic sent by any of them. In most configurations, all nodes connected to the same switch belong to the same broadcasting domain.

  • You are logged in as the root user.
  • The network interfaces are not configured.

Create and configure the first VRF device:

Create a connection for the VRF device and assign it to a routing table. For example, to create a VRF device named vrf0 that is assigned to the 1001 routing table:

Enable the vrf0 device:

Assign a network device to the VRF just created. For example, to add the enp1s0 Ethernet device to the vrf0 VRF device and assign an IP address and the subnet mask to enp1s0 , enter:

Activate the vrf.enp1s0 connection:

Create and configure the next VRF device:

Create the VRF device and assign it to a routing table. For example, to create a VRF device named vrf1 that is assigned to the 1002 routing table, enter:

Activate the vrf1 device:

Assign a network device to the VRF just created. For example, to add the enp7s0 Ethernet device to the vrf1 VRF device and assign an IP address and the subnet mask to enp7s0 , enter:

Activate the vrf.enp7s0 device:

39.2. Temporarily reusing the same IP address on different interfaces

You can use the virtual routing and forwarding (VRF) feature to temporarily use the same IP address on different interfaces in one server. Use this procedure only for testing purposes, because the configuration is temporary and lost after you reboot the system.

To enable remote peers to contact both VRF interfaces while reusing the same IP address, the network interfaces must belong to different broadcasting domains. A broadcast domain in a network is a set of nodes which receive broadcast traffic sent by any of them. In most configurations, all nodes connected to the same switch belong to the same broadcasting domain.

Create the VRF device and assign it to a routing table. For example, to create a VRF device named blue that is assigned to the 1001 routing table:

Enable the blue device:

Assign a network device to the VRF device. For example, to add the enp1s0 Ethernet device to the blue VRF device:

Enable the enp1s0 device:

Assign an IP address and subnet mask to the enp1s0 device. For example, to set it to 192.0.2.1/24 :

Create the VRF device and assign it to a routing table. For example, to create a VRF device named red that is assigned to the 1002 routing table:

Enable the red device:

Assign a network device to the VRF device. For example, to add the enp7s0 Ethernet device to the red VRF device:

Enable the enp7s0 device:

Assign the same IP address and subnet mask to the enp7s0 device as you used for enp1s0 in the blue VRF domain:

  • Optionally, create further VRF devices as described above.

39.3. Additional resources

  • /usr/share/doc/kernel-doc-< kernel_version >/Documentation/networking/vrf.txt from the kernel-doc package

Chapter 40. Starting a service within an isolated VRF network

With virtual routing and forwarding (VRF), you can create isolated networks with a routing table that is different to the main routing table of the operating system. You can then start services and applications so that they have only access to the network defined in that routing table.

40.1. Configuring a VRF device

To use virtual routing and forwarding (VRF), you create a VRF device and attach a physical or virtual network interface and routing information to it.

To prevent that you lock out yourself out remotely, perform this procedure on the local console or remotely over a network interface that you do not want to assign to the VRF device.

  • You are logged in locally or using a network interface that is different to the one you want to assign to the VRF device.

Create the vrf0 connection with a same-named virtual device, and attach it to routing table 1000 :

Add the enp1s0 device to the vrf0 connection, and configure the IP settings:

This command creates the enp1s0 connection as a port of the vrf0 connection. Due to this configuration, the routing information are automatically assigned to the routing table 1000 that is associated with the vrf0 device.

If you require static routes in the isolated network:

Add the static routes:

This adds a route to the 198.51.100.0/24 network that uses 192.0.2.2 as the router.

Display the IP settings of the device that is associated with vrf0 :

Display the VRF devices and their associated routing table:

Display the main routing table:

The main routing table does not mention any routes associated with the device enp1s0 device or the 192.0.2.1/24 subnet.

Display the routing table 1000 :

The default entry indicates that services that use this routing table, use 192.0.2.254 as their default gateway and not the default gateway in the main routing table.

Execute the traceroute utility in the network associated with vrf0 to verify that the utility uses the route from table 1000 :

The first hop is the default gateway that is assigned to the routing table 1000 and not the default gateway from the system’s main routing table.

  • ip-vrf(8) man page

40.2. Starting a service within an isolated VRF network

You can configure a service, such as the Apache HTTP Server, to start within an isolated virtual routing and forwarding (VRF) network.

Services can only bind to local IP addresses that are in the same VRF network.

  • You configured the vrf0 device.
  • You configured Apache HTTP Server to listen only on the IP address that is assigned to the interface associated with the vrf0 device.

Display the content of the httpd systemd service:

You require the content of the ExecStart parameter in a later step to run the same command within the isolated VRF network.

Create the /etc/systemd/system/httpd.service.d/ directory:

Create the /etc/systemd/system/httpd.service.d/override.conf file with the following content:

To override the ExecStart parameter, you first need to unset it and then set it to the new value as shown.

Reload systemd.

Restart the httpd service.

Display the process IDs (PID) of httpd processes:

Display the VRF association for the PIDs, for example:

Display all PIDs associated with the vrf0 device:

Chapter 41. Running dhclient exit hooks using NetworkManager a dispatcher script

You can use a NetworkManager dispatcher script to execute dhclient exit hooks.

41.1. The concept of NetworkManager dispatcher scripts

The NetworkManager-dispatcher service executes user-provided scripts in alphabetical order when network events happen. These scripts are typically shell scripts, but can be any executable script or application. You can use dispatcher scripts, for example, to adjust network-related settings that you cannot manage with NetworkManager.

You can store dispatcher scripts in the following directories:

  • /etc/NetworkManager/dispatcher.d/ : The general location for dispatcher scripts the root user can edit.
  • /usr/lib/NetworkManager/dispatcher.d/ : For pre-deployed immutable dispatcher scripts.

For security reasons, the NetworkManager-dispatcher service executes scripts only if the following conditions met:

  • The script is owned by the root user.
  • The script is only readable and writable by root .
  • The setuid bit is not set on the script.

The NetworkManager-dispatcher service runs each script with two arguments:

  • The interface name of the device the operation happened on.
  • The action, such as up , when the interface has been activated.

The Dispatcher scripts section in the NetworkManager(8) man page provides an overview of actions and environment variables you can use in scripts.

The NetworkManager-dispatcher service runs one script at a time, but asynchronously from the main NetworkManager process. Note that, if a script is queued, the service will always run it, even if a later event makes it obsolete. However, the NetworkManager-dispatcher service runs scripts that are symbolic links referring to files in /etc/NetworkManager/dispatcher.d/no-wait.d/ immediately, without waiting for the termination of previous scripts, and in parallel.

  • NetworkManager(8) man page

41.2. Creating a NetworkManager dispatcher script that runs dhclient exit hooks

When a DHCP server assigns or updates an IPv4 address, NetworkManager can run a dispatcher script stored in the /etc/dhcp/dhclient-exit-hooks.d/ directory. This dispatcher script can then, for example, run dhclient exit hooks.

  • The dhclient exit hooks are stored in the /etc/dhcp/dhclient-exit-hooks.d/ directory.

Create the /etc/NetworkManager/dispatcher.d/12-dhclient-down file with the following content:

Set the root user as owner of the file:

Set the permissions so that only the root user can execute it:

Restore the SELinux context:

Chapter 42. Introduction to NetworkManager Debugging

Increasing the log levels for all or certain domains helps to log more details of the operations that NetworkManager performs. You can use this information to troubleshoot problems. NetworkManager provides different levels and domains to produce logging information. The /etc/NetworkManager/NetworkManager.conf file is the main configuration file for NetworkManager. The logs are stored in the journal.

42.1. Introduction to NetworkManager reapply method

The NetworkManager service uses a profile to manage the connection settings of a device. Desktop Bus (D-Bus) API can create, modify, and delete these connection settings. For any changes in a profile, D-Bus API clones the existing settings to the modified settings of a connection. Despite cloning, changes do not apply to the modified settings. To make it effective, reactivate the existing settings of a connection or use the reapply() method.

The reapply() method has the following features:

  • Updating modified connection settings without deactivation or restart of a network interface.
  • Removing pending changes from the modified connection settings. As NetworkManager does not revert the manual changes, you can reconfigure the device and revert external or manual parameters.
  • Creating different modified connection settings than that of the existing connection settings.

Also, reapply() method supports the following attributes:

  • bridge.ageing-time
  • bridge.forward-delay
  • bridge.group-address
  • bridge.group-forward-mask
  • bridge.hello-time
  • bridge.max-age
  • bridge.multicast-hash-max
  • bridge.multicast-last-member-count
  • bridge.multicast-last-member-interval
  • bridge.multicast-membership-interval
  • bridge.multicast-querier
  • bridge.multicast-querier-interval
  • bridge.multicast-query-interval
  • bridge.multicast-query-response-interval
  • bridge.multicast-query-use-ifaddr
  • bridge.multicast-router
  • bridge.multicast-snooping
  • bridge.multicast-startup-query-count
  • bridge.multicast-startup-query-interval
  • bridge.priority
  • bridge.VLAN-filtering
  • bridge.VLAN-protocol
  • bridge.VLANs
  • 802-3-ethernet.accept-all-mac-addresses
  • 802-3-ethernet.cloned-mac-address
  • IPv4.addresses
  • IPv4.dhcp-client-id
  • IPv4.dhcp-iaid
  • IPv4.dhcp-timeout
  • IPv4.DNS-priority
  • IPv4.DNS-search
  • IPv4.gateway
  • IPv4.ignore-auto-DNS
  • IPv4.ignore-auto-routes
  • IPv4.may-fail
  • IPv4.method
  • IPv4.never-default
  • IPv4.route-table
  • IPv4.routes
  • IPv4.routing-rules
  • IPv6.addr-gen-mode
  • IPv6.addresses
  • IPv6.dhcp-duid
  • IPv6.dhcp-iaid
  • IPv6.dhcp-timeout
  • IPv6.DNS-priority
  • IPv6.DNS-search
  • IPv6.gateway
  • IPv6.ignore-auto-DNS
  • IPv6.may-fail
  • IPv6.method
  • IPv6.never-default
  • IPv6.ra-timeout
  • IPv6.route-metric
  • IPv6.route-table
  • IPv6.routes
  • IPv6.routing-rules

42.2. Setting the NetworkManager log level

By default, all the log domains are set to record the INFO log level. Disable rate-limiting before collecting debug logs. With rate-limiting, systemd-journald drops messages if there are too many of them in a short time. This can occur when the log level is TRACE .

This procedure disables rate-limiting and enables recording debug logs for the all (ALL) domains.

To disable rate-limiting, edit the /etc/systemd/journald.conf file, uncomment the RateLimitBurst parameter in the [Journal] section, and set its value as 0 :

Restart the systemd-journald service.

Create the /etc/NetworkManager/conf.d/95-nm-debug.conf file with the following content:

The domains parameter can contain multiple comma-separated domain:level pairs.

Restart the NetworkManager service.

Query the systemd journal to display the journal entries of the NetworkManager unit:

42.3. Temporarily setting log levels at run time using nmcli

You can change the log level at run time using nmcli . However, Red Hat recommends to enable debugging using configuration files and restart NetworkManager. Updating debugging levels and domains using the .conf file helps to debug boot issues and captures all the logs from the initial state.

Optional: Display the current logging settings:

To modify the logging level and domains, use the following options:

To set the log level for all domains to the same LEVEL , enter:

To change the level for specific domains, enter:

Note that updating the logging level using this command disables logging for all the other domains.

To change the level of specific domains and preserve the level of all other domains, enter:

42.4. Viewing NetworkManager logs

You can view the NetworkManager logs for troubleshooting.

To view the logs, enter:

  • journalctl(1) man page

42.5. Debugging levels and domains

You can use the levels and domains parameters to manage the debugging for NetworkManager. The level defines the verbosity level, whereas the domains define the category of the messages to record the logs with given severity ( level ).

Note that subsequent levels log all messages from earlier levels. For example, setting the log level to INFO also logs messages contained in the ERR and WARN log level.

Chapter 43. Introduction to Nmstate

Nmstate is a declarative network manager API. The nmstate package provides the libnmstate Python library and a command-line utility, nmstatectl , to manage NetworkManager on RHEL. When you use Nmstate, you describe the expected networking state using YAML or JSON-formatted instructions.

Nmstate has many benefits. For example, it:

  • Provides a stable and extensible interface to manage RHEL network capabilities
  • Supports atomic and transactional operations at the host and cluster level
  • Supports partial editing of most properties and preserves existing settings that are not specified in the instructions
  • Provides plug-in support to enable administrators to use their own plug-ins

43.1. Using the libnmstate library in a Python application

The libnmstate Python library enables developers to use Nmstate in their own application

To use the library, import it in your source code:

Note that you must install the nmstate package to use this library.

Example 43.1. Querying the network state using the libnmstate library

The following Python code imports the libnmstate library and displays the available network interfaces and their state:

43.2. Updating the current network configuration using nmstatectl

You can use the nmstatectl utility to store the current network configuration of one or all interfaces in a file. You can then use this file to:

  • Modify the configuration and apply it to the same system.
  • Copy the file to a different host and configure the host with the same or modified settings.

For example, you can export the settings of the enp1s0 interface to a file, modify the configuration, and apply the settings to the host.

Export the settings of the enp1s0 interface to the ~/network-config.yml file:

This command stores the configuration of enp1s0 in YAML format. To store the output in JSON format, pass the --json option to the command.

If you do not specify an interface name, nmstatectl exports the configuration of all interfaces.

  • Modify the ~/network-config.yml file using a text editor to update the configuration.

Apply the settings from the ~/network-config.yml file:

If you exported the settings in JSON format, pass the --json option to the command.

43.3. Network states for the network RHEL System role

The network RHEL system role supports state configurations in playbooks to configure the devices. For this, use the network_state variable followed by the state configurations.

Benefits of using the network_state variable in a playbook:

  • Using the declarative method with the state configurations, you can configure interfaces, and the NetworkManager creates a profile for these interfaces in the background.
  • With the network_state variable, you can specify the options that you require to change, and all the other options will remain the same as they are. However, with the network_connections variable, you must specify all settings to change the network connection profile.

For example, to create an Ethernet connection with dynamic IP address settings, use the following vars block in your playbook:

For example, to only change the connection status of dynamic IP address settings that you created as above, use the following vars block in your playbook:

43.4. Additional resources

  • /usr/share/doc/nmstate/README.md
  • /usr/share/doc/nmstate/examples/

Chapter 44. Capturing network packets

To debug network issues and communications, you can capture network packets. The following sections provide instructions and additional information about capturing network packets.

44.1. Using xdpdump to capture network packets including packets dropped by XDP programs

The xdpdump utility captures network packets. Unlike the tcpdump utility, xdpdump uses an extended Berkeley Packet Filter(eBPF) program for this task. This enables xdpdump to also capture packets dropped by Express Data Path (XDP) programs. User-space utilities, such as tcpdump , are not able to capture these dropped packages, as well as original packets modified by an XDP program.

You can use xdpdump to debug XDP programs that are already attached to an interface. Therefore, the utility can capture packets before an XDP program is started and after it has finished. In the latter case, xdpdump also captures the XDP action. By default, xdpdump captures incoming packets at the entry of the XDP program.

On other architectures than AMD and Intel 64-bit, the xdpdump 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.

Note that xdpdump has no packet filter or decode capabilities. However, you can use it in combination with tcpdump for packet decoding.

  • A network driver that supports XDP programs.
  • An XDP program is loaded to the enp1s0 interface. If no program is loaded, xdpdump captures packets in a similar way tcpdump does, for backward compatibility.

To capture packets on the enp1s0 interface and write them to the /root/capture.pcap file, enter:

  • To stop capturing packets, press Ctrl + C .
  • xdpdump(8) man page
  • If you are a developer and you are interested in the source code of xdpdump , download and install the corresponding source RPM (SRPM) from the Red Hat Customer Portal.

44.2. Additional resources

  • How to capture network packets with tcpdump?

Chapter 45. Using and configuring firewalld

A firewall is a way to protect machines from any unwanted traffic from outside. It enables users to control incoming network traffic on host machines by defining a set of firewall rules . These rules are used to sort the incoming traffic and either block it or allow through.

firewalld is a firewall service daemon that provides a dynamic customizable host-based firewall with a D-Bus interface. Being dynamic, it enables creating, changing, and deleting the rules without the necessity to restart the firewall daemon each time the rules are changed.

firewalld uses the concepts of zones and services, that simplify the traffic management. Zones are predefined sets of rules. Network interfaces and sources can be assigned to a zone. The traffic allowed depends on the network your computer is connected to and the security level this network is assigned. Firewall services are predefined rules that cover all necessary settings to allow incoming traffic for a specific service and they apply within a zone.

Services use one or more ports or addresses for network communication. Firewalls filter communication based on ports. To allow network traffic for a service, its ports must be open. firewalld blocks all traffic on ports that are not explicitly set as open. Some zones, such as trusted, allow all traffic by default.

Note that firewalld with nftables backend does not support passing custom nftables rules to firewalld , using the --direct option.

45.1. When to use firewalld, nftables, or iptables

The following is a brief overview in which scenario you should use one of the following utilities:

  • firewalld : Use the firewalld utility for simple firewall use cases. The utility is easy to use and covers the typical use cases for these scenarios.
  • nftables : Use the nftables utility to set up complex and performance-critical firewalls, such as for a whole network.
  • iptables : The iptables utility on Red Hat Enterprise Linux uses the nf_tables kernel API instead of the legacy back end. The nf_tables API provides backward compatibility so that scripts that use iptables commands still work on Red Hat Enterprise Linux. For new firewall scripts, Red Hat recommends to use nftables .

To prevent the different firewall-related services ( firewalld , nftables , or iptables ) from influencing each other, run only one of them on a RHEL host, and disable the other services.

45.2. Firewall zones

You can use the ⁠ firewalld utility to separate networks into different zones according to the level of trust that you have with the interfaces and traffic within that network. A connection can only be part of one zone, but you can use that zone for many network connections.

firewalld follows strict principles in regards to zones:

  • Traffic ingresses only one zone.
  • Traffic egresses only one zone.
  • A zone defines a level of trust.
  • Intrazone traffic (within the same zone) is allowed by default.
  • Interzone traffic (from zone to zone) is denied by default.

Principles 4 and 5 are a consequence of principle 3.

Principle 4 is configurable through the zone option --remove-forward . Principle 5 is configurable by adding new policies.

NetworkManager notifies firewalld of the zone of an interface. You can assign zones to interfaces with the following utilities:

  • NetworkManager
  • firewall-config utility
  • firewall-cmd utility
  • The RHEL web console

The RHEL web console, firewall-config , and firewall-cmd can only edit the appropriate NetworkManager configuration files. If you change the zone of the interface using the web console, firewall-cmd , or firewall-config , the request is forwarded to NetworkManager and is not handled by ⁠ firewalld .

The /usr/lib/firewalld/zones/ directory stores the predefined zones, and you can instantly apply them to any available network interface. These files are copied to the /etc/firewalld/zones/ directory only after they are modified. The default settings of the predefined zones are as follows:

  • Suitable for: Any incoming network connections are rejected with an icmp-host-prohibited message for IPv4 and icmp6-adm-prohibited for IPv6 .
  • Accepts: Only network connections initiated from within the system.
  • Suitable for: Computers in your DMZ that are publicly-accessible with limited access to your internal network.
  • Accepts: Only selected incoming connections.

**Accepts: Only outgoing network connections.

  • Suitable for: External networks with masquerading enabled, especially for routers. Situations when you do not trust the other computers on the network.
  • Suitable for: Home environment where you mostly trust the other computers on the network.
  • Suitable for: Internal networks where you mostly trust the other computers on the network.
  • Suitable for: Public areas where you do not trust other computers on the network.
  • Accepts: All network connections.

Suitable for: Work environment where you mostly trust the other computers on the network.

One of these zones is set as the default zone. When interface connections are added to NetworkManager , they are assigned to the default zone. On installation, the default zone in firewalld is the public zone. You can change the default zone.

Make network zone names self-explanatory to help users understand them quickly.

To avoid any security problems, review the default zone configuration and disable any unnecessary services according to your needs and risk assessments.

  • The firewalld.zone(5) man page.

45.3. Firewall policies

The firewall policies specify the desired security state of your network. They outline rules and actions to take for different types of traffic. Typically, the policies contain rules for the following types of traffic:

  • Incoming traffic
  • Outgoing traffic
  • Forward traffic
  • Specific services and applications
  • Network address translations (NAT)

Firewall policies use the concept of firewall zones. Each zone is associated with a specific set of firewall rules that determine the traffic allowed. Policies apply firewall rules in a stateful, unidirectional manner. This means you only consider one direction of the traffic. The traffic return path is implicitly allowed due to stateful filtering of firewalld .

Policies are associated with an ingress zone and an egress zone. The ingress zone is where the traffic originated (received). The egress zone is where the traffic leaves (sent).

The firewall rules defined in a policy can reference the firewall zones to apply consistent configurations across multiple network interfaces.

45.4. Firewall rules

You can use the firewall rules to implement specific configurations for allowing or blocking network traffic. As a result, you can control the flow of network traffic to protect your system from security threats.

Firewall rules typically define certain criteria based on various attributes. The attributes can be as:

  • Source IP addresses
  • Destination IP addresses
  • Transfer Protocols (TCP, UDP, …​)
  • Network interfaces

The firewalld utility organizes the firewall rules into zones (such as public , internal , and others) and policies. Each zone has its own set of rules that determine the level of traffic freedom for network interfaces associated with a particular zone.

45.5. Zone configuration files

A firewalld zone configuration file contains the information for a zone. These are the zone description, services, ports, protocols, icmp-blocks, masquerade, forward-ports and rich language rules in an XML file format. The file name has to be zone-name .xml where the length of zone-name is currently limited to 17 chars. The zone configuration files are located in the /usr/lib/firewalld/zones/ and /etc/firewalld/zones/ directories.

The following example shows a configuration that allows one service ( SSH ) and one port range, for both the TCP and UDP protocols:

  • firewalld.zone manual page

45.6. Predefined firewalld services

The firewalld service is a predefined set of firewall rules that define access to a specific application or network service. Each service represents a combination of the following elements:

  • Network protocol
  • Associated firewall rules
  • Source ports and destinations
  • Firewall helper modules that load automatically if a service is enabled

A service simplifies packet filtering and saves you time because it achieves several tasks at once. For example, firewalld can perform the following tasks at once:

  • Open a port
  • Define network protocol
  • Enable packet forwarding

Service configuration options and generic file information are described in the firewalld.service(5) man page. The services are specified by means of individual XML configuration files, which are named in the following format: service-name .xml . Protocol names are preferred over service or application names in firewalld .

You can configure firewalld in the following ways:

Use utilities:

  • firewall-config - graphical utility
  • firewall-cmd - command-line utility
  • firewall-offline-cmd - command-line utility

Edit the XML files in the /etc/firewalld/services/ directory.

If you do not add or change the service, no corresponding XML file exists in /etc/firewalld/services/ . You can use the files in /usr/lib/firewalld/services/ as templates.

  • The firewalld.service(5) man page

45.7. Working with firewalld zones

Zones represent a concept to manage incoming traffic more transparently. The zones are connected to networking interfaces or assigned a range of source addresses. You manage firewall rules for each zone independently, which enables you to define complex firewall settings and apply them to the traffic.

45.7.1. Customizing firewall settings for a specific zone to enhance security

You can strengthen your network security by modifying the firewall settings and associating a specific network interface or connection with a particular firewall zone. By defining granular rules and restrictions for a zone, you can control inbound and outbound traffic based on your intended security levels.

For example, you can achieve the following benefits:

  • Protection of sensitive data
  • Prevention of unauthorized access
  • Mitigation of potential network threats
  • The firewalld service is running.

List the available firewall zones:

The firewall-cmd --get-zones command displays all zones that are available on the system, but it does not show any details for particular zones. To see more detailed information for all zones, use the firewall-cmd --list-all-zones command.

  • Choose the zone you want to use for this configuration.

Modify firewall settings for the chosen zone. For example, to allow the SSH service and remove the ftp service:

Assign a network interface to the firewall zone:

List the available network interfaces:

Activity of a zone is determined by the presence of network interfaces or source address ranges that match its configuration. The default zone is active for unclassified traffic but is not always active if no traffic matches its rules.

Assign a network interface to the chosen zone:

Assigning a network interface to a zone is more suitable for applying consistent firewall settings to all traffic on a particular interface (physical or virtual).

The firewall-cmd command, when used with the --permanent option, often involves updating NetworkManager connection profiles to make changes to the firewall configuration permanent. This integration between firewalld and NetworkManager ensures consistent network and firewall settings.

Display the updated settings for your chosen zone:

The command output displays all zone settings including the assigned services, network interface, and network connections (sources).

45.7.2. Changing the default zone

System administrators assign a zone to a networking interface in its configuration files. If an interface is not assigned to a specific zone, it is assigned to the default zone. After each restart of the firewalld service, firewalld loads the settings for the default zone and makes it active. Note that settings for all other zones are preserved and ready to be used.

Typically, zones are assigned to interfaces by NetworkManager according to the connection.zone setting in NetworkManager connection profiles. Also, after a reboot NetworkManager manages assignments for "activating" those zones.

To set up the default zone:

Display the current default zone:

Set the new default zone:

Following this procedure, the setting is a permanent setting, even without the --permanent option.

45.7.3. Assigning a network interface to a zone

It is possible to define different sets of rules for different zones and then change the settings quickly by changing the zone for the interface that is being used. With multiple interfaces, a specific zone can be set for each of them to distinguish traffic that is coming through them.

To assign the zone to a specific interface:

List the active zones and the interfaces assigned to them:

Assign the interface to a different zone:

45.7.4. Assigning a zone to a connection using nmcli

You can add a firewalld zone to a NetworkManager connection using the nmcli utility.

Assign the zone to the NetworkManager connection profile:

45.7.5. Manually assigning a zone to a network connection in a connection profile file

If you cannot use the nmcli utility to modify a connection profile, you can manually edit the corresponding file of the profile to assign a firewalld zone.

Modifying the connection profile with the nmcli utility to assign a firewalld zone is more efficient. For details, see Assigning a network interface to a zone .

Determine the path to the connection profile and its format:

NetworkManager uses separate directories and file names for the different connection profile formats:

  • Profiles in /etc/NetworkManager/system-connections/ <connection_name> .nmconnection files use the keyfile format.
  • Profiles in /etc/sysconfig/network-scripts/ifcfg- <interface_name> files use the ifcfg format.

Depending on the format, update the corresponding file:

If the file uses the keyfile format, append zone= <name> to the [connection] section of the /etc/NetworkManager/system-connections/ <connection_name> .nmconnection file:

If the file uses the ifcfg format, append ZONE= <name> to the /etc/sysconfig/network-scripts/ifcfg- <interface_name> file:

Reactivate the connection profiles

Display the zone of the interface, for example:

45.7.6. Manually assigning a zone to a network connection in an ifcfg file

When the connection is managed by NetworkManager , it must be aware of a zone that it uses. For every network connection profile, a zone can be specified, which provides the flexibility of various firewall settings according to the location of the computer with portable devices. Thus, zones and settings can be specified for different locations, such as company or home.

To set a zone for a connection, edit the /etc/sysconfig/network-scripts/ifcfg- connection_name file and add a line that assigns a zone to this connection:

45.7.7. Creating a new zone

To use custom zones, create a new zone and use it just like a predefined zone. New zones require the --permanent option, otherwise the command does not work.

Create a new zone:

Make the new zone usable:

The command applies recent changes to the firewall configuration without interrupting network services that are already running.

Check if the new zone is added to your permanent settings:

45.7.8. Using zone targets to set default behavior for incoming traffic

For every zone, you can set a default behavior that handles incoming traffic that is not further specified. Such behavior is defined by setting the target of the zone. There are four options:

  • ACCEPT : Accepts all incoming packets except those disallowed by specific rules.
  • REJECT : Rejects all incoming packets except those allowed by specific rules. When firewalld rejects packets, the source machine is informed about the rejection.
  • DROP : Drops all incoming packets except those allowed by specific rules. When firewalld drops packets, the source machine is not informed about the packet drop.
  • default : Similar behavior as for REJECT , but with special meanings in certain scenarios.

To set a target for a zone:

List the information for the specific zone to see the default target:

Set a new target in the zone:

  • firewall-cmd(1) man page

45.8. Controlling network traffic using firewalld

The firewalld package installs a large number of predefined service files and you can add more or customize them. You can then use these service definitions to open or close ports for services without knowing the protocol and port numbers they use.

45.8.1. Controlling traffic with predefined services using the CLI

The most straightforward method to control traffic is to add a predefined service to firewalld . This opens all necessary ports and modifies other settings according to the service definition file .

Check that the service in firewalld is not already allowed:

The command lists the services that are enabled in the default zone.

List all predefined services in firewalld :

The command displays a list of available services for the default zone.

Add the service to the list of services that firewalld allows:

The command adds the specified service to the default zone.

Make the new settings persistent:

The command applies these runtime changes to the permanent configuration of the firewall. By default, it applies these changes to the configuration of the default zone.

List all permanent firewall rules:

The command displays complete configuration with the permanent firewall rules of the default firewall zone ( public ).

Check the validity of the permanent configuration of the firewalld service.

If the permanent configuration is invalid, the command returns an error with further details:

You can also manually inspect the permanent configuration files to verify the settings. The main configuration file is /etc/firewalld/firewalld.conf . The zone-specific configuration files are in the /etc/firewalld/zones/ directory and the policies are in the /etc/firewalld/policies/ directory.

45.8.2. Controlling traffic with predefined services using the GUI

You can control the network traffic with predefined services using a graphical user interface. The Firewall Configuration application provides an accessible and user-friendly alternative to the command-line utilities.

  • You installed the firewall-config package.

To enable or disable a predefined or custom service:

  • Start the firewall-config utility and select the network zone whose services are to be configured.
  • Select the Zones tab and then the Services tab below.
  • Select the checkbox for each type of service you want to trust or clear the checkbox to block a service in the selected zone.

To edit a service:

  • Start the firewall-config utility.
  • Select Permanent from the menu labeled Configuration . Additional icons and menu buttons appear at the bottom of the Services window.
  • Select the service you want to configure.

The Ports , Protocols , and Source Port tabs enable adding, changing, and removing of ports, protocols, and source port for the selected service. The modules tab is for configuring Netfilter helper modules. The Destination tab enables limiting traffic to a particular destination address and Internet Protocol ( IPv4 or IPv6 ).

It is not possible to alter service settings in the Runtime mode.

  • Press the Super key to enter the Activities overview.

Select the Firewall Configuration utility.

  • You can also start the graphical firewall configuration utility using the command-line, by entering the firewall-config command.

View the list of configurations of your firewall:

firewall configuration

The Firewall Configuration window opens. Note that this command can be run as a normal user, but you are prompted for an administrator password occasionally.

45.8.3. Configuring firewalld to allow hosting a secure web server

Ports are logical services that enable an operating system to receive and distinguish network traffic and forward it to system services. The system services are represented by a daemon that listens on the port and waits for any traffic coming to this port.

Normally, system services listen on standard ports that are reserved for them. The httpd daemon, for example, listens on port 80. However, system administrators can directly specify the port number instead of the service name.

You can use the firewalld service to configure access to a secure web server for hosting your data.

Check the currently active firewall zone:

Add the HTTPS service to the appropriate zone:

Reload the firewall configuration:

Check if the port is open in firewalld :

If you opened the port by specifying the port number, enter:

If you opened the port by specifying a service definition, enter:

45.8.4. Closing unused or unnecessary ports to enhance network security

When an open port is no longer needed, you can use the firewalld utility to close it.

Close all unnecessary ports to reduce the potential attack surface and minimize the risk of unauthorized access or exploitation of vulnerabilities.

List all allowed ports:

By default, this command lists the ports that are enabled in the default zone.

This command will only give you a list of ports that are opened as ports. You will not be able to see any open ports that are opened as a service. For that case, consider using the --list-all option instead of --list-ports .

Remove the port from the list of allowed ports to close it for the incoming traffic:

This command removes a port from a zone. If you do not specify a zone, it will remove the port from the default zone.

Without specifying a zone, this command applies runtime changes to the permanent configuration of the default zone.

List the active zones and choose the zone you want to inspect:

List the currently open ports in the selected zone to check if the unused or unnecessary ports are closed:

45.8.5. Controlling traffic through the CLI

You can use the firewall-cmd command to:

  • disable networking traffic
  • enable networking traffic

As a result, you can for example enhance your system defenses, ensure data privacy or optimize network resources.

Enabling panic mode stops all networking traffic. For this reason, it should be used only when you have the physical access to the machine or if you are logged in using a serial console.

To immediately disable networking traffic, switch panic mode on:

Switching off panic mode reverts the firewall to its permanent settings. To switch panic mode off, enter:

To see whether panic mode is switched on or off, use:

45.8.6. Controlling traffic with protocols using GUI

To permit traffic through the firewall using a certain protocol, you can use the GUI.

  • You installed the firewall-config package
  • Start the firewall-config tool and select the network zone whose settings you want to change.
  • Select the Protocols tab and click the Add button on the right-hand side. The Protocol window opens.
  • Either select a protocol from the list or select the Other Protocol check box and enter the protocol in the field.

45.9. Using zones to manage incoming traffic depending on a source

You can use zones to manage incoming traffic based on its source. Incoming traffic in this context is any data that is destined for your system, or passes through the host running firewalld . The source typically refers to the IP address or network range from which the traffic originates. As a result, you can sort incoming traffic and assign it to different zones to allow or disallow services that can be reached by that traffic.

Matching by source address takes precedence over matching by interface name. When you add a source to a zone, the firewall will prioritize the source-based rules for incoming traffic over interface-based rules. This means that if incoming traffic matches a source address specified for a particular zone, the zone associated with that source address will determine how the traffic is handled, regardless of the interface through which it arrives. On the other hand, interface-based rules are generally a fallback for traffic that does not match specific source-based rules. These rules apply to traffic, for which the source is not explicitly associated with a zone. This allows you to define a default behavior for traffic that does not have a specific source-defined zone.

45.9.1. Adding a source

To route incoming traffic into a specific zone, add the source to that zone. The source can be an IP address or an IP mask in the classless inter-domain routing (CIDR) notation.

In case you add multiple zones with an overlapping network range, they are ordered alphanumerically by zone name and only the first one is considered.

To set the source in the current zone:

To set the source IP address for a specific zone:

The following procedure allows all incoming traffic from 192.168.2.15 in the trusted zone:

List all available zones:

Add the source IP to the trusted zone in the permanent mode:

45.9.2. Removing a source

When you remove a source from a zone, the traffic which originates from the source is no longer directed through the rules specified for that source. Instead, the traffic falls back to the rules and settings of the zone associated with the interface from which it originates, or goes to the default zone.

List allowed sources for the required zone:

Remove the source from the zone permanently:

45.9.3. Removing a source port

By removing a source port you disable sorting the traffic based on a port of origin.

To remove a source port:

45.9.4. Using zones and sources to allow a service for only a specific domain

To allow traffic from a specific network to use a service on a machine, use zones and source. The following procedure allows only HTTP traffic from the 192.0.2.0/24 network while any other traffic is blocked.

When you configure this scenario, use a zone that has the default target. Using a zone that has the target set to ACCEPT is a security risk, because for traffic from 192.0.2.0/24 , all network connections would be accepted.

Add the IP range to the internal zone to route the traffic originating from the source through the zone:

Add the http service to the internal zone:

Check that the internal zone is active and that the service is allowed in it:

  • firewalld.zones(5) man page

45.10. Filtering forwarded traffic between zones

firewalld enables you to control the flow of network data between different firewalld zones. By defining rules and policies, you can manage how traffic is allowed or blocked when it moves between these zones.

The policy objects feature provides forward and output filtering in firewalld . You can use firewalld to filter traffic between different zones to allow access to locally hosted VMs to connect the host.

45.10.1. The relationship between policy objects and zones

Policy objects allow the user to attach firewalld’s primitives such as services, ports, and rich rules to the policy. You can apply the policy objects to traffic that passes between zones in a stateful and unidirectional manner.

HOST and ANY are the symbolic zones used in the ingress and egress zone lists.

  • The HOST symbolic zone allows policies for the traffic originating from or has a destination to the host running firewalld.
  • The ANY symbolic zone applies policy to all the current and future zones. ANY symbolic zone acts as a wildcard for all zones.

45.10.2. Using priorities to sort policies

Multiple policies can apply to the same set of traffic, therefore, priorities should be used to create an order of precedence for the policies that may be applied.

To set a priority to sort the policies:

In the above example -500 is a lower priority value but has higher precedence. Thus, -500 will execute before -100.

Lower numerical priority values have higher precedence and are applied first.

45.10.3. Using policy objects to filter traffic between locally hosted containers and a network physically connected to the host

The policy objects feature allows users to filter traffic between Podman and firewalld zones.

Red Hat recommends blocking all traffic by default and opening the selective services needed for the Podman utility.

Create a new firewall policy:

Block all traffic from Podman to other zones and allow only necessary services on Podman:

Create a new Podman zone:

Define the ingress zone for the policy:

Define the egress zone for all other zones:

Setting the egress zone to ANY means that you filter from Podman to other zones. If you want to filter to the host, then set the egress zone to HOST.

Restart the firewalld service:

Verify the Podman firewall policy to other zones:

45.10.4. Setting the default target of policy objects

You can specify --set-target options for policies. The following targets are available:

  • ACCEPT - accepts the packet
  • DROP - drops the unwanted packets
  • REJECT - rejects unwanted packets with an ICMP reply

CONTINUE (default) - packets will be subject to rules in following policies and zones.

Verify information about the policy

45.10.5. Using DNAT to forward HTTPS traffic to a different host

If your web server runs in a DMZ with private IP addresses, you can configure destination network address translation (DNAT) to enable clients on the internet to connect to this web server. In this case, the host name of the web server resolves to the public IP address of the router. When a client establishes a connection to a defined port on the router, the router forwards the packets to the internal web server.

  • The DNS server resolves the host name of the web server to the router’s IP address.

You know the following settings:

  • The private IP address and port number that you want to forward
  • The IP protocol to be used
  • The destination IP address and port of the web server where you want to redirect the packets

Create a firewall policy:

The policies, as opposed to zones, allow packet filtering for input, output, and forwarded traffic. This is important, because forwarding traffic to endpoints on locally run web servers, containers, or virtual machines requires such capability.

Configure symbolic zones for the ingress and egress traffic to also enable the router itself to connect to its local IP address and forward this traffic:

The --add-ingress-zone=HOST option refers to packets generated locally and transmitted out of the local host. The --add-egress-zone=ANY option refers to traffic moving to any zone.

Add a rich rule that forwards traffic to the web server:

The rich rule forwards TCP traffic from port 443 on the IP address of the router (192.0.2.1) to port 443 of the IP address of the web server (192.51.100.20).

Reload the firewall configuration files:

Activate routing of 127.0.0.0/8 in the kernel:

For persistent changes, run:

The command persistently configures the route_localnet kernel parameter and ensures that the setting is preserved after the system reboots.

For applying the settings immediately without a system reboot, run:

The sysctl command is useful for applying on-the-fly changes, however the configuration will not persist across system reboots.

Connect to the IP address of the router and to the port that you have forwarded to the web server:

Optional: Verify that the net.ipv4.conf.all.route_localnet kernel parameter is active:

Verify that <example_policy> is active and contains the settings you need, especially the source IP address and port, protocol to be used, and the destination IP address and port:

  • firewall-cmd(1) , firewalld.policies(5) , firewalld.richlanguage(5) , sysctl(8) , and sysctl.conf(5) man pages
  • Using configuration files in /etc/sysctl.d/ to adjust kernel parameters

45.11. Configuring NAT using firewalld

With firewalld , you can configure the following network address translation (NAT) types:

  • Masquerading
  • Destination NAT (DNAT)

45.11.1. Network address translation types

These are the different network address translation (NAT) types:

Use one of these NAT types to change the source IP address of packets. For example, Internet Service Providers (ISPs) do not route private IP ranges, such as 10.0.0.0/8 . If you use private IP ranges in your network and users should be able to reach servers on the internet, map the source IP address of packets from these ranges to a public IP address.

  • Masquerading automatically uses the IP address of the outgoing interface. Therefore, use masquerading if the outgoing interface uses a dynamic IP address.

45.11.2. Configuring IP address masquerading

You can enable IP masquerading on your system. IP masquerading hides individual machines behind a gateway when accessing the internet.

To check if IP masquerading is enabled (for example, for the external zone), enter the following command as root :

The command prints yes with exit status 0 if enabled. It prints no with exit status 1 otherwise. If zone is omitted, the default zone will be used.

To enable IP masquerading, enter the following command as root :

  • To make this setting persistent, pass the --permanent option to the command.

To disable IP masquerading, enter the following command as root :

To make this setting permanent, pass the --permanent option to the command.

45.11.3. Using DNAT to forward incoming HTTP traffic

You can use destination network address translation (DNAT) to direct incoming traffic from one destination address and port to another. Typically, this is useful for redirecting incoming requests from an external network interface to specific internal servers or services.

Create the /etc/sysctl.d/90-enable-IP-forwarding.conf file with the following content:

This setting enables IP forwarding in the kernel. It makes the internal RHEL server act as a router and forward packets from network to network.

Load the setting from the /etc/sysctl.d/90-enable-IP-forwarding.conf file:

Forward incoming HTTP traffic:

The previous command defines a DNAT rule with the following settings:

  • --zone=public - The firewall zone for which you configure the DNAT rule. You can adjust this to whatever zone you need.
  • --add-forward-port - The option that indicates you are adding a port-forwarding rule.
  • port=80 - The external destination port.
  • proto=tcp - The protocol indicating that you forward TCP traffic.
  • toaddr=198.51.100.10 - The destination IP address.
  • toport=8080 - The destination port of the internal server.
  • --permanent - The option that makes the DNAT rule persistent across reboots.

Reload the firewall configuration to apply the changes:

Verify the DNAT rule for the firewall zone that you used:

Alternatively, view the corresponding XML configuration file:

  • Configuring kernel parameters at runtime
  • firewall-cmd(1) manual page

45.11.4. Redirecting traffic from a non-standard port to make the web service accessible on a standard port

You can use the redirect mechanism to make the web service that internally runs on a non-standard port accessible without requiring users to specify the port in the URL. As a result, the URLs are simpler and provide better browsing experience, while a non-standard port is still used internally or for specific requirements.

This setting enables IP forwarding in the kernel.

Create the NAT redirect rule:

The previous command defines the NAT redirect rule with the following settings:

  • --zone=public - The firewall zone, for which you configure the rule. You can adjust this to whatever zone you need.
  • --add-forward-port=port= <non_standard_port> - The option that indicates you are adding a port-forwarding (redirecting) rule with source port on which you initially receive the incoming traffic.
  • proto=tcp - The protocol indicating that you redirect TCP traffic.
  • toport= <standard_port> - The destination port, to which the incoming traffic should be redirected after being received on the source port.
  • --permanent - The option that makes the rule persist across reboots.

Verify the redirect rule for the firewall zone that you used:

45.12. Managing ICMP requests

The Internet Control Message Protocol ( ICMP ) is a supporting protocol that is used by various network devices for testing, troubleshooting, and diagnostics. ICMP differs from transport protocols such as TCP and UDP because it is not used to exchange data between systems.

You can use the ICMP messages, especially echo-request and echo-reply , to reveal information about a network and misuse such information for various kinds of fraudulent activities. Therefore, firewalld enables controlling the ICMP requests to protect your network information.

45.12.1. Configuring ICMP filtering

You can use ICMP filtering to define which ICMP types and codes you want the firewall to permit or deny from reaching your system. ICMP types and codes are specific categories and subcategories of ICMP messages.

ICMP filtering helps, for example, in the following areas:

  • Security enhancement - Block potentially harmful ICMP types and codes to reduce your attack surface.
  • Network performance - Permit only necessary ICMP types to optimize network performance and prevent potential network congestion caused by excessive ICMP traffic.
  • Troubleshooting control - Maintain essential ICMP functionality for network troubleshooting and block ICMP types that represent potential security risk.

List available ICMP types and codes:

From this predefined list, select which ICMP types and codes to allow or block.

Filter specific ICMP types by:

Allowing ICMP types:

The command removes any existing blocking rules for the echo requests ICMP type.

Blocking ICMP types:

The command ensures that the redirect messages ICMP type is blocked by the firewall.

Verify your filtering rules are in effect:

The command output displays the ICMP types and codes that you allowed or blocked.

45.13. Setting and controlling IP sets using firewalld

IP sets are a RHEL feature for grouping of IP addresses and networks into sets to achieve more flexible and efficient firewall rule management.

The IP sets are valuable in scenarios when you need to for example:

  • Handle large lists of IP addresses
  • Implement dynamic updates to those large lists of IP addresses
  • Create custom IP-based policies to enhance network security and control

Red Hat recommends using the firewall-cmd command to create and manage IP sets.

45.13.1. Configuring dynamic updates for allowlisting with IP sets

You can make near real-time updates to flexibly allow specific IP addresses or ranges in the IP sets even in unpredictable conditions. These updates can be triggered by various events, such as detection of security threats or changes in the network behavior. Typically, such a solution leverages automation to reduce manual effort and improve security by responding quickly to the situation.

Create an IP set with a meaningful name:

The new IP set called allowlist contains IP addresses that you want your firewall to allow.

Add a dynamic update to the IP set:

This configuration updates the allowlist IP set with a newly added IP address that is allowed to pass network traffic by your firewall.

Create a firewall rule that references the previously created IP set:

Without this rule, the IP set would not have any impact on network traffic. The default firewall policy would prevail.

List all IP sets:

List the active rules:

The sources section of the command-line output provides insights to what origins of traffic (hostnames, interfaces, IP sets, subnets, and others) are permitted or denied access to a particular firewall zone. In this case, the IP addresses contained in the allowlist IP set are allowed to pass traffic through the firewall for the public zone.

Explore the contents of your IP set:

  • Use a script or a security utility to fetch your threat intelligence feeds and update allowlist accordingly in an automated fashion.

45.14. Prioritizing rich rules

By default, rich rules are organized based on their rule action. For example, deny rules have precedence over allow rules. The priority parameter in rich rules provides administrators fine-grained control over rich rules and their execution order. When using the priority parameter, rules are sorted first by their priority values in ascending order. When more rules have the same priority , their order is determined by the rule action, and if the action is also the same, the order may be undefined.

45.14.1. How the priority parameter organizes rules into different chains

You can set the priority parameter in a rich rule to any number between -32768 and 32767 , and lower numerical values have higher precedence.

The firewalld service organizes rules based on their priority value into different chains:

  • Priority lower than 0: the rule is redirected into a chain with the _pre suffix.
  • Priority higher than 0: the rule is redirected into a chain with the _post suffix.
  • Priority equals 0: based on the action, the rule is redirected into a chain with the _log , _deny , or _allow the action.

Inside these sub-chains, firewalld sorts the rules based on their priority value.

45.14.2. Setting the priority of a rich rule

The following is an example of how to create a rich rule that uses the priority parameter to log all traffic that is not allowed or denied by other rules. You can use this rule to flag unexpected traffic.

Add a rich rule with a very low precedence to log all traffic that has not been matched by other rules:

The command additionally limits the number of log entries to 5 per minute.

Display the nftables rule that the command in the previous step created:

45.15. Configuring firewall lockdown

Local applications or services are able to change the firewall configuration if they are running as root (for example, libvirt ). With this feature, the administrator can lock the firewall configuration so that either no applications or only applications that are added to the lockdown allow list are able to request firewall changes. The lockdown settings default to disabled. If enabled, the user can be sure that there are no unwanted configuration changes made to the firewall by local applications or services.

45.15.1. Configuring lockdown using CLI

You can enable or disable the lockdown feature using the command line.

To query whether lockdown is enabled:

Manage lockdown configuration by either:

Enabling lockdown:

Disabling lockdown:

45.15.2. Overview of lockdown allowlist configuration files

The default allowlist configuration file contains the NetworkManager context and the default context of libvirt . The user ID 0 is also on the list.

The allowlist configuration files are stored in the /etc/firewalld/ directory.

Following is an example allowlist configuration file enabling all commands for the firewall-cmd utility, for a user called user whose user ID is 815 :

This example shows both user id and user name , but only one option is required. Python is the interpreter and is prepended to the command line.

In Red Hat Enterprise Linux, all utilities are placed in the /usr/bin/ directory and the /bin/ directory is sym-linked to the /usr/bin/ directory. In other words, although the path for firewall-cmd when entered as root might resolve to /bin/firewall-cmd , /usr/bin/firewall-cmd can now be used. All new scripts should use the new location. But be aware that if scripts that run as root are written to use the /bin/firewall-cmd path, then that command path must be added in the allowlist in addition to the /usr/bin/firewall-cmd path traditionally used only for non- root users.

The * at the end of the name attribute of a command means that all commands that start with this string match. If the * is not there then the absolute command including arguments must match.

45.16. Enabling traffic forwarding between different interfaces or sources within a firewalld zone

Intra-zone forwarding is a firewalld feature that enables traffic forwarding between interfaces or sources within a firewalld zone.

45.16.1. The difference between intra-zone forwarding and zones with the default target set to ACCEPT

With intra-zone forwarding enabled, the traffic within a single firewalld zone can flow from one interface or source to another interface or source. The zone specifies the trust level of interfaces and sources. If the trust level is the same, the traffic stays inside the same zone.

Enabling intra-zone forwarding in the default zone of firewalld , applies only to the interfaces and sources added to the current default zone.

firewalld uses different zones to manage incoming and outgoing traffic. Each zone has its own set of rules and behaviors. For example, the trusted zone, allows all forwarded traffic by default.

Other zones can have different default behaviors. In standard zones, forwarded traffic is typically dropped by default when the target of the zone is set to default .

To control how the traffic is forwarded between different interfaces or sources within a zone, make sure you understand and configure the target of the zone accordingly.

45.16.2. Using intra-zone forwarding to forward traffic between an Ethernet and Wi-Fi network

You can use intra-zone forwarding to forward traffic between interfaces and sources within the same firewalld zone. This feature brings the following benefits:

  • Seamless connectivity between wired and wireless devices (you can forward traffic between an Ethernet network connected to enp1s0 and a Wi-Fi network connected to wlp0s20 )
  • Support for flexible work environments
  • Shared resources that are accessible and used by multiple devices or users within a network (such as printers, databases, network-attached storage, and others)
  • Efficient internal networking (such as smooth communication, reduced latency, resource accessibility, and others)

You can enable this functionality for individual firewalld zones.

Enable packet forwarding in the kernel:

Ensure that interfaces between which you want to enable intra-zone forwarding are assigned only to the internal zone:

If the interface is currently assigned to a zone other than internal , reassign it:

Add the enp1s0 and wlp0s20 interfaces to the internal zone:

Enable intra-zone forwarding:

The following verification steps require that the nmap-ncat package is installed on both hosts.

  • Log in to a host that is on the same network as the enp1s0 interface of the host on which you enabled zone forwarding.

Start an echo service with ncat to test connectivity:

  • Log in to a host that is in the same network as the wlp0s20 interface.

Connect to the echo server running on the host that is in the same network as the enp1s0 :

  • Type something and press Enter . Verify the text is sent back.

45.17. Configuring firewalld by using RHEL System Roles

You can use the firewall System Role to configure settings of the firewalld service on multiple clients at once. This solution:

  • Provides an interface with efficient input settings.
  • Keeps all intended firewalld parameters in one place.

After you run the firewall role on the control node, the System Role applies the firewalld parameters to the managed node immediately and makes them persistent across reboots.

45.17.1. Introduction to the firewall RHEL System Role

RHEL System Roles is a set of contents for the Ansible automation utility. This content together with the Ansible automation utility provides a consistent configuration interface to remotely manage multiple systems.

The rhel-system-roles.firewall role from the RHEL System Roles was introduced for automated configurations of the firewalld service. The rhel-system-roles package contains this System Role, and also the reference documentation.

To apply the firewalld parameters on one or more systems in an automated fashion, use the firewall System Role variable in a playbook. A playbook is a list of one or more plays that is written in the text-based YAML format.

You can use an inventory file to define a set of systems that you want Ansible to configure.

With the firewall role you can configure many different firewalld parameters, for example:

  • The services for which packets should be allowed.
  • Granting, rejection, or dropping of traffic access to ports.
  • Forwarding of ports or port ranges for a zone.
  • README.md and README.html files in the /usr/share/doc/rhel-system-roles/firewall/ directory
  • Working with playbooks
  • How to build your inventory

45.17.2. Resetting the firewalld settings by using a RHEL System Role

With the firewall RHEL system role, you can reset the firewalld settings to their default state. If you add the previous:replaced parameter to the variable list, the System Role removes all existing user-defined settings and resets firewalld to the defaults. If you combine the previous:replaced parameter with other settings, the firewall role removes all existing settings before applying new ones.

Create a playbook file, for example ~/reset-firewalld.yml , with the following content:

Run this command as root on the managed node to check all the zones:

  • /usr/share/ansible/roles/rhel-system-roles.firewall/README.md

45.17.3. Forwarding incoming traffic in firewalld from one local port to a different local port by using a RHEL System Role

With the firewall role you can remotely configure firewalld parameters with persisting effect on multiple managed hosts.

Create a playbook file, for example ~/port_forwarding.yml , with the following content:

On the managed host, display the firewalld settings:

45.17.4. Managing ports in firewalld by using a RHEL System Role

You can use the RHEL firewall System Role to open or close ports in the local firewall for incoming traffic and make the new configuration persist across reboots. For example you can configure the default zone to permit incoming traffic for the HTTPS service.

Create a playbook file, for example ~/opening-a-port.yml , with the following content:

The permanent: true option makes the new settings persistent across reboots.

On the managed node, verify that the 443/tcp port associated with the HTTPS service is open:

45.17.5. Configuring a firewalld DMZ zone by using a RHEL System Role

As a system administrator, you can use the firewall System Role to configure a dmz zone on the enp1s0 interface to permit HTTPS traffic to the zone. In this way, you enable external users to access your web servers.

Create a playbook file, for example ~/configuring-a-dmz.yml , with the following content:

On the managed node, view detailed information about the dmz zone:

Chapter 46. Getting started with nftables

The nftables framework classifies packets and it is the successor to the iptables , ip6tables , arptables , ebtables , and ipset utilities. It offers numerous improvements in convenience, features, and performance over previous packet-filtering tools, most notably:

  • Built-in lookup tables instead of linear processing
  • A single framework for both the IPv4 and IPv6 protocols
  • All rules applied atomically instead of fetching, updating, and storing a complete rule set
  • Support for debugging and tracing in the rule set ( nftrace ) and monitoring trace events (in the nft tool)
  • More consistent and compact syntax, no protocol-specific extensions
  • A Netlink API for third-party applications

The nftables framework uses tables to store chains. The chains contain individual rules for performing actions. The nft utility replaces all tools from the previous packet-filtering frameworks. You can use the libnftnl library for low-level interaction with nftables Netlink API through the libmnl library.

To display the effect of rule set changes, use the nft list ruleset command. Because these utilities add tables, chains, rules, sets, and other objects to the nftables rule set, be aware that nftables rule-set operations, such as the nft flush ruleset command, might affect rule sets installed using the iptables command.

46.1. Migrating from iptables to nftables

If your firewall configuration still uses iptables rules, you can migrate your iptables rules to nftables .

46.1.1. When to use firewalld, nftables, or iptables

46.1.2. converting iptables and ip6tables rule sets to nftables.

Use the iptables-restore-translate and ip6tables-restore-translate utilities to translate iptables and ip6tables rule sets to nftables .

  • The nftables and iptables packages are installed.
  • The system has iptables and ip6tables rules configured.

Write the iptables and ip6tables rules to a file:

Convert the dump files to nftables instructions:

  • Review and, if needed, manually update the generated nftables rules.

To enable the nftables service to load the generated files, add the following to the /etc/sysconfig/nftables.conf file:

Stop and disable the iptables service:

If you used a custom script to load the iptables rules, ensure that the script no longer starts automatically and reboot to flush all tables.

Enable and start the nftables service:

Display the nftables rule set:

  • Automatically loading nftables rules when the system boots

46.1.3. Converting single iptables and ip6tables rules to nftables

Red Hat Enterprise Linux provides the iptables-translate and ip6tables-translate utilities to convert an iptables or ip6tables rule into the equivalent one for nftables .

  • The nftables package is installed.

Use the iptables-translate or ip6tables-translate utility instead of iptables or ip6tables to display the corresponding nftables rule, for example:

Note that some extensions lack translation support. In these cases, the utility prints the untranslated rule prefixed with the # sign, for example:

  • iptables-translate --help

46.1.4. Comparison of common iptables and nftables commands

The following is a comparison of common iptables and nftables commands:

Listing all rules:

Listing a certain table and chain:

The nft command does not pre-create tables and chains. They exist only if a user created them manually.

Listing rules generated by firewalld:

46.2. Writing and executing nftables scripts

The major benefit of using the nftables framework is that the execution of scripts is atomic. This means that the system either applies the whole script or prevents the execution if an error occurs. This guarantees that the firewall is always in a consistent state.

Additionally, with the nftables script environment, you can:

  • Add comments
  • Define variables
  • Include other rule-set files

When you install the nftables package, Red Hat Enterprise Linux automatically creates *.nft scripts in the /etc/nftables/ directory. These scripts contain commands that create tables and empty chains for different purposes.

46.2.1. Supported nftables script formats

You can write scripts in the nftables scripting environment in the following formats:

The same format as the nft list ruleset command displays the rule set:

The same syntax as for nft commands:

46.2.2. Running nftables scripts

You can run an nftables script either by passing it to the nft utility or by executing the script directly.

To run an nftables script by passing it to the nft utility, enter:

To run an nftables script directly:

For the single time that you perform this:

Ensure that the script starts with the following shebang sequence:

If you omit the -f parameter, the nft utility does not read the script and displays: Error: syntax error, unexpected newline, expecting string .

Optional: Set the owner of the script to root :

Make the script executable for the owner:

Run the script:

If no output is displayed, the system executed the script successfully.

Even if nft executes the script successfully, incorrectly placed rules, missing parameters, or other problems in the script can cause that the firewall behaves not as expected.

  • chown(1) man page
  • chmod(1) man page

46.2.3. Using comments in nftables scripts

The nftables scripting environment interprets everything to the right of a # character to the end of a line as a comment.

Comments can start at the beginning of a line, or next to a command:

46.2.4. Using variables in nftables script

To define a variable in an nftables script, use the define keyword. You can store single values and anonymous sets in a variable. For more complex scenarios, use sets or verdict maps.

The following example defines a variable named INET_DEV with the value enp1s0 :

You can use the variable in the script by entering the $ sign followed by the variable name:

The following example defines a variable that contains an anonymous set:

You can use the variable in the script by writing the $ sign followed by the variable name:

Curly braces have special semantics when you use them in a rule because they indicate that the variable represents a set.

  • Using sets in nftables commands
  • Using verdict maps in nftables commands

46.2.5. Including files in nftables scripts

In the nftables scripting environment, you can include other scripts by using the include statement.

If you specify only a file name without an absolute or relative path, nftables includes files from the default search path, which is set to /etc on Red Hat Enterprise Linux.

Example 46.1. Including files from the default search directory

To include a file from the default search directory:

Example 46.2. Including all *.nft files from a directory

To include all files ending with *.nft that are stored in the /etc/nftables/rulesets/ directory:

Note that the include statement does not match files beginning with a dot.

  • The Include files section in the nft(8) man page

46.2.6. Automatically loading nftables rules when the system boots

The nftables systemd service loads firewall scripts that are included in the /etc/sysconfig/nftables.conf file.

  • The nftables scripts are stored in the /etc/nftables/ directory.

Edit the /etc/sysconfig/nftables.conf file.

  • If you modified the *.nft scripts that were created in /etc/nftables/ with the installation of the nftables package, uncomment the include statement for these scripts.

If you wrote new scripts, add include statements to include these scripts. For example, to load the /etc/nftables/ example .nft script when the nftables service starts, add:

Optional: Start the nftables service to load the firewall rules without rebooting the system:

Enable the nftables service.

  • Supported nftables script formats

46.3. Creating and managing nftables tables, chains, and rules

You can display nftables rule sets and manage them.

46.3.1. Basics of nftables tables

A table in nftables is a namespace that contains a collection of chains, rules, sets, and other objects.

Each table must have an address family assigned. The address family defines the packet types that this table processes. You can set one of the following address families when you create a table:

  • ip : Matches only IPv4 packets. This is the default if you do not specify an address family.
  • ip6 : Matches only IPv6 packets.
  • inet : Matches both IPv4 and IPv6 packets.
  • arp : Matches IPv4 address resolution protocol (ARP) packets.
  • bridge : Matches packets that pass through a bridge device.
  • netdev : Matches packets from ingress.

If you want to add a table, the format to use depends on your firewall script:

In scripts in native syntax, use:

In shell scripts, use:

46.3.2. Basics of nftables chains

Tables consist of chains which in turn are containers for rules. The following two rule types exists:

  • Base chain : You can use base chains as an entry point for packets from the networking stack.
  • Regular chain : You can use regular chains as a jump target to better organize rules.

If you want to add a base chain to a table, the format to use depends on your firewall script:

To avoid that the shell interprets the semicolons as the end of the command, place the \ escape character in front of the semicolons.

Both examples create base chains . To create a regular chain , do not set any parameters in the curly brackets.

Chain types

The following are the chain types and an overview with which address families and hooks you can use them:

Chain priorities

The priority parameter specifies the order in which packets traverse chains with the same hook value. You can set this parameter to an integer value or use a standard priority name.

The following matrix is an overview of the standard priority names and their numeric values, and with which address families and hooks you can use them:

Chain policies

The chain policy defines whether nftables should accept or drop packets if rules in this chain do not specify any action. You can set one of the following policies in a chain:

  • accept (default)

46.3.3. Basics of nftables rules

Rules define actions to perform on packets that pass a chain that contains this rule. If the rule also contains matching expressions, nftables performs the actions only if all previous expressions apply.

If you want to add a rule to a chain, the format to use depends on your firewall script:

This shell command appends the new rule at the end of the chain. If you prefer to add a rule at the beginning of the chain, use the nft insert command instead of nft add .

46.3.4. Managing tables, chains, and rules using nft commands

To manage an nftables firewall on the command line or in shell scripts, use the nft utility.

The commands in this procedure do not represent a typical workflow and are not optimized. This procedure only demonstrates how to use nft commands to manage tables, chains, and rules in general.

Create a table named nftables_svc with the inet address family so that the table can process both IPv4 and IPv6 packets:

Add a base chain named INPUT , that processes incoming network traffic, to the inet nftables_svc table:

To avoid that the shell interprets the semicolons as the end of the command, escape the semicolons using the \ character.

Add rules to the INPUT chain. For example, allow incoming TCP traffic on port 22 and 443, and, as the last rule of the INPUT chain, reject other incoming traffic with an Internet Control Message Protocol (ICMP) port unreachable message:

If you enter the nft add rule commands as shown, nft adds the rules in the same order to the chain as you run the commands.

Display the current rule set including handles:

Insert a rule before the existing rule with handle 3. For example, to insert a rule that allows TCP traffic on port 636, enter:

Append a rule after the existing rule with handle 3. For example, to insert a rule that allows TCP traffic on port 80, enter:

Display the rule set again with handles. Verify that the later added rules have been added to the specified positions:

Remove the rule with handle 6:

To remove a rule, you must specify the handle.

Display the rule set, and verify that the removed rule is no longer present:

Remove all remaining rules from the INPUT chain:

Display the rule set, and verify that the INPUT chain is empty:

Delete the INPUT chain:

You can also use this command to delete chains that still contain rules.

Display the rule set, and verify that the INPUT chain has been deleted:

Delete the nftables_svc table:

You can also use this command to delete tables that still contain chains.

To delete the entire rule set, use the nft flush ruleset command instead of manually deleting all rules, chains, and tables in separate commands.

  • nft(8) man page

46.4. Configuring NAT using nftables

With nftables , you can configure the following network address translation (NAT) types:

  • Source NAT (SNAT)

You can only use real interface names in iifname and oifname parameters, and alternative names ( altname ) are not supported.

46.4.1. NAT types

Masquerading and SNAT are very similar to one another. The differences are:

  • SNAT sets the source IP address of packets to a specified IP and does not dynamically look up the IP of the outgoing interface. Therefore, SNAT is faster than masquerading. Use SNAT if the outgoing interface uses a fixed IP address.

46.4.2. Configuring masquerading using nftables

Masquerading enables a router to dynamically change the source IP of packets sent through an interface to the IP address of the interface. This means that if the interface gets a new IP assigned, nftables automatically uses the new IP when replacing the source IP.

Replace the source IP of packets leaving the host through the ens3 interface to the IP set on ens3 .

Create a table:

Add the prerouting and postrouting chains to the table:

Even if you do not add a rule to the prerouting chain, the nftables framework requires this chain to match incoming packet replies.

Note that you must pass the -- option to the nft command to prevent the shell from interpreting the negative priority value as an option of the nft command.

Add a rule to the postrouting chain that matches outgoing packets on the ens3 interface:

46.4.3. Configuring source NAT using nftables

On a router, Source NAT (SNAT) enables you to change the IP of packets sent through an interface to a specific IP address. The router then replaces the source IP of outgoing packets.

Even if you do not add a rule to the postrouting chain, the nftables framework requires this chain to match outgoing packet replies.

Add a rule to the postrouting chain that replaces the source IP of outgoing packets through ens3 with 192.0.2.1 :

  • Forwarding incoming packets on a specific local port to a different host

46.4.4. Configuring destination NAT using nftables

Destination NAT (DNAT) enables you to redirect traffic on a router to a host that is not directly accessible from the internet.

For example, with DNAT the router redirects incoming traffic sent to port 80 and 443 to a web server with the IP address 192.0.2.1 .

Add a rule to the prerouting chain that redirects incoming traffic to port 80 and 443 on the ens3 interface of the router to the web server with the IP address 192.0.2.1 :

Depending on your environment, add either a SNAT or masquerading rule to change the source address for packets returning from the web server to the sender:

If the ens3 interface uses a dynamic IP addresses, add a masquerading rule:

If the ens3 interface uses a static IP address, add a SNAT rule. For example, if the ens3 uses the 198.51.100.1 IP address:

46.4.5. Configuring a redirect using nftables

The redirect feature is a special case of destination network address translation (DNAT) that redirects packets to the local machine depending on the chain hook.

For example, you can redirect incoming and forwarded traffic sent to port 22 of the local host to port 2222 .

Add the prerouting chain to the table:

Add a rule to the prerouting chain that redirects incoming traffic on port 22 to port 2222 :

46.4.6. Configuring flowtable by using nftables

The nftables utility uses the netfilter framework to provide network address translation (NAT) for network traffic and provides the fastpath feature-based flowtable mechanism to accelerate packet forwarding.

The flowtable mechanism has the following features:

  • Uses connection tracking to bypass the classic packet forwarding path.
  • Avoids revisiting the routing table by bypassing the classic packet processing.
  • Works only with TCP and UDP protocols.
  • Hardware independent software fast path.

Add an example-table table of inet family:

Add an example-flowtable flowtable with ingress hook and filter as a priority type:

Add an example-forwardchain flow to the flowtable from a packet processing table:

This command adds a flowtable of filter type with forward hook and filter priority.

Add a rule with established connection tracking state to offload example-flowtable flow:

Verify the properties of example-table :

46.5. Using sets in nftables commands

The nftables framework natively supports sets. You can use sets, for example, if a rule should match multiple IP addresses, port numbers, interfaces, or any other match criteria.

46.5.1. Using anonymous sets in nftables

An anonymous set contains comma-separated values enclosed in curly brackets, such as { 22, 80, 443 } , that you use directly in a rule. You can use anonymous sets also for IP addresses and any other match criteria.

The drawback of anonymous sets is that if you want to change the set, you must replace the rule. For a dynamic solution, use named sets as described in Using named sets in nftables .

  • The example_chain chain and the example_table table in the inet family exists.

For example, to add a rule to example_chain in example_table that allows incoming traffic to port 22 , 80 , and 443 :

Optional: Display all chains and their rules in example_table :

46.5.2. Using named sets in nftables

The nftables framework supports mutable named sets. A named set is a list or range of elements that you can use in multiple rules within a table. Another benefit over anonymous sets is that you can update a named set without replacing the rules that use the set.

When you create a named set, you must specify the type of elements the set contains. You can set the following types:

  • ipv4_addr for a set that contains IPv4 addresses or ranges, such as 192.0.2.1 or 192.0.2.0/24 .
  • ipv6_addr for a set that contains IPv6 addresses or ranges, such as 2001:db8:1::1 or 2001:db8:1::1/64 .
  • ether_addr for a set that contains a list of media access control (MAC) addresses, such as 52:54:00:6b:66:42 .
  • inet_proto for a set that contains a list of internet protocol types, such as tcp .
  • inet_service for a set that contains a list of internet services, such as ssh .
  • mark for a set that contains a list of packet marks. Packet marks can be any positive 32-bit integer value ( 0 to 2147483647 ).
  • The example_chain chain and the example_table table exists.

Create an empty set. The following examples create a set for IPv4 addresses:

To create a set that can store multiple individual IPv4 addresses:

To create a set that can store IPv4 address ranges:

To prevent the shell from interpreting the semicolons as the end of the command, you must escape the semicolons with a backslash.

Optional: Create rules that use the set. For example, the following command adds a rule to the example_chain in the example_table that will drop all packets from IPv4 addresses in example_set .

Because example_set is still empty, the rule has currently no effect.

Add IPv4 addresses to example_set :

If you create a set that stores individual IPv4 addresses, enter:

If you create a set that stores IPv4 ranges, enter:

When you specify an IP address range, you can alternatively use the Classless Inter-Domain Routing (CIDR) notation, such as 192.0.2.0/24 in the above example.

46.5.3. Additional resources

  • The Sets section in the nft(8) man page

46.6. Using verdict maps in nftables commands

Verdict maps, which are also known as dictionaries, enable nft to perform an action based on packet information by mapping match criteria to an action.

46.6.1. Using anonymous maps in nftables

An anonymous map is a { match_criteria : action } statement that you use directly in a rule. The statement can contain multiple comma-separated mappings.

The drawback of an anonymous map is that if you want to change the map, you must replace the rule. For a dynamic solution, use named maps as described in Using named maps in nftables .

For example, you can use an anonymous map to route both TCP and UDP packets of the IPv4 and IPv6 protocol to different chains to count incoming TCP and UDP packets separately.

Create a new table:

Create the tcp_packets chain in example_table :

Add a rule to tcp_packets that counts the traffic in this chain:

Create the udp_packets chain in example_table

Add a rule to udp_packets that counts the traffic in this chain:

Create a chain for incoming traffic. For example, to create a chain named incoming_traffic in example_table that filters incoming traffic:

Add a rule with an anonymous map to incoming_traffic :

The anonymous map distinguishes the packets and sends them to the different counter chains based on their protocol.

To list the traffic counters, display example_table :

The counters in the tcp_packets and udp_packets chain display both the number of received packets and bytes.

46.6.2. Using named maps in nftables

The nftables framework supports named maps. You can use these maps in multiple rules within a table. Another benefit over anonymous maps is that you can update a named map without replacing the rules that use it.

When you create a named map, you must specify the type of elements:

  • ipv4_addr for a map whose match part contains an IPv4 address, such as 192.0.2.1 .
  • ipv6_addr for a map whose match part contains an IPv6 address, such as 2001:db8:1::1 .
  • ether_addr for a map whose match part contains a media access control (MAC) address, such as 52:54:00:6b:66:42 .
  • inet_proto for a map whose match part contains an internet protocol type, such as tcp .
  • inet_service for a map whose match part contains an internet services name port number, such as ssh or 22 .
  • mark for a map whose match part contains a packet mark. A packet mark can be any positive 32-bit integer value ( 0 to 2147483647 ).
  • counter for a map whose match part contains a counter value. The counter value can be any positive 64-bit integer value.
  • quota for a map whose match part contains a quota value. The quota value can be any positive 64-bit integer value.

For example, you can allow or drop incoming packets based on their source IP address. Using a named map, you require only a single rule to configure this scenario while the IP addresses and actions are dynamically stored in the map.

Create a table. For example, to create a table named example_table that processes IPv4 packets:

Create a chain. For example, to create a chain named example_chain in example_table :

Create an empty map. For example, to create a map for IPv4 addresses:

Create rules that use the map. For example, the following command adds a rule to example_chain in example_table that applies actions to IPv4 addresses which are both defined in example_map :

Add IPv4 addresses and corresponding actions to example_map :

This example defines the mappings of IPv4 addresses to actions. In combination with the rule created above, the firewall accepts packet from 192.0.2.1 and drops packets from 192.0.2.2 .

Optional: Enhance the map by adding another IP address and action statement:

Optional: Remove an entry from the map:

Optional: Display the rule set:

46.6.3. Additional resources

  • The Maps section in the nft(8) man page

46.7. Example: Protecting a LAN and DMZ using an nftables script

Use the nftables framework on a RHEL router to write and install a firewall script that protects the network clients in an internal LAN and a web server in a DMZ from unauthorized access from the internet and from other networks.

This example is only for demonstration purposes and describes a scenario with specific requirements.

Firewall scripts highly depend on the network infrastructure and security requirements. Use this example to learn the concepts of nftables firewalls when you write scripts for your own environment.

46.7.1. Network conditions

The network in this example has the following conditions:

The router is connected to the following networks:

  • The internet through interface enp1s0
  • The internal LAN through interface enp7s0
  • The DMZ through enp8s0
  • The internet interface of the router has both a static IPv4 address ( 203.0.113.1 ) and IPv6 address ( 2001:db8:a::1 ) assigned.
  • The clients in the internal LAN use only private IPv4 addresses from the range 10.0.0.0/24 . Consequently, traffic from the LAN to the internet requires source network address translation (SNAT).
  • The administrator PCs in the internal LAN use the IP addresses 10.0.0.100 and 10.0.0.200 .
  • The DMZ uses public IP addresses from the ranges 198.51.100.0/24 and 2001:db8:b::/56 .
  • The web server in the DMZ uses the IP addresses 198.51.100.5 and 2001:db8:b::5 .
  • The router acts as a caching DNS server for hosts in the LAN and DMZ.

46.7.2. Security requirements to the firewall script

The following are the requirements to the nftables firewall in the example network:

The router must be able to:

  • Recursively resolve DNS queries.
  • Perform all connections on the loopback interface.

Clients in the internal LAN must be able to:

  • Query the caching DNS server running on the router.
  • Access the HTTPS server in the DMZ.
  • Access any HTTPS server on the internet.
  • The PCs of the administrators must be able to access the router and every server in the DMZ using SSH.

The web server in the DMZ must be able to:

  • Access HTTPS servers on the internet to download updates.

Hosts on the internet must be able to:

  • Access the HTTPS servers in the DMZ.

Additionally, the following security requirements exists:

  • Connection attempts that are not explicitly allowed should be dropped.
  • Dropped packets should be logged.

46.7.3. Configuring logging of dropped packets to a file

By default, systemd logs kernel messages, such as for dropped packets, to the journal. Additionally, you can configure the rsyslog service to log such entries to a separate file. To ensure that the log file does not grow infinitely, configure a rotation policy.

  • The rsyslog package is installed.
  • The rsyslog service is running.

Create the /etc/rsyslog.d/nftables.conf file with the following content:

Using this configuration, the rsyslog service logs dropped packets to the /var/log/nftables.log file instead of /var/log/messages .

Restart the rsyslog service:

Create the /etc/logrotate.d/nftables file with the following content to rotate /var/log/nftables.log if the size exceeds 10 MB:

The maxage 30 setting defines that logrotate removes rotated logs older than 30 days during the next rotation operation.

  • rsyslog.conf(5) man page
  • logrotate(8) man page

46.7.4. Writing and activating the nftables script

This example is an nftables firewall script that runs on a RHEL router and protects the clients in an internal LAN and a web server in a DMZ. For details about the network and the requirements for the firewall used in the example, see Network conditions and Security requirements to the firewall script .

This nftables firewall script is only for demonstration purposes. Do not use it without adapting it to your environments and security requirements.

  • The network is configured as described in Network conditions .

Create the /etc/nftables/firewall.nft script with the following content:

Include the /etc/nftables/firewall.nft script in the /etc/sysconfig/nftables.conf file:

Enable IPv4 forwarding:

Optional: Verify the nftables rule set:

Try to perform an access that the firewall prevents. For example, try to access the router using SSH from the DMZ:

Depending on your logging settings, search:

The systemd journal for the blocked packets:

The /var/log/nftables.log file for the blocked packets:

46.8. Configuring port forwarding using nftables

Port forwarding enables administrators to forward packets sent to a specific destination port to a different local or remote port.

For example, if your web server does not have a public IP address, you can set a port forwarding rule on your firewall that forwards incoming packets on port 80 and 443 on the firewall to the web server. With this firewall rule, users on the internet can access the web server using the IP or host name of the firewall.

46.8.1. Forwarding incoming packets to a different local port

You can use nftables to forward packets. For example, you can forward incoming IPv4 packets on port 8022 to port 22 on the local system.

Create a table named nat with the ip address family:

Pass the -- option to the nft command to prevent the shell from interpreting the negative priority value as an option of the nft command.

Add a rule to the prerouting chain that redirects incoming packets on port 8022 to the local port 22 :

46.8.2. Forwarding incoming packets on a specific local port to a different host

You can use a destination network address translation (DNAT) rule to forward incoming packets on a local port to a remote host. This enables users on the internet to access a service that runs on a host with a private IP address.

For example, you can forward incoming IPv4 packets on the local port 443 to the same port number on the remote system with the 192.0.2.1 IP address.

  • You are logged in as the root user on the system that should forward the packets.

Add a rule to the prerouting chain that redirects incoming packets on port 443 to the same port on 192.0.2.1 :

Add a rule to the postrouting chain to masquerade outgoing traffic:

46.9. Using nftables to limit the amount of connections

You can use nftables to limit the number of connections or to block IP addresses that attempt to establish a given amount of connections to prevent them from using too many system resources.

46.9.1. Limiting the number of connections using nftables

The ct count parameter of the nft utility enables administrators to limit the number of connections.

  • The base example_chain in example_table exists.

Create a dynamic set for IPv4 addresses:

Add a rule that allows only two simultaneous connections to the SSH port (22) from an IPv4 address and rejects all further connections from the same IP:

Optional: Display the set created in the previous step:

The elements entry displays addresses that currently match the rule. In this example, elements lists IP addresses that have active connections to the SSH port. Note that the output does not display the number of active connections or if connections were rejected.

46.9.2. Blocking IP addresses that attempt more than ten new incoming TCP connections within one minute

You can temporarily block hosts that are establishing more than ten IPv4 TCP connections within one minute.

Create the filter table with the ip address family:

Add the input chain to the filter table:

Add a rule that drops all packets from source addresses that attempt to establish more than ten TCP connections within one minute:

The timeout 5m parameter defines that nftables automatically removes entries after five minutes to prevent that the meter fills up with stale entries.

To display the meter’s content, enter:

46.10. Debugging nftables rules

The nftables framework provides different options for administrators to debug rules and if packets match them.

46.10.1. Creating a rule with a counter

To identify if a rule is matched, you can use a counter.

  • For more information about a procedure that adds a counter to an existing rule, see Adding a counter to an existing rule .
  • The chain to which you want to add the rule exists.

Add a new rule with the counter parameter to the chain. The following example adds a rule with a counter that allows TCP traffic on port 22 and counts the packets and traffic that match this rule:

To display the counter values:

46.10.2. Adding a counter to an existing rule

  • For more information about a procedure that adds a new rule with a counter, see Creating a rule with the counter .
  • The rule to which you want to add the counter exists.

Display the rules in the chain including their handles:

Add the counter by replacing the rule but with the counter parameter. The following example replaces the rule displayed in the previous step and adds a counter:

46.10.3. Monitoring packets that match an existing rule

The tracing feature in nftables in combination with the nft monitor command enables administrators to display packets that match a rule. You can enable tracing for a rule an use it to monitoring packets that match this rule.

Add the tracing feature by replacing the rule but with the meta nftrace set 1 parameters. The following example replaces the rule displayed in the previous step and enables tracing:

Use the nft monitor command to display the tracing. The following example filters the output of the command to display only entries that contain inet example_table example_chain :

Depending on the number of rules with tracing enabled and the amount of matching traffic, the nft monitor command can display a lot of output. Use grep or other utilities to filter the output.

46.11. Backing up and restoring the nftables rule set

You can backup nftables rules to a file and later restoring them. Also, administrators can use a file with the rules to, for example, transfer the rules to a different server.

46.11.1. Backing up the nftables rule set to a file

You can use the nft utility to back up the nftables rule set to a file.

To backup nftables rules:

In a format produced by nft list ruleset format:

In JSON format:

46.11.2. Restoring the nftables rule set from a file

You can restore the nftables rule set from a file.

To restore nftables rules:

If the file to restore is in the format produced by nft list ruleset or contains nft commands directly:

If the file to restore is in JSON format:

46.12. Additional resources

  • Using nftables in Red Hat Enterprise Linux 8
  • What comes after iptables? Its successor, of course: nftables
  • Firewalld: The Future is nftables

Chapter 47. Using xdp-filter for high-performance traffic filtering to prevent DDoS attacks

Compared to packet filters, such as nftables , Express Data Path (XDP) processes and drops network packets right at the network interface. Therefore, XDP determines the next step for the package before it reaches a firewall or other applications. As a result, XDP filters require less resources and can process network packets at a much higher rate than conventional packet filters to defend against distributed denial of service (DDoS) attacks. For example, during testing, Red Hat dropped 26 million network packets per second on a single core, which is significantly higher than the drop rate of nftables on the same hardware.

The xdp-filter utility allows or drops incoming network packets using XDP. You can create rules to filter traffic to or from specific:

  • IP addresses
  • MAC addresses

Note that, even if xdp-filter has a significantly higher packet-processing rate, it does not have the same capabilities as, for example, nftables . Consider xdp-filter a conceptual utility to demonstrate packet filtering using XDP. Additionally, you can use the code of the utility for a better understanding of how to write your own XDP applications.

On other architectures than AMD and Intel 64-bit, the xdp-filter 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.

47.1. Dropping network packets that match an xdp-filter rule

You can use xdp-filter to drop network packets:

  • To a specific destination port
  • From a specific IP address
  • From a specific MAC address

The allow policy of xdp-filter defines that all traffic is allowed and the filter drops only network packets that match a particular rule. For example, use this method if you know the source IP addresses of packets you want to drop.

  • The xdp-tools package is installed.

Load xdp-filter to process incoming packets on a certain interface, such as enp1s0 :

By default, xdp-filter uses the allow policy, and the utility drops only traffic that matches any rule.

Optionally, use the -f feature option to enable only particular features, such as tcp , ipv4 , or ethernet . Loading only the required features instead of all of them increases the speed of packet processing. To enable multiple features, separate them with a comma.

If the command fails with an error, the network driver does not support XDP programs.

Add rules to drop packets that match them. For example:

To drop incoming packets to port 22 , enter:

This command adds a rule that matches TCP and UDP traffic. To match only a particular protocol, use the -p protocol option.

To drop incoming packets from 192.0.2.1 , enter:

Note that xdp-filter does not support IP ranges.

To drop incoming packets from MAC address 00:53:00:AA:07:BE , enter:

Use the following command to display statistics about dropped and allowed packets:

  • xdp-filter(8) man page
  • If you are a developer and interested in the code of xdp-filter , download and install the corresponding source RPM (SRPM) from the Red Hat Customer Portal.

47.2. Dropping all network packets except the ones that match an xdp-filter rule

You can use xdp-filter to allow only network packets:

  • From and to a specific destination port
  • From and to a specific IP address
  • From and to specific MAC address

To do so, use the deny policy of xdp-filter which defines that the filter drops all network packets except the ones that match a particular rule. For example, use this method if you do not know the source IP addresses of packets you want to drop.

If you set the default policy to deny when you load xdp-filter on an interface, the kernel immediately drops all packets from this interface until you create rules that allow certain traffic. To avoid being locked out from the system, enter the commands locally or connect through a different network interface to the host.

  • You are logged in to the host either locally or using a network interface for which you do not plan to filter the traffic.

Load xdp-filter to process packets on a certain interface, such as enp1s0 :

Add rules to allow packets that match them. For example:

To allow packets to port 22 , enter:

This command adds a rule that matches TCP and UDP traffic. To match only a particular protocol, pass the -p protocol option to the command.

To allow packets to 192.0.2.1 , enter:

To allow packets to MAC address 00:53:00:AA:07:BE , enter:

The xdp-filter utility does not support stateful packet inspection. This requires that you either do not set a mode using the -m mode option or you add explicit rules to allow incoming traffic that the machine receives in reply to outgoing traffic.

  • xdp-filter(8) man page.
  • If you are a developer and you are interested in the code of xdp-filter , download and install the corresponding source RPM (SRPM) from the Red Hat Customer Portal.

Chapter 48. Getting started with DPDK

The data plane development kit (DPDK) provides libraries and network drivers to accelerate packet processing in user space.

Administrators use DPDK, for example, in virtual machines to use Single Root I/O Virtualization (SR-IOV) to reduce latencies and increase I/O throughput.

Red Hat does not support experimental DPDK APIs.

48.1. Installing the dpdk package

To use DPDK, install the dpdk package.

Use the yum utility to install the dpdk package:

48.2. Additional resources

  • Network Adapter Fast Datapath Feature Support Matrix

Chapter 49. Understanding the eBPF networking features in RHEL 8

The extended Berkeley Packet Filter (eBPF) is an in-kernel virtual machine that allows code execution in the kernel space. This code runs in a restricted sandbox environment with access only to a limited set of functions.

In networking, you can use eBPF to complement or replace kernel packet processing. Depending on the hook you use, eBPF programs have, for example:

  • Read and write access to packet data and metadata
  • Can look up sockets and routes
  • Can set socket options
  • Can redirect packets

49.1. Overview of networking eBPF features in RHEL 8

You can attach extended Berkeley Packet Filter (eBPF) networking programs to the following hooks in RHEL:

  • eXpress Data Path (XDP): Provides early access to received packets before the kernel networking stack processes them.
  • tc eBPF classifier with direct-action flag: Provides powerful packet processing on ingress and egress.
  • Control Groups version 2 (cgroup v2): Enables filtering and overriding socket-based operations performed by programs in a control group.
  • Socket filtering: Enables filtering of packets received from sockets. This feature was also available in the classic Berkeley Packet Filter (cBPF), but has been extended to support eBPF programs.
  • Stream parser: Enables splitting up streams to individual messages, filtering, and redirecting them to sockets.
  • SO_REUSEPORT socket selection: Provides a programmable selection of a receiving socket from a reuseport socket group.
  • Flow dissector: Enables overriding the way the kernel parses packet headers in certain situations.
  • TCP congestion control callbacks: Enables implementing a custom TCP congestion control algorithm.
  • Routes with encapsulation: Enables creating custom tunnel encapsulation.

Note that Red Hat does not support all of the eBPF functionality that is available in RHEL and described here. For further details and the support status of the individual hooks, see the RHEL 8 Release Notes and the following overview.

You can attach programs of the BPF_PROG_TYPE_XDP type to a network interface. The kernel then executes the program on received packets before the kernel network stack starts processing them. This allows fast packet forwarding in certain situations, such as fast packet dropping to prevent distributed denial of service (DDoS) attacks and fast packet redirects for load balancing scenarios.

You can also use XDP for different forms of packet monitoring and sampling. The kernel allows XDP programs to modify packets and to pass them for further processing to the kernel network stack.

The following XDP modes are available:

  • Native (driver) XDP: The kernel executes the program from the earliest possible point during packet reception. At this moment, the kernel did not parse the packet and, therefore, no metadata provided by the kernel is available. This mode requires that the network interface driver supports XDP but not all drivers support this native mode.
  • Generic XDP: The kernel network stack executes the XDP program early in the processing. At that time, kernel data structures have been allocated, and the packet has been pre-processed. If a packet should be dropped or redirected, it requires a significant overhead compared to the native mode. However, the generic mode does not require network interface driver support and works with all network interfaces.
  • Offloaded XDP: The kernel executes the XDP program on the network interface instead of on the host CPU. Note that this requires specific hardware, and only certain eBPF features are available in this mode.

On RHEL, load all XDP programs using the libxdp library. This library enables system-controlled usage of XDP.

Currently, there are some system configuration limitations for XDP programs. For example, you must disable certain hardware offload features on the receiving interface. Additionally, not all features are available with all drivers that support the native mode.

In RHEL 8.7, Red Hat supports the XDP feature only if all of the following conditions apply:

  • You load the XDP program on an AMD or Intel 64-bit architecture.
  • You use the libxdp library to load the program into the kernel.
  • The XDP program does not use the XDP hardware offloading.

Additionally, Red Hat provides the following usage of XDP features as unsupported Technology Preview:

  • Loading XDP programs on architectures other than AMD and Intel 64-bit. Note that the libxdp library is not available for architectures other than AMD and Intel 64-bit.
  • The XDP hardware offloading.

Using an XDP program that filters and redirects packets to a given AF_XDP socket, you can use one or more sockets from the AF_XDP protocol family to quickly copy packets from the kernel to the user space.

In RHEL 8.7, Red Hat provides this feature as an unsupported Technology Preview.

Traffic Control

The Traffic Control ( tc ) subsystem offers the following types of eBPF programs:

  • BPF_PROG_TYPE_SCHED_CLS
  • BPF_PROG_TYPE_SCHED_ACT

These types enable you to write custom tc classifiers and tc actions in eBPF. Together with the parts of the tc ecosystem, this provides the ability for powerful packet processing and is the core part of several container networking orchestration solutions.

In most cases, only the classifier is used, as with the direct-action flag, the eBPF classifier can execute actions directly from the same eBPF program. The clsact Queueing Discipline ( qdisc ) has been designed to enable this on the ingress side.

Note that using a flow dissector eBPF program can influence operation of some other qdiscs and tc classifiers, such as flower .

The eBPF for tc feature is fully supported in RHEL 8.2 and later.

Socket filter

Several utilities use or have used the classic Berkeley Packet Filter (cBPF) for filtering packets received on a socket. For example, the tcpdump utility enables the user to specify expressions, which tcpdump then translates into cBPF code.

As an alternative to cBPF, the kernel allows eBPF programs of the BPF_PROG_TYPE_SOCKET_FILTER type for the same purpose.

Control Groups

In RHEL, you can use multiple types of eBPF programs that you can attach to a cgroup. The kernel executes these programs when a program in the given cgroup performs an operation. Note that you can use only cgroups version 2.

The following networking-related cgroup eBPF programs are available in RHEL:

  • BPF_PROG_TYPE_SOCK_OPS : The kernel calls this program on various TCP events. The program can adjust the behavior of the kernel TCP stack, including custom TCP header options, and so on.
  • BPF_PROG_TYPE_CGROUP_SOCK_ADDR : The kernel calls this program during connect , bind , sendto , recvmsg , getpeername , and getsockname operations. This program allows changing IP addresses and ports. This is useful when you implement socket-based network address translation (NAT) in eBPF.
  • BPF_PROG_TYPE_CGROUP_SOCKOPT : The kernel calls this program during setsockopt and getsockopt operations and allows changing the options.
  • BPF_PROG_TYPE_CGROUP_SOCK : The kernel calls this program during socket creation, socket releasing, and binding to addresses. You can use these programs to allow or deny the operation, or only to inspect socket creation for statistics.
  • BPF_PROG_TYPE_CGROUP_SKB : This program filters individual packets on ingress and egress, and can accept or reject packets.
  • BPF_PROG_TYPE_CGROUP_SYSCTL : This program allows filtering of access to system controls ( sysctl ).
  • BPF_CGROUP_INET4_GETPEERNAME , BPF_CGROUP_INET6_GETPEERNAME , BPF_CGROUP_INET4_GETSOCKNAME , and BPF_CGROUP_INET6_GETSOCKNAME : Using these programs, you can override the result of getsockname and getpeername system calls. This is useful when you implement socket-based network address translation (NAT) in eBPF.

Stream Parser

A stream parser operates on a group of sockets that are added to a special eBPF map. The eBPF program then processes packets that the kernel receives or sends on those sockets.

The following stream parser eBPF programs are available in RHEL:

  • BPF_PROG_TYPE_SK_SKB : An eBPF program parses packets received from the socket into individual messages, and instructs the kernel to drop those messages or send them to another socket in the group.
  • BPF_PROG_TYPE_SK_MSG : This program filters egress messages. An eBPF program parses the packets into individual messages and either approves or rejects them.

SO_REUSEPORT socket selection

Using this socket option, you can bind multiple sockets to the same IP address and port. Without eBPF, the kernel selects the receiving socket based on a connection hash. With the BPF_PROG_TYPE_SK_REUSEPORT program, the selection of the receiving socket is fully programmable.

Flow dissector

When the kernel needs to process packet headers without going through the full protocol decode, they are dissected . For example, this happens in the tc subsystem, in multipath routing, in bonding, or when calculating a packet hash. In this situation the kernel parses the packet headers and fills internal structures with the information from the packet headers. You can replace this internal parsing using the BPF_PROG_TYPE_FLOW_DISSECTOR program. Note that you can only dissect TCP and UDP over IPv4 and IPv6 in eBPF in RHEL.

TCP Congestion Control

You can write a custom TCP congestion control algorithm using a group of BPF_PROG_TYPE_STRUCT_OPS programs that implement struct tcp_congestion_oops callbacks. An algorithm that is implemented this way is available to the system alongside the built-in kernel algorithms.

Routes with encapsulation

You can attach one of the following eBPF program types to routes in the routing table as a tunnel encapsulation attribute:

  • BPF_PROG_TYPE_LWT_IN
  • BPF_PROG_TYPE_LWT_OUT
  • BPF_PROG_TYPE_LWT_XMIT

The functionality of such an eBPF program is limited to specific tunnel configurations and does not allow creating a generic encapsulation or decapsulation solution.

Socket lookup

To bypass limitations of the bind system call, use an eBPF program of the BPF_PROG_TYPE_SK_LOOKUP type. Such programs can select a listening socket for new incoming TCP connections or an unconnected socket for UDP packets.

49.2. Overview of XDP features in RHEL 8 by network cards

The following is an overview of XDP-enabled network cards and the XDP features you can use with them:

  • Basic: Supports basic return codes: DROP , PASS , ABORTED , and TX .
  • Redirect: Supports the REDIRECT return code.
  • Target: Can be a target of a REDIRECT return code.
  • HW offload: Supports XDP hardware offload.
  • Zero-copy: Supports the zero-copy mode for the AF_XDP protocol family.

Chapter 50. Network tracing using the BPF compiler collection

BPF Compiler Collection (BCC) is a library, which facilitates the creation of the extended Berkeley Packet Filter (eBPF) programs. The main utility of eBPF programs is analyzing the operating system performance and network performance without experiencing overhead or security issues.

BCC removes the need for users to know deep technical details of eBPF, and provides many out-of-the-box starting points, such as the bcc-tools package with pre-created eBPF programs.

The eBPF programs are triggered on events, such as disk I/O, TCP connections, and process creations. It is unlikely that the programs should cause the kernel to crash, loop or become unresponsive because they run in a safe virtual machine in the kernel.

50.1. Installing the bcc-tools package

Install the bcc-tools package, which also installs the BPF Compiler Collection (BCC) library as a dependency.

Install bcc-tools .

The BCC tools are installed in the /usr/share/bcc/tools/ directory.

Optionally, inspect the tools:

The doc directory in the listing above contains documentation for each tool.

50.2. Displaying TCP connections added to the Kernel’s accept queue

After the kernel receives the ACK packet in a TCP 3-way handshake, the kernel moves the connection from the SYN queue to the accept queue after the connection’s state changes to ESTABLISHED . Therefore, only successful TCP connections are visible in this queue.

The tcpaccept utility uses eBPF features to display all connections the kernel adds to the accept queue. The utility is lightweight because it traces the accept() function of the kernel instead of capturing packets and filtering them. For example, use tcpaccept for general troubleshooting to display new connections the server has accepted.

Enter the following command to start the tracing the kernel accept queue:

Each time the kernel accepts a connection, tcpaccept displays the details of the connections.

  • Press Ctrl + C to stop the tracing process.
  • tcpaccept(8) man page
  • /usr/share/bcc/tools/doc/tcpaccept_example.txt file

50.3. Tracing outgoing TCP connection attempts

The tcpconnect utility uses eBPF features to trace outgoing TCP connection attempts. The output of the utility also includes connections that failed.

The tcpconnect utility is lightweight because it traces, for example, the connect() function of the kernel instead of capturing packets and filtering them.

Enter the following command to start the tracing process that displays all outgoing connections:

Each time the kernel processes an outgoing connection, tcpconnect displays the details of the connections.

  • tcpconnect(8) man page
  • /usr/share/bcc/tools/doc/tcpconnect_example.txt file

50.4. Measuring the latency of outgoing TCP connections

The TCP connection latency is the time taken to establish a connection. This typically involves the kernel TCP/IP processing and network round trip time, and not the application runtime.

The tcpconnlat utility uses eBPF features to measure the time between a sent SYN packet and the received response packet.

Start measuring the latency of outgoing connections:

Each time the kernel processes an outgoing connection, tcpconnlat displays the details of the connection after the kernel receives the response packet.

  • tcpconnlat(8) man page
  • /usr/share/bcc/tools/doc/tcpconnlat_example.txt file

50.5. Displaying details about TCP packets and segments that were dropped by the kernel

The tcpdrop utility enables administrators to display details about TCP packets and segments that were dropped by the kernel. Use this utility to debug high rates of dropped packets that can cause the remote system to send timer-based retransmits. High rates of dropped packets and segments can impact the performance of a server.

Instead of capturing and filtering packets, which is resource-intensive, the tcpdrop utility uses eBPF features to retrieve the information directly from the kernel.

Enter the following command to start displaying details about dropped TCP packets and segments:

Each time the kernel drops TCP packets and segments, tcpdrop displays the details of the connection, including the kernel stack trace that led to the dropped package.

  • tcpdrop(8) man page
  • /usr/share/bcc/tools/doc/tcpdrop_example.txt file

50.6. Tracing TCP sessions

The tcplife utility uses eBPF to trace TCP sessions that open and close, and prints a line of output to summarize each one. Administrators can use tcplife to identify connections and the amount of transferred traffic.

For example, you can display connections to port 22 (SSH) to retrieve the following information:

  • The local process ID (PID)
  • The local process name
  • The local IP address and port number
  • The remote IP address and port number
  • The amount of received and transmitted traffic in KB.
  • The time in milliseconds the connection was active

Enter the following command to start the tracing of connections to the local port 22 :

Each time a connection is closed, tcplife displays the details of the connections.

  • tcplife(8) man page
  • /usr/share/bcc/tools/doc/tcplife_example.txt file

50.7. Tracing TCP retransmissions

The tcpretrans utility displays details about TCP retransmissions, such as the local and remote IP address and port number, as well as the TCP state at the time of the retransmissions.

The utility uses eBPF features and, therefore, has a very low overhead.

Use the following command to start displaying TCP retransmission details:

Each time the kernel calls the TCP retransmit function, tcpretrans displays the details of the connection.

  • tcpretrans(8) man page
  • /usr/share/bcc/tools/doc/tcpretrans_example.txt file

50.8. Displaying TCP state change information

During a TCP session, the TCP state changes. The tcpstates utility uses eBPF functions to trace these state changes, and prints details including the duration in each state. For example, use tcpstates to identify if connections spend too much time in the initialization state.

Use the following command to start tracing TCP state changes:

Each time a connection changes its state, tcpstates displays a new line with updated connection details.

If multiple connections change their state at the same time, use the socket address in the first column ( SKADDR ) to determine which entries belong to the same connection.

  • tcpstates(8) man page
  • /usr/share/bcc/tools/doc/tcpstates_example.txt file

50.9. Summarizing and aggregating TCP traffic sent to specific subnets

The tcpsubnet utility summarizes and aggregates IPv4 TCP traffic that the local host sends to subnets and displays the output on a fixed interval. The utility uses eBPF features to collect and summarize the data to reduce the overhead.

By default, tcpsubnet summarizes traffic for the following subnets:

  • 127.0.0.1/32
  • 172.16.0.0/12
  • 192.0.2.0/24/16

Note that the last subnet ( 0.0.0.0/0 ) is a catch-all option. The tcpsubnet utility counts all traffic for subnets different than the first four in this catch-all entry.

Follow the procedure to count the traffic for the 192.0.2.0/24 and 198.51.100.0/24 subnets. Traffic to other subnets will be tracked in the 0.0.0.0/0 catch-all subnet entry.

Start monitoring the amount of traffic send to the 192.0.2.0/24 , 198.51.100.0/24 , and other subnets:

This command displays the traffic in bytes for the specified subnets once per second.

  • tcpsubnet(8) man page
  • /usr/share/bcc/tools/doc/tcpsubnet.txt file

50.10. Displaying the network throughput by IP address and port

The tcptop utility displays TCP traffic the host sends and receives in kilobytes. The report automatically refreshes and contains only active TCP connections. The utility uses eBPF features and, therefore, has only a very low overhead.

To monitor the sent and received traffic, enter:

The output of the command includes only active TCP connections. If the local or remote system closes a connection, the connection is no longer visible in the output.

  • tcptop(8) man page
  • /usr/share/bcc/tools/doc/tcptop.txt file

50.11. Tracing established TCP connections

The tcptracer utility traces the kernel functions that connect, accept, and close TCP connections. The utility uses eBPF features and, therefore, has a very low overhead.

Use the following command to start the tracing process:

Each time the kernel connects, accepts, or closes a connection, tcptracer displays the details of the connections.

  • tcptracer(8) man page
  • /usr/share/bcc/tools/doc/tcptracer_example.txt file

50.12. Tracing IPv4 and IPv6 listen attempts

The solisten utility traces all IPv4 and IPv6 listen attempts. It traces the listen attempts including that ultimately fail or the listening program that does not accept the connection. The utility traces function that the kernel calls when a program wants to listen for TCP connections.

Enter the following command to start the tracing process that displays all listen TCP attempts:

  • solisten(9) man page
  • /usr/share/bcc/tools/doc/solisten_example.txt file

50.13. Summarizing the service time of soft interrupts

The softirqs utility summarizes the time spent servicing soft interrupts (soft IRQs) and shows this time as either totals or histogram distributions. This utility uses the irq:softirq_enter and irq:softirq_exit kernel tracepoints, which is a stable tracing mechanism.

Enter the following command to start the tracing soft irq event time:

  • softirqs(8) man page
  • /usr/share/bcc/tools/doc/softirqs_example.txt file
  • mpstat(1) man page

50.14. Summarizing packets size and count on a network interface

The netqtop utility displays statistics about the attributes of received (RX) and transmitted (TX) packets on each network queue of a particular network interface. The statistics include:

  • Bytes per second (BPS)
  • Packets per second (PPS)
  • The average packet size
  • Total number of packets

To generate these statistics, netqtop traces the kernel functions that perform events of transmitted packets net_dev_start_xmit and received packets netif_receive_skb .

Display the number of packets within the range of bytes size of the time interval of 2 seconds:

  • Press Ctrl + C to stop netqtop .
  • netqtop(8) man page
  • /usr/share/bcc/tools/doc/netqtop_example.txt

50.15. Additional resources

  • /usr/share/doc/bcc/README.md

Chapter 51. Getting started with TIPC

Transparent Inter-process Communication (TIPC), which is also known as Cluster Domain Sockets , is an Inter-process Communication (IPC) service for cluster-wide operation.

Applications that are running in a high-available and dynamic cluster environment have special needs. The number of nodes in a cluster can vary, routers can fail, and, due to load balancing considerations, functionality can be moved to different nodes in the cluster. TIPC minimizes the effort by application developers to deal with such situations, and maximizes the chance that they are handled in a correct and optimal way. Additionally, TIPC provides a more efficient and fault-tolerant communication than general protocols, such as TCP.

51.1. The architecture of TIPC

TIPC is a layer between applications using TIPC and a packet transport service ( bearer ), and spans the level of transport, network, and signaling link layers. However, TIPC can use a different transport protocol as bearer, so that, for example, a TCP connection can serve as a bearer for a TIPC signaling link.

TIPC supports the following bearers:

  • UDP protocol

TIPC provides a reliable transfer of messages between TIPC ports, that are the endpoints of all TIPC communication.

The following is a diagram of the TIPC architecture:

TIPC architectural overview

51.2. Loading the tipc module when the system boots

Before you can use the TIPC protocol, you must load the tipc kernel module. You can configure Red Hat Enterprise Linux to automatically load this kernel module automatically when the system boots.

Create the /etc/modules-load.d/tipc.conf file with the following content:

Restart the systemd-modules-load service to load the module without rebooting the system:

Use the following command to verify that RHEL loaded the tipc module:

If the command shows no entry for the tipc module, RHEL failed to load it.

  • modules-load.d(5) man page

51.3. Creating a TIPC network

To create a TIPC network, perform this procedure on each host that should join the TIPC network.

The commands configure the TIPC network only temporarily. To permanently configure TIPC on a node, use the commands of this procedure in a script, and configure RHEL to execute that script when the system boots.

  • The tipc module has been loaded. For details, see Loading the tipc module when the system boots

Optional: Set a unique node identity, such as a UUID or the node’s host name:

The identity can be any unique string consisting of a maximum 16 letters and numbers.

You cannot set or change an identity after this step.

Add a bearer. For example, to use Ethernet as media and enp0s1 device as physical bearer device, enter:

  • Optional: For redundancy and better performance, attach further bearers using the command from the previous step. You can configure up to three bearers, but not more than two on the same media.
  • Repeat all previous steps on each node that should join the TIPC network.

Display the link status for cluster members:

This output indicates that the link between bearer enp1s0 on node 5254006b74be and bearer enp1s0 on node 525400df55d1 is up .

Display the TIPC publishing table:

  • The two entries with service type 0 indicate that two nodes are members of this cluster.
  • The entry with service type 1 represents the built-in topology service tracking service.
  • The entry with service type 2 displays the link as seen from the issuing node. The range limit 3741353223 represents the peer endpoint’s address (a unique 32-bit hash value based on the node identity) in decimal format.
  • tipc-bearer(8) man page
  • tipc-namespace(8) man page

51.4. Additional resources

Red Hat recommends to use other bearer level protocols to encrypt the communication between nodes based on the transport media. For example:

  • MACSec: See Using MACsec to encrypt layer 2 traffic
  • IPsec: See Configuring a VPN with IPsec
  • For examples of how to use TIPC, clone the upstream GIT repository using the git clone git://git.code.sf.net/p/tipc/tipcutils command. This repository contains the source code of demos and test programs that use TIPC features. Note that this repository is not provided by Red Hat.
  • /usr/share/doc/kernel-doc- <kernel_version> /Documentation/output/networking/tipc.html provided by the kernel-doc package.

Chapter 52. Automatically configuring network interfaces in public clouds using nm-cloud-setup

Usually, a virtual machine (VM) has only one interface that is configurable by DHCP. However, DHCP cannot configure VMs with multiple network entities, such as interfaces, IP subnets, and IP addresses. Additionally, you cannot apply settings when the VM instance is running. To solve this runtime configuration issue, the nm-cloud-setup utility automatically retrieves configuration information from the metadata server of the cloud service provider and updates the network configuration of the host. The utility automatically picks up multiple network interfaces, multiple IP addresses, or IP subnets on one interface and helps to reconfigure the network of the running VM instance.

52.1. Configuring and pre-deploying nm-cloud-setup

To enable and configure network interfaces in public clouds, run nm-cloud-setup as a timer and service.

On Red Hat Enterprise Linux On Demand and AWS golden images, nm-cloud-setup is already enabled and no action is required.

  • A network connection exists.

The connection uses DHCP.

By default, NetworkManager creates a connection profile which uses DHCP. If no profile was created because you set the no-auto-default parameter in /etc/NetworkManager/NetworkManager.conf , create this initial connection manually.

Install the nm-cloud-setup package:

Create and run the snap-in file for the nm-cloud-setup service:

Use the following command to start editing the snap-in file:

It is important to either start the service explicitly or reboot the system to make configuration settings effective.

Use the systemd snap-in file to configure the cloud provider in nm-cloud-setup . For example, to use Amazon EC2, enter:

You can set the following environment variables to enable the cloud provide you use:

  • NM_CLOUD_SETUP_AZURE for Microsoft Azure
  • NM_CLOUD_SETUP_EC2 for Amazon EC2 (AWS)
  • NM_CLOUD_SETUP_GCP for Google Cloud Platform(GCP)
  • NM_CLOUD_SETUP_ALIYUN for Alibaba Cloud (Aliyun)
  • Save the file and quit the editor.

Reload the systemd configuration:

Enable and start the nm-cloud-setup service:

Enable and start the nm-cloud-setup timer:

  • nm-cloud-setup(8) man page

52.2. Understanding the role of IMDSv2 and nm-cloud-setup in the RHEL EC2 instance

The instance metadata service (IMDS) in Amazon EC2 allows you to manage permissions to access instance metadata of a running Red Hat Enterprise Linux (RHEL) EC2 instance. The RHEL EC2 instance uses IMDS version 2 (IMDSv2), a session-oriented method. By using the nm-cloud-setup utility, administrators can reconfigure the network and automatically update the configuration of running RHEL EC2 instances. The nm-cloud-setup utility handles IMDSv2 API calls by using IMDSv2 tokens without any user intervention.

  • IMDS runs on a link-local address 169.254.169.254 for providing access to native applications on a RHEL EC2 instance.
  • After you have specified and configured IMDSv2 for each RHEL EC2 instance for applications and users, you can no longer access IMDSv1.
  • By using IMDSv2, the RHEL EC2 instance maintains metadata without using the IAM role while remaining accessible through the IAM role.
  • When the RHEL EC2 instance boots, the nm-cloud-setup utility automatically runs to fetch the EC2 instance API access token for using the RHEL EC2 instance API.

Use the IMDSv2 token as an HTTP header to check the details of the EC2 environment.

Legal Notice

Quick links.

  • Subscriptions
  • Support Cases
  • Customer Service
  • Product Documentation
  • Contact Customer Portal
  • Customer Portal FAQ
  • Log-in Assistance
  • Trust Red Hat
  • Browser Support Policy
  • Accessibility
  • Awards and Recognition

Related Sites

  • developers.redhat.com
  • connect.redhat.com
  • cloud.redhat.com

Systems Status

  • Red Hat Subscription Value
  • About Red Hat
  • Red Hat Jobs

Red Hat legal and privacy links

  • Contact Red Hat
  • Red Hat Blog
  • Diversity, equity, and inclusion
  • Cool Stuff Store
  • Red Hat Summit
  • Privacy statement
  • Terms of use
  • All policies and guidelines
  • Digital accessibility

IMAGES

  1. How to Set Static IP Address on RHEL 9

    set static ip rhel

  2. 3 Ways to Set a Static IP Address in RHEL 8

    set static ip rhel

  3. How to Set Static IP Address on RHEL 9

    set static ip rhel

  4. How to setup a static IP address on Centos 7 / RHEL 7

    set static ip rhel

  5. How to Set Static IP Address on RHEL 9

    set static ip rhel

  6. How to Configure Network Static IP Address on RHEL/CentOS 8/7

    set static ip rhel

VIDEO

  1. 02-how to add storage and set static IP address on TrueNas

  2. How to set static IP in windows PC #windows #windows10 #ipaddress #staticip

  3. How to set a Static IP Address

  4. Let's Configure Windows Server 2025 CORE

  5. How To Configure Static Ip In dlink Router

  6. How to Set Static ip Address in Windows

COMMENTS

  1. How to configure a static IP address on CentOS 7 / RHEL 7

    Verification. Verify new IP settings using the ip command for the NIC named eth0: # ip a s eth0. Verify new routing settings: # ip r. Next, verify DNS servers settings using the cat command or grep command to query the /etc/resolv.conf file as follows: # cat /etc/resolv.conf. Finally verify the internet connectivity using the ping command:

  2. How to configure a static IP address on RHEL 8 / CentOS 8 ...

    In this tutorial we learn how to set a static IP address for a network interface in RHEL 8 / CentOS 8. We show three methods to perform said action: by manually editing a connection file, by using the nmcli command line utility, and finally by using nmtui, a text-user interface.

  3. 3.6. Configuring IP Networking with ip Commands Red Hat ...

    The package name in Red Hat Enterprise Linux 7 is iproute. If necessary, you can check that the ip utility is installed by checking its version number as follows: ~]$ ip -V. ip utility, iproute2-ss130716. The ip commands can be used to add and remove addresses and routes to interfaces in parallel with NetworkManager, which will preserve them ...

  4. 3 Ways to Set a Static IP Address in RHEL 8 - Tecmint

    Verify IP Address 3. How to Configure Static IP Using Nmcli Tool. Nmcli is a NetworkManager command line interface that can be used for obtaining information or configuring a network interface. If you want to set a static IP address, you can use the following options: Set the IP address for interface enp0s3 on RHEL 8.

  5. How to Set Static IP Address on RHEL 9 - LinuxTechi

    To set static ip address using nmtui, run following command, $ sudo nmtui. It will start the text-based interface, Choose ‘ Edit a connection ’ and hit enter, Select the interface (in my case it is enp0s3) and then choose edit and press enter, In the following screen, change IPv4 Configuration from Automatic to Manual.

  6. Configuring and managing networking Red Hat Enterprise Linux ...

    2.6. Configuring an Ethernet connection with a static IP address by using nmstatectl 2.7. Configuring an Ethernet connection with a static IP address by using the network RHEL System Role with an interface name 2.8. Configuring an Ethernet connection with a static IP address by using the network RHEL System Role with a device path 2.9.

  7. Manual Network Configuration in Linux and How to Set a Static ...

    a specific IP address; full control over the address assignment; Since the Dynamic Host Configuration Protocol (DHCP) can take the Media Access Control (MAC) address into account when assigning the network-layer address, we might still automatically receive the same IP on each connection with that protocol.

  8. Configuring network interface with Static IP address on RHEL 7

    How to add static route with netplan on Ubuntu 22.04 Jammy… How to Use a Bash Script to Run Your Python Scripts; Configuring VNC Server Access on a Redhat Linux; Handling User Input in Bash Scripts; Setting a Static IP Address in Ubuntu 24.04 via the Command… Linux Configuration files: Top 30 most important; Mastering Bash Script Loops

  9. How to Configure Network Static IP Address on RHEL/CentOS 8/7

    Configure IP Address in CentOS 8. 10. After finishing editing the file, close it, and move to resolv.conf file if you want DNS servers enabled system-wide. # nano /etc/resolv.conf. Here just add your DNS servers using nameserver statement. nameserver 192.168.1.1. nameserver 8.8.8.8. 11.