12.07.2015 Views

Red Hat Enterprise Linux 5 Administration Unleashed

Red Hat Enterprise Linux 5 Administration Unleashed

Red Hat Enterprise Linux 5 Administration Unleashed

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Network Configuration 67The /etc/hosts file lists IP addresses and hostnames that should resolve to the IPaddresses as shown in Listing 2.3. The first one listed, 127.0.0.1, is referred to as the loopbackinterface and should never be removed. If some hostnames can not be resolved bythe DNS servers, list them with their IP addresses after the loopback device. For example,if your network only consists of a handful of systems, it might be easier to list them inthe /etc/hosts file on each local system than set up a DNS server on the local networkfor name resolution.2CAUTIONBe careful when listing hostnames that can be resolved by the DNS servers and thosethat are not under your control. If the IP address of the hostname changes, you willnot be able to connect to the host because any IP addresses listed in /etc/hostshave precedence over any IP addresses resolved through the DNS servers.LISTING 2.3/etc/hosts# Do not remove the following line, or various programs# that require network functionality will fail.127.0.0.1 localhost.localdomain localhost192.168.0.1 metropolis192.168.0.2 lois182.168.0.3 clarkkentA typical /etc/resolv.conf is shown in Listing 2.4. Each nameserver line represents aDNS server, and the search line specifies domain names to try if only the first part of ahostname is used. For example, if just the name smallville is used as a hostname, smallville.example.comand then smallville.example.org will be tried if the /etc/resolv.conffile in Listing 2.4 is on the system.LISTING 2.4/etc/resolv.confnameserver 192.168.0.254nameserver 192.168.10.254search example.com example.orgIn the /etc/sysconfig/network-scripts/ directory, each network device has its ownconfiguration file with the filename ifcfg- such as ifcfg-eth0 for the firstEthernet device.If the device uses DHCP to retrieve network settings, a typical /etc/sysconfig/networkscripts/ifcfg-eth0file contains the lines from Listing 2.5. If the device is configured fora static IP address, the interface configuration file looks similar to Listing 2.6.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!