11.2 About Network Configuration Files

11.2.1 /etc/hosts
11.2.2 /etc/nsswitch.conf
11.2.3 /etc/resolv.conf
11.2.4 /etc/sysconfig/network

The following sections describe additional network configuration files that you might need to configure on a system.

11.2.1 /etc/hosts

The /etc/hosts file associates host names with IP addresses. It allows the system to look up (resolve) the IP address of a host given its name, or the name given the UP address. Most networks use DNS (Domain Name Service) to perform address or name resolution. Even if your network uses DNS, it is usual to include lines in this file that specify the IPv4 and IPv6 addresses of the loopback device, for example:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

The first and second column contains the IP address and host name. Additional columns contain aliases for the host name.

For more information, see the hosts(5) manual page.

11.2.2 /etc/nsswitch.conf

The /etc/nsswitch.conf file configures how the system uses various databases and name resolution mechanisms. The first field of entries in this file identifies the name of the database. The second field defines a list of resolution mechanisms in the order in which the system attempts to resolve queries on the database.

The following example hosts definition from /etc/nsswitch.conf indicates that the system first attempts to resolve host names and IP addresses by querying files (that is, /etc/hosts) and, if that fails, next by querying a DNS server, and last of all, by querying NIS+ (NIS version 3) :

hosts:      files dns nisplus

For more information, see the nsswitch.conf(5) manual page.

11.2.3 /etc/resolv.conf

The /etc/resolv.conf file defines how the system uses DNS to resolve host names and IP addresses. This file usually contains a line specifying the search domains and up to three lines that specify the IP addresses of DNS server. The following entries from /etc/resolv.conf configure two search domains and three DNS servers:

search us.mydomain.com mydomain.com
nameserver 192.168.154.3
nameserver 192.168.154.4
nameserver 10.216.106.3

If your system obtains its IP address from a DHCP server, it is usual for the system to configure the contents of this file with information also obtained using DHCP.

For more information, see the resolv.conf(5) manual page.

11.2.4 /etc/sysconfig/network

The /etc/sysconfig/network file specifies additional information that is valid to all network interfaces on the system. The following entries from /etc/sysconfig/network define that IPv4 networking is enabled, IPv6 networking is not enabled, the host name of the system, and the IP address of the default network gateway:

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=host20.mydomain.com
GATEWAY=192.168.1.1

For more information, see /usr/share/doc/initscripts*/sysconfig.txt.