Chapter 27. Configuring ip networking with ifcfg files
This section describes how to configure a network interface manually by editing the 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 usually named ifcfg-name
, 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.
27.1. Configuring an interface with static network settings using ifcfg files
This procedure describes how to configure a network interface using ifcfg
files.
Procedure
To configure an interface with static network settings using
ifcfg
files, for an interface with the nameenp1s0
, create a file with the nameifcfg-enp1s0
in the/etc/sysconfig/network-scripts/
directory that contains:For
IPv4
configuration:DEVICE=enp1s0 BOOTPROTO=none ONBOOT=yes PREFIX=24 IPADDR=10.0.1.27 GATEWAY=10.0.1.1
For
IPv6
configuration:DEVICE=enp1s0 BOOTPROTO=none ONBOOT=yes IPV6INIT=yes IPV6ADDR=2001:db8:1::2/64
Additional resources
- For more information on testing connections, see Chapter 39, Testing basic network settings.
-
For more
IPv6
ifcfg configuration options, see nm-settings-ifcfg-rh(5) man page.
27.2. Configuring an interface with dynamic network settings using ifcfg files
This procedure describes how to configure a network interface with dynamic network settings using ifcfg
files.
Procedure
To configure an interface named em1 with dynamic network settings using
ifcfg
files, create a file with the nameifcfg-em1
in the/etc/sysconfig/network-scripts/
directory that contains:DEVICE=em1 BOOTPROTO=dhcp ONBOOT=yes
To configure an interface to send a different host name to the
DHCP
server, add the following line to theifcfg
file:DHCP_HOSTNAME=hostname
To configure an interface to send a different fully qualified domain name (FQDN) to the
DHCP
server, add the following line to theifcfg
file:DHCP_FQDN=fully.qualified.domain.name
NoteOnly one directive, either
DHCP_HOSTNAME
orDHCP_FQDN
, should be used in a givenifcfg
file. In case bothDHCP_HOSTNAME
andDHCP_FQDN
are specified, only the latter is used.To configure an interface to use particular
DNS
servers, add the following lines to theifcfg
file:PEERDNS=no DNS1=ip-address DNS2=ip-address
where ip-address is the address of a
DNS
server. This will cause the network service to update/etc/resolv.conf
with the specifiedDNS
servers specified. Only oneDNS
server address is necessary, the other is optional.
27.3. Managing system-wide and private connection profiles with ifcfg files
This procedure describes how to configure ifcfg
files to manage the system-wide and private connection profiles.
Procedure
The permissions correspond to the USERS
directive in the ifcfg
files. If the USERS
directive is not present, the network profile will be available to all users.
As an example, modify the
ifcfg
file with the following row, which will make the connection available only to the users listed:USERS="joe bob alice"