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

25.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 name enp1s0, create a file with the name ifcfg-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

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

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

    DEVICE=em1
    BOOTPROTO=dhcp
    ONBOOT=yes
  2. To configure an interface to send a different host name to the DHCP server, add the following line to the ifcfg file:

    DHCP_HOSTNAME=hostname
  3. To configure an interface to send a different fully qualified domain name (FQDN) to the DHCP server, add the following line to the ifcfg file:

    DHCP_FQDN=fully.qualified.domain.name
    Note

    Only one directive, either DHCP_HOSTNAME or DHCP_FQDN, should be used in a given ifcfg file. In case both DHCP_HOSTNAME and DHCP_FQDN are specified, only the latter is used.

  4. To configure an interface to use particular DNS servers, add the following lines to the ifcfg 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 specified DNS servers specified. Only one DNS server address is necessary, the other is optional.

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

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