Network Configuration Files July 13 Network Configuration Files: o All network configuration data is stored within a series of text files in the /etc directory. Below is a list of some of the basic network configuration files: /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network /etc/networks /etc/hosts /etc/resolv.conf /etc/host.conf Basic Networking Files: o The /etc/sysconfig/network-scripts/ifcfg-eth0 file is used to store information about the configuration of your network interface card. Below are the default contents of the file: DEVICE=eth0 BOOTPROTO=static ONBOOT=no The DEVICE variable is set to store the device name. The BOOTPROTO variable is set to static because the NIC information is not to change. The ONBOOT variable is set to no, so this information will not be loaded at bootup. You may further configure the NIC by adding the following information: BROADCAST=192.168.208.255 IPADDR=192.168.208.1 NETMASK=255.255.255.0 NETWORK=192.168.208.0 o The /etc/sysconfig/network file is used to feeds information to many of the other network configuration files. Below are the default contents of the file: NETWORKING=yes HOSTNAME=localhost.localdomain Because our computer are set to boot to run level 3 (command-line networking), the NETWOKING directive is set to yes. By default, the HOSTNAME of our computer is localhost.localdomain. Name Resolution Files: o Because it easier to remember the name of a computer as opposed to an IP address, the process of name resolution is very important. There are a series of files that are used by Linux to do this. o The /etc/networks file is used to associate network names with network IP addresses. This file doesn’t exist by default. If it did exist, it might look something like this: loopnet 127.0.0.0 rm208net 192.168.208.0 The 127.0.0.0 network is assigned a name of loopnet, and the 192.168.208.0 is assigned a name of rm208net. o The /etc/hosts file is used to associate a computer name with an IP address. Used to speed up the IP address lookup of frequently requested addresses. The default contents of the file look similar to this: 127.0.0.1 192.168.208.17 localhost.localdomain localhost teacher The loopback device is assigned a name of localhost.localdomain or localhost. The computer with an IP address of 192.168.208.17 is assigned a name of teacher. o Since there are billions of IP addresses in the world, we can’t possibly type in an entry into out /etc/hosts file for every IP address in the world. Therefore, we need to be able to connect to DNS servers to find IP addresses. The domain name server (DNS) contains a big database of computer names that are associated with IP addresses. o The /etc/resolv.conf file configures your computer to connect to a DNS Server; contains the addresses of the DNS server. Below is a sample of what this file might look like. nameserver 192.168.208.25 nameserver 192.168.208.33 When resolving a computer name to an IP address, the system will connect to a DNS server located at 192.168.208.25. If the computer name is not found at this DNS server, then it will connect to the DNS server at 192.168.208.33. o The /etc/host.conf file specifies whether the local /etc/host file or a DNS server will be searched first when looking up a computer name. Below is a sample of what this file might look like. order hosts, bind Due to the contents of this file, the system will look up computer names first in the /etc/hosts file, and then look up the DNS Server. By the way, bind is the name of the most popular DNS program in Linux. BIND stands for Berkeley Internet Name Domain. Name Resolution Example: /etc/hosts /etc/resolv.conf 127.0.0.1 localhost nameserver 192.168.10.25 192.168.208.1 comp1 nameserver 192.168.10.33 192.168.208.2 comp2 DNS listings at 192.168.208.25 /etc/host.conf 192.168.208.3 comp3 192.168.208.4 comp4 order hosts, bind DNS listings at 192.168.208.25 192.168.208.91 comp1 192.168.208.5 comp5 192.168.208.27 comp27 Here’s an example. Assume that you enter the following command: ping comp27 o Your system will look first at its /etc/host.conf file to see where it should look first. Looking at the file above, it will look at the /etc/hosts file first. o There is no listing for comp27 in the /etc/hosts file. Therefore, your system will have to look at the /etc/resolv.conf file in order to find a DNS. o The first DNS is located at 192.168.208.25. Your computer will then send a request to search the listings at this DNS. However, there is no listing for comp27 here. o The next DNS is located at 192.168.208.33. Therefore, your computer will then send a request to search the listings at this DNS. There is a listing for comp27 here and the IP address, 192.168.208.27, is returned. Routing Table Entries: o There is no good network configuration file to permanently add entries to the routing table. Here’s a good work-around. o Remember that the /etc/profile file stores scripts, variables, and commands that executed when any user logs in. o We can add a route add command to the end of the /etc/profile file. Therefore, every time a user logs in, the routing entry will be added to the routing table.