Networking / Beginners

The resolv.conf file

The resolv.conf file lists the DNS nameservers that can be consulted to perform DNS lookups. A typical resolv.conf file looks like this:

nameserver 192.168.1.110
nameserver 204.127.198.19
nameserver 63.249.76.19

If you have set up a nameserver on your own network, its IP address should be the first one listed.

The nsswitch.conf file

This configuration file controls how name resolution works when looking up various types of objects, such as host addresses and passwords. Listing-1 shows the sample nsswitch.conf file that comes with Fedora Linux. As you can see, this file is loaded with comments that explain what the various settings do.

You can use the files, db, and dns keywords to specify how objects should be retrieved. files specifies that the local file should be used, db specifies a database lookup, and dns specifies that a DNS server should be consulted.

The order in which you list these keywords determines the order in which the data sources are searched. Thus, if you want host names to be resolved first by the local Hosts file and then by DNS, you should include the following line in nsswitch:

hosts: files dns Listing-1: A Sample /etc/nsswitch.conf File
#
# /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
shadow: 	files
group: 		files
#hosts: 	db files nisplus nis dns
hosts: 		files 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
rpc: 		files
services: 	files
netgroup: 	files
publickey: 	nisplus
automount: 	files
aliases: 	files nisplus

The xinetd.conf file

Xinetd is a service that oversees a variety of networking services, such as Telnet or Finger. Xinetd listens for requests on the ports on which these services talk and automatically starts the service when a connection is made. Xinetd is controlled by the configuration file xinetd.conf, which is found in the /etc directory, and each of the services controlled by xinetd is in turn controlled by a configuration file found in the /etc/xinet.d directory.

You should leave most of the settings in these configuration files alone unless you've studied up on xinetd. (You can find out more about it at www.xinetd.org.) However, you may want to modify the configuration files in order to enable or disable specific services.

Each of the services controlled by xinetd has a configuration file in the / etc/xinet.d directory. Each of these configuration files ends with a line that enables or disables the service. For example, here's the configuration file for Telnet, /etc/xinet.d/telnet:

# default: on
# description: The telnet server serves telnet sessions; it uses \
# unencrypted username/password pairs for authentication.
service telnet
{
    Flags = REUSE
    socket_type = stream
    wait = no
    user = root
    server = /usr/sbin/in.telnetd
    log_on_failure += USERID
    disable = yes
}

Here, the last line disables Telnet. You can enable the Telnet service by changing the last line to disable = no.

Displaying Your Network Configuration with the ifconfig Command

Linux doesn't have an ipconfig command like Windows. Instead, the command that you use to display information about your network configuration is ifconfig. You can also use this command to set network configuration options, but in most cases, using the Network Configuration program or directly editing the network configuration files is easier.

If you enter ifconfig without any parameters, you get output similar to the following:

Eth0 	Link encap:Ethernet HWaddr 00:40:05:80:51:F3
	inet addr:192.168.1.200 Bcast:192.168.1.255 Mask:255.255.255.0
	UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
	RX packets:17293 errors:0 dropped:0 overruns:0 frame:0
	TX packets:334 errors:0 dropped:0 overruns:0 carrier:0
	collisions:0 txqueuelen:100
	RX bytes:1124153 (1.0 Mb) TX bytes:45726 (44.6 Kb)
	Interrupt:3 Base address:0xc000
lo 	Link encap:Local Loopback
	inet addr:127.0.0.1 Mask:255.0.0.0
	UP LOOPBACK RUNNING MTU:16436 Metric:1
	RX packets:202939 errors:0 dropped:0 overruns:0 frame:0
	TX packets:202939 errors:0 dropped:0 overruns:0 carrier:0
	collisions:0 txqueuelen:0
	RX bytes:13856758 (13.2 Mb) TX bytes:13856758 (13.2 Mb)

From this output, you can tell that the IP address of the Ethernet adapter (eth0) is 192.168.1.200, the broadcast address is 192.168.1.255, and the netmask is 255.255.255.0. You can also see transmit and receive statistics as well as information about the hardware configuration, such as the MAC address and the adapter's interrupt and memory base address assignments.

Linux offers many other commands that can help you configure and troubleshoot a network.

[Previous] [Contents] [Next]