Online Book Reader

Home Category

Running Linux, 5th Edition - Matthias Kalle Dalheimer [252]

By Root 1268 0

loopnet 127.0.0.0 # loopback network - mandatory

veggie-net 128.17.75.0 # Modify for your own network address

Now, instead of using the command:

route add 128.17.75.20

we can use:

route add veggie-net

/etc/host.conf

The /etc/host.conf file specifies how your system resolves hostnames. It should contain the following two lines:

order hosts,bind

multi on

These lines tell the resolver libraries to first check the /etc/hosts file and then ask the nameserver (if one is present) for any names it must look up. The multi entry allows you to have multiple IP addresses for a given machine name in /etc/hosts.

On systems that use glibc2 (which applies to most of the newer distributions), /etc/nsswitch.conf is used instead of /etc/host.conf. In this case, this file should contain the lines hosts: files dns and networks: files dns.

/etc/resolv.conf

The /etcresolv.conf file configures the name resolver, specifying the address of your nameserver (if any) and domains that you want to search by default if a specified hostname is not a fully specified hostname. For example, if this file contains the line:

search vpizza.com vpasta.com

using the hostname blurb will cause the name resolver to try to resolve the names blurb.vpizza.com and blurb.vpasta.com (in this order). This is convenient because it saves you typing in the full names of often-used domains. On the other hand, the more domains you specify here, the longer the DNS lookup will take.

For example, the machine eggplant.veggie.com with a nameserver at address 128.17.75.55 would have the following lines in /etc/resolv.conf:

domain veggie.com

nameserver 128.17.75.55

You can specify more than one nameserver; each must have a nameserver line of its own in resolv.conf.

Setting your hostname

You should set your system hostname with the hostname command. This is usually executed from a file called /etc/init.d/boot.localnet or similar; simply search your system rc files to determine where it is invoked. For example, if your (full) hostname is eggplant.veggie.com, edit the appropriate rc file to execute the command /bin/hostname eggplant.veggie.com. Note that the hostname executable may be found in a directory other than /bin on your system.

Trying out your network

Once you have the various networking configuration files modified for your system, you should be able to reboot (using a TCP/IP-enabled kernel) and attempt to use the network.

When first booting the system, you may wish to disable execution of rc.inet1 and rc.inet2 and run them by hand once the system is up. This allows you to catch any error messages, modify the scripts, and retry. Once you have things working, you can enable the scripts from /etc/inittab.

One good way of testing network connectivity is to simply ssh to another host. You should first try to connect to another host on your local network, and if this works, attempt to connect to hosts on other networks . The former will test your connection to the local subnet; the latter, your connection to the rest of the world through your gateway.

You may be able to connect to remote machines via the gateway if connecting to machines on the subnet fails. This is a sign that there is a problem with your subnetwork mask or the routing table entry for the local network.

When attempting to connect to other machines, you should first try to connect using only the IP address of the remote host. If this seems to work, but connecting via the hostname does not, there may be a problem with your nameserver configuration (e.g., /etc/resolv.conf and /etc/host.conf) or with your route to the nameserver.

The most common source of network trouble is an ill-configured routing table. You can use the command

netstat -rn

to display the routing table; in the previous section, we described the format of the routing tables as displayed by this command. The netstat(8) manual page provides additional insight as well. Using netstat without the -n option forces it to display host and network entries by name instead of by address.

Return Main Page Previous Page Next Page

®Online Book Reader