Bookmark this page

Edit Network Configuration Files

Objectives

  • Modify network configuration by editing configuration files.

Connection Configuration Files

Starting with Red Hat Enterprise Linux 8, network configurations are stored in the /etc/NetworkManager/system-connections/ directory. This configuration location uses the key file format instead of the ifcfg format. However, the previously stored configurations at /etc/sysconfig/network-scripts/ continue to work. The /etc/NetworkManager/system-connections/ directory stores any changes with the nmcli con mod name command.

Key File Format

The NetworkManager uses the INI-style key format for storing network connection profiles. The key-value pairs store configurations as sections (groups). Each configuration key/value pair in the section is one of the listed properties in the settings specification. This configuration file stores most of the settings in the same format as the INI-style format. For example, writing IP addresses as 192.168.0.1/24 is easier to read than as integer arrays.

Although the recommended way to manage profiles is with the nmcli command, users might still manually create or modify the configuration files. After editing the configuration file, run the nmcli con reload command to inform NetworkManager about these changes.

Table 13.2. Comparison of NetworkManager Settings and Key File Format File

nmcli con mod *.nmconnection fileEffect
ipv4.method manual

[ipv4]

method=manual

Configure IPv4 addresses statically.
ipv4.method auto

[ipv4]

method=auto

Look for configuration settings from a DHCPv4 server. It shows static addresses only when it has information from DHCPv4.
ipv4.addresses 192.0.2.1/24

[ipv4]

address1=192.0.2.1/24

Set a static IPv4 address and network prefix. For more than one connection address, the address2 key defines the second address, and the address3 key defines the third address.
ipv4.gateway 192.0.2.254

[ipv4]

gateway=192.0.2.254

Set the default gateway.
ipv4.dns 8.8.8.8

[ipv4]

dns=8.8.8.8

Modify /etc/resolv.conf to use this name server.
ipv4.dns-search example.com

[ipv4]

dns-search=example.com

Modify /etc/resolv.conf to use this domain in the search directive.
ipv4.ignore-auto-dns true

[ipv4]

ignore-auto-dns=true

Ignore DNS server information from the DHCP server.
ipv6.method manual

[ipv6]

method=manual

Configure IPv6 addresses statically.
ipv6.method auto

[ipv6]

method=auto

Configure network settings with SLAAC from router advertisements.
ipv6.method dhcp

[ipv6]

method=dhcp

Configure network settings by using DHCPv6, but not by using SLAAC.
ipv6.addresses 2001:db8::a/64

[ipv6]

address1=2001:db8::a/64

Set a static IPv6 address and network prefix. When using more than one address for a connection, the address2 key defines the second address, and the address3 key defines the third address.
ipv6.gateway 2001:db8::1

[ipv6]

gateway=2001:db8::1

Set the default gateway.
ipv6.dns fde2:6494:1e09:2::d

[ipv6]

dns=fde2:6494:1e09:2::d

Modify /etc/resolv.conf to use this name server. The same as IPv4.
ipv6.dns-search example.com

[ipv6]

dns-search=example.com

Modify /etc/resolv.conf to use this domain in the search directive.
ipv6.ignore-auto-dns true

[ipv6]

ignore-auto-dns=true

Ignore DNS server information from the DHCP server.
connection.autoconnect yes

[connection]

autoconnect=true

Automatically activate this connection at boot.
connection.id ens3

[connection]

id=Main eth0

The name of this connection.
connection.interface-name ens3

[connection]

interface-name=ens3

The connection is bound to the network interface with this name.
802-3-ethernet.mac-address …​

[802-3-ethernet]

mac-address=

The connection is bound to the network interface with this MAC address.

Modify Network Configuration

You can also configure the network by directly editing the connection configuration files. Connection configuration files control the software interfaces for individual network devices. These files are usually called /etc/NetworkManager/system-connections/name.nmconnection, where name refers to the device's name or connection that the configuration file controls.

Depending on the purpose of the connection profile, NetworkManager uses the following directories to store the configuration files:

  • The /etc/NetworkManager/system-connections/ directory stores persistent profiles that the user created and edited. NetworkManager copies them automatically to the /etc/NetworkManager/system-connections/ directory.

  • The /run/NetworkManager/system-connections/ directory stores temporary profiles, which are automatically removed when you reboot the system.

  • The /usr/lib/NetworkManager/system-connections/ directory stores predeployed immutable profiles. When you edit such a profile with the NetworkManager API, NetworkManager copies this profile to either the persistent or the temporary storage.

Sample configuration file content for static IPv4 configuration:

[connection]
id=Main eth0
uuid=27afa607-ee36-43f0-b8c3-9d245cdc4bb3
type=802-3-ethernet
autoconnect=true

[ipv4]
method=manual

[802-3-ethernet]
mac-address=00:23:5a:47:1f:71

Table 13.3. IPv4 Configuration Options for Key File Format

Static Dynamic Either

[ipv4]

address1=172.25.0.10/24

gateway=172.25.0.254

dns=172.25.254.254

method=auto

[connection]

interface-name=ens3

id=Main eth0

autoconnect=true

uuid=f3e8(…​)ad3e

type=ethernet


After you modify the configuration files, run the nmcli con reload command so that NetworkManager loads the configuration changes. If the autoconnect variable is set to false in the connection profile, then activate the connection manually.

[root@host ~]# nmcli con reload
[root@host ~]# nmcli con up "static-ens3"

References

nmcli(1), nm-settings(5), and nm-settings-keyfile(5) man page

For more information, refer to the Manually Creating NetworkManager Profiles in Key File Format at https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html-single/configuring_and_managing_networking/assembly_manually-creating-networkmanager-profiles-in-key-file-format_configuring-and-managing-networking

Revision: rh199-9.3-8dd73db