Commonly Used Networking Files

 < Day Day Up > 

There isn't really any "procedure" associated with networking. Networking is more of a matter of knowing commands and files associated with networking than it is a step-by-step endeavor, so this section covers most common networking commands and files. First, some commonly used files are covered so you can see the type of networking parameters you define. Then you'll look at graphical tools that you can use to define these parameters. Finally, this section covers commands that you can issue from the command line to view and set networking-related parameters.

ifcfg-eth0

You can define the parameters related to a network interface card easily with the ifcfg file for the card. The file ifcfg-eth0 is usually the first network card on Red Hat systems. This file is in /etc/sysconfig/network-scripts along with a lot of other networking files beginning with if. The interface device files, such as ifcfg-eth0 are usually named ifcfg-device where device is the name of the device for which control will be specified in the configuration file.The contents of this file are shown here for the system used in many of the examples in this chapter:

 # pwd /etc/sysconfig/network-scripts # cat ifcfg-eth0 DEVICE=eth0 BOOTPROTO=static BROADCAST=192.168.1.255 IPADDR=192.168.1.102 NETMASK=255.255.255.0 NETWORK=192.168.1.0 ONBOOT=yes # 

This file has in it all the important information related to the interface, such as IPADDR, DEVICE, NETMASK, and so on.

You can edit this file directly, using the command line with ifconfig as described shortly, or use neat, webmin, or netconf to define the information for eth0 or any other interface. (Keep in mind that not all graphical tools are available on Integrity yet.)

If you were to use DHCP, the file might look like the following:

 DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes 

The following describes the entries shown in the ifcfg-device file:

BOOTPROTO=protocol, where protocol is one of the following:

none No boot-time protocol should be used.

bootp The BOOTP protocol should be used.

dhcp The DHCP protocol should be used.

BROADCAST=address, where address is the broadcast address.

DEVICE=name, where name is the name of the physical device.

IPADDR=address, where address is the IP address.

NETMASK=mask, where mask is the netmask value.

NETWORK=address, where address is the network address.

ONBOOT=answer, where answer is one of the following:

yes This device should be activated at boot-time.

no This device should not be activated at boot-time.

USERCTL=answer, where answer is one of the following:

true Non-root users are allowed to control this device.

false Non-root users are not allowed to control this device.

There is also a loopback device in this directory called ifcfg-lo, which has the following contents:

 # more /etc/sysconfig/network-scripts/ifcfg-lo DEVICE=lo IPADDR=127.0.0.1 NETMASK=255.0.0.0 NETWORK=127.0.0.0 # If you're having problems with gated making 127.0.0.0/8 a martian, # you can change this to anything (255.255.255.255, for example) BROADCAST=127.255.255.255 ONBOOT=yes NAME=loopback # 

The address of 127.0.0.1 is a special address know as the loopback. This is for an IP host to refer to itself. A local loopback interface is often used in testing, as well as a variety of applications that require an IP address pointing back to the same system. Any data sent to the loopback device is immediately returned to the host's network layer.

You can find a lot of information about these scripts in /usr/share/doc/initscripts and ssyconfig.txt.

/etc/sysconfig/network

The file /etc/sysconfig/network has in it information about the network configuration. The file contains information such as the following:

NETWORKING Set to yes or no depending on whether you want networking configured.

HOSTNAME The hostname, such as m4415mxp.

GATEWAY The address of the gateway.

GATEWAYDEV The gateway device, such as eth0.

NISDOMAIN=value, where value is the NIS domain name.

The following is an example network file:

 # cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=m4415mxp GATEWAY=15.32.160.1 # 

/etc/hosts

The /etc/hosts file contains the Internet Protocol (IP) hostnames and addresses for the local host and other hosts in the Internet network. This file is used to translate a hostname into its Internet address or what is called resolve the hostname. When your system is using a name server, the file is accessed only if the name server cannot resolve the hostname. You may be using the DOMAIN protocol on your Linux system in which case the resolver routines query a remote DOMAIN name server before searching this file. In a flat network with no name server, the resolver routines search this file for hostname and address data. This file contains information about the other systems to which you are connected. It contains the Internet address of each system, the system name, and any aliases for the system name. The format of the file is simple as shown in the following example:

 127.0.0.1     localhostloopback 15.32.199.42  a4410827 15.32.199.28  a4410tu8 15.32.199.7   a4410922 15.32.199.21  a4410tu1 15.32.199.22  a4410tu2 15.32.199.62  a4410730 15.32.199.63  hpxterm1 15.32.199.64  a4410rd1 15.32.199.62  a4410750hp1 

This file is in the following format:


internet_address           official_hostname aliases

The Internet Protocol address (IP address) is a Class A, B, or C address. A Class A network supports many more nodes per network than either a Class B or C network. The purpose of breaking down the IP address into four fields is to define a node (or host) address and a network address. The previous chapter describes these classes in detail.

Assuming that the above /etc/hosts file contains Class C addresses, the rightmost field is the host or node address, and the other three fields comprise the network address.

You could use either the official_hostname or alias from the /etc/hosts file when issuing remote connection command, such as telnet or rlogin, as shown in the following example:

 $ telnet a4410750 

or

 $ telnet hp1 

Similarly, either of the following Berkeley commands works:

 $ rlogin a4410750 

or

 $ rlogin hp1 

If you're using only the loopback device, the only line in the file will be the one that contains 127.0.0.1.

/etc/networks

This file lists the names of networks including the one on which you are working and other networks. This is an optional file. It is used by the route command to identify networks by name rather than IP address. An entry in/etc/networks would look like the following:

 dev-net       15.33.75.0     #development network 

You can then use the following route command:

 # route add dev-net 

Without the /etc/networks file, you would have to use the IP address rather than the name dev-net. If your system doesn't have an /etc/networks file, you must create one and add entries like the above for any network you want to route by name.

/etc/nsswitch.conf

This file is used by the system to determine where it should look up information and in what order it should reference these entries. To look up hosts for instance, you would specify locations such as the /etc/hosts file, dns, nisplus, and so on. The following examples show looking up hosts using these locations in the same order just listed:

 hosts:          files dns nisplus 

In most cases, the /etc/hosts file comes first. This file has many other networking selections in it. The following example shows the full nss- witch.conf file from the Integrity Advanced Server system:

 # cat /etc/nsswitch.conf # # /etc/nsswitch.conf # # An example Name Service Switch config file. This file should be # sorted with the most-used services at the beginning. # # The entry '[NOTFOUND=return]' means that the search for an # entry should stop if the search in the previous entry turned # up nothing. Note that if the search failed due to some other reason # (like no NIS server responding) then the search continues with the # next entry. # # Legal entries are: # #       nisplus or nis+         Use NIS+ (NIS version 3) #       nis or yp               Use NIS (NIS version 2), also called YP #       dns                     Use DNS (Domain Name Service) #       files                   Use the local files #       db                      Use the local database (.db) files #       compat                  Use NIS on compat mode #       hesiod                  Use Hesiod for user lookups #       [NOTFOUND=return]       Stop searching if not found so far # # To use db, put the "db" in front of "files" for entries you want to be # looked up first in the databases # # Example: #passwd:    db files nisplus nis #shadow:    db files nisplus nis #group:     db files nisplus nis passwd:     files nisplus shadow:     files nisplus group:      files nisplus #hosts:     db files nisplus nis dns hosts:      files nisplus dns # Example - obey only what nisplus tells us... #services:   nisplus [NOTFOUND=return] files #networks:   nisplus [NOTFOUND=return] files #protocols:  nisplus [NOTFOUND=return] files #rpc:        nisplus [NOTFOUND=return] files #ethers:     nisplus [NOTFOUND=return] files #netmasks:   nisplus [NOTFOUND=return] files bootparams:  nisplus [NOTFOUND=return] files ethers:     files netmasks:   files networks:   files protocols:  files nisplus rpc:        files services:   files nisplus netgroup:   files nisplus publickey:  nisplus automount:  files nisplus aliases:    files nisplus # 

You are not limited to hosts information in this file. You can specify other services besides hosts, such as passwd, shadow, group, and others. There are already entries in your default /etc/nsswitch.conf file if you want to view them. For more information about /etc/nsswitch.conf, see the man page for nsswitch.conf.

/etc/resolv.conf

This file contains the name of the domain and any name server(s) that will be used along with their IP addresses. The name servers will resolve a name into an IP address. The following example shows a simple resolv.conf file:

 domain         development.com nameserver     15.33.75.55 

This first line contains the default search domain and the second contains the is the IP address of the host's name server.

In the previous example, the domain of development.com will be appended to any hostname such the result will be hostname.development.com. You can specify multiple domain names in this file by separating them with spaces all on one line.

     < Day Day Up > 


    Linux on HP Integrity Servers. A System Administrator's Guide
    Linux on HP Integrity Servers: A System Administrators Guide
    ISBN: 0131400002
    EAN: 2147483647
    Year: 2004
    Pages: 100

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net