The /etc/hosts file lists IP addresses and hostnames that should resolve to the IPaddresses as shown. The first one listed, 127.0.0.1, is referred to as the loopback interface and should never be removed. If some hostnames are not resolved by the DNS servers, list them with their IP addresses after the loopback device. For example, if your network consists only of a handful of systems, it might be easier to list them in the /etc/hosts file on each local system than set up a DNS server on the local network for name resolution.
CAUTION
Always be careful when listing hostnames that can be resolved by the DNS servers and those that are not under your control. If the IP address of the hostname changes, you will not be able to connect to the host because any IP addresses listed in /etc/hosts have precedence over any IP addresses resolved through the DNS servers.
/etc/hosts File
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.0.1 metropolis
192.168.0.2 louis
182.168.0.3 clark
A typical /etc/resolv.conf is shown below. Each nameserver line represents a
DNS server, and the search line specifies domain names to try if only the first part of a hostname is used. For example, if just the name infinity is used as a hostname, infinity.example.com and then infinity.example.org will be tried if the /etc/resolv.conf file in Listing 2.4 is on the system.
/etc/resolv.conf File
nameserver 192.168.0.254
nameserver 192.168.10.254
search example.com example.org
In the /etc/sysconfig/network-scripts/ directory, each network device has its own
configuration file with the filename ifcfg-
If the device uses DHCP to retrieve network settings, a typical /etc/sysconfig/networkscripts/ifcfg-eth0 file contains the lines as shown below.
Ethernet Interface Configuration File for DHCP
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
If the device is configured for a static IP address, the interface configuration file looks similar to
Ethernet Interface Configuration File for Static IP
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
NETWORK=192.168.1.0
NETMASK=255.255.255.0
IPADDR=192.168.1.15
USERCTL=no
If the ONBOOT option is set to yes, the device is activated at boot time using the network initialization script. Other device names include lo for the local loopback device, pppX for dialup interfaces, and irlanX for infrared devices where X is the device number starting with 0. Refer to the file /usr/share/doc/initscripts-
the files in this directory.
RELATED POSTS:-
Post a Comment