All the big, userfriendly Linux distributions come with various graphical tools, allowing for easy setup of the computer in a local network, for connecting it to an Internet Service Provider or for wireless access. These tools can be started up from the command line or from a menu:
Your system documentation provides plenty of advice and information about availability and use of tools. Information that you will need to provide:
The graphical helper tools edit a specific set of network configuration files, using a couple of basic commands. The exact names of the configuration files and their location in the file system is largely dependent on your Linux distribution and version. However, a couple of network configuration files are common on all UNIX systems: The /etc/hosts file always contains the localhost IP address, 127.0.0.1, which is used for interprocess communication. Never remove this line! Sometimes contains addresses of additional hosts, which can be contacted without using an external naming service such as DNS (the Domain Name Server). A sample hosts file for a small home network:
Read more in man hosts. The /etc/resolv.conf file configures access to a DNS server, see Section 10.3.7. This file contains your domain name and the name server(s) to contact:
Read more in the resolv.conf man page. The /etc/nsswitch.conf file defines the order in which to contact different name services. For Internet use, it is important that dns shows up in the "hosts" line:
This instructs your computer to look up hostnames and IP addresses first in the /etc/hosts file, and to contact the DNS server if a given host does not occur in the local hosts file. Other possible name services to contact are LDAP, NIS and NIS+. More in man nsswitch.conf. The distribution-specific scripts and graphical tools are front-ends to ip (or ifconfig and route on older systems) to display and configure the kernel's networking configuration. The ip command is used for assigning IP addresses to interfaces, for setting up routes to the Internet and to other networks, for displaying TCP/IP configurations etcetera. The following commands show IP address and routing information:
Things to note:
While ip is the most novel way to configure a Linux system, ifconfig is still very popular. Use it without option for displaying network interface information:
Here, too, we note the most important aspects of the interface configuration:
Both ifconfig and ip display more detailed configuration information and a number of statistics about each interface and, maybe most important, whether it is "UP" and "RUNNING". On your laptop which you usually connect to the company network using the onboard Ethernet connection, but which you are now to configure for dial-in at home or in a hotel, you might need to activate the PCMCIA card. This is done using the cardctl control utility, or the pccardctl on newer distributions. A usage example: cardctl insert Now the card can be configured, either using the graphical or the command line interface. Prior to taking the card out, use this command: cardctl eject However, a good distribution should provide PCMCIA support in the network configuration tools, preventing users from having to execute PCMCIA commands manually. Further discussion of network configuration is out of the scope of this document. Your primary source for extra information is the man pages for the services you want to set up. Additional reading:
On a Linux machine, the device name lo or the local loop is linked with the internal 127.0.0.1 address. The computer will have a hard time making your applications work if this device is not present; it is always there, even on computers which are not networked. The first ethernet device, eth0 in the case of a standard network interface card, points to your local LAN IP address. Normal client machines only have one network interface card. Routers, connecting networks together, have one network device for each network they serve. If you use a modem to connect to the Internet, your network device will probably be named ppp0. There are many more names, for instance for Virtual Private Network interfaces (VPNs), and multiple interfaces can be active simultaneously, so that the output of the ifconfig or ip commands might become quite extensive when no options are used. Even multiple interfaces of the same type can be active. In that case, they are numbered sequentially: the first will get the number 0, the second will get a suffix of 1, the third will get 2, and so on. This is the case on many application servers, on machines which have a failover configuration, on routers, firewalls and many more. Apart from the ip command for displaying the network configuration, there's the common netstat command which has a lot of options and is generally useful on any UNIX system. Routing information can be displayed with the -nr option to the netstat command:
This is a typical client machine in an IP network. It only has one network device, eth0. The lo interface is the local loop.
When this machine tries to contact a host that is on another network than its own, indicated by the line starting with 0.0.0.0, it will send the connection requests to the machine (router) with IP address 192.168.42.1, and it will use its primary interface, eth0, to do this. Hosts that are on the same network, the line starting with 192.168.42.0, will also be contacted through the primary network interface, but no router is necessary, the data are just put on the network. Machines can have much more complicated routing tables than this one, with lots of different "Destination-Gateway" pairs to connect to different networks. If you have the occasion to connect to an application server, for instance at work, it is most educating to check the routing information. An impressive amount of tools is focused on network management and remote administration of Linux machines. Your local Linux software mirror will offer plenty of those. It would lead us too far to discuss them in this document, so please refer to the program-specific documentation. We will only discuss some common UNIX/Linux text tools in this section. To display information on hosts or domains, use the host command:
Similar information can be displayed using the dig command, which gives additional information about how records are stored in the name server. To check if a host is alive, use ping. If your system is configured to send more than one packet, interrupt ping with the Ctrl+C key combination:
To check the route that packets follow to a network host, use the traceroute command:
On some systems, traceroute has been renamed to tracepath. Specific domain name information can be queried using the whois command, as is explained by many whois servers, like the one below:
For other domain names than .com, .net, .org and .edu, you might need to specify the whois server, such as this one for .be domains: whois |