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:
Ubuntu configuration is done selecting-> -> .
RedHat Linux comes with redhat-config-network, which has both a graphical and a text mode interface.
Suse's YAST or YAST2 is an all-in-one configuration tool.
Mandrake/Mandriva comes with a Network and Internet Configuration Wizard, which is preferably started up from Mandrake's Control Center.
On Gnome systems: gnome-network-preferences.
On KDE systems: knetworkconf.
Your system documentation provides plenty of advice and information about availability and use of tools.
Information that you will need to provide:
For connecting to the local network, for instance with your home computers, or at work: hostname, domainname and IP address. If you want to set up your own network, best do some more reading first. At work, this information is likely to be given to your computer automatically when you boot it up. When in doubt, it is better not to specify any information than making it up.
For connecting to the Internet: username and password for your ISP, telephone number when using a modem. Your ISP usually automatically assigns you an IP address and all the other things necessary for your Internet applications to work.
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:
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 192.168.52.10 tux.mylan.com tux 192.168.52.11 winxp.mylan.com winxp
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:
search mylan.com nameserver 126.96.36.199
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:
[bob@tux ~] grep hosts /etc/nsswitch.conf hosts: files dns
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:
benny@home benny> ip addr show 1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 brd 127.255.255.255 scope host lo inet6 ::1/128 scope host 2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100 link/ether 00:50:bf:7e:54:9a brd ff:ff:ff:ff:ff:ff inet 192.168.42.15/24 brd 192.168.42.255 scope global eth0 inet6 fe80::250:bfff:fe7e:549a/10 scope link benny@home benny> ip route show 192.168.42.0/24 dev eth0 scope link 127.0.0.0/8 dev lo scope link default via 192.168.42.1 dev eth0
Things to note:
two network interfaces, even on a system that has only one network interface card: "lo" is the local loop, used for internal network communication; "eth0" is a common name for a real interface. Do not ever change the local loop configuration, or your machine will start mallfunctioning! Wireless interfaces are usually defined as "wlan0"; modem interfaces as "ppp0", but there might be other names as well.
IP addresses, marked with "inet": the local loop always has 127.0.0.1, the physical interface can have any other combination.
The hardware address of your interface, which might be required as part of the authentication procedure to connect to a network, is marked with "ether". The local loop has 6 pairs of all zeros, the physical loop has 6 pairs of hexadecimal characters, of which the first 3 pairs are vendor-specific.
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:
els@asus:~$ /sbin/ifconfig eth0 Link encap:Ethernet HWaddr 00:50:70:31:2C:14 inet addr:188.8.131.52 Bcast:184.108.40.206 Mask:255.255.255.192 inet6 addr: fe80::250:70ff:fe31:2c14/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:31977764 errors:0 dropped:0 overruns:0 frame:0 TX packets:51896866 errors:0 dropped:0 overruns:0 carrier:0 collisions:802207 txqueuelen:1000 RX bytes:2806974916 (2.6 GiB) TX bytes:2874632613 (2.6 GiB) Interrupt:11 Base address:0xec00 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:765762 errors:0 dropped:0 overruns:0 frame:0 TX packets:765762 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:624214573 (595.2 MiB) TX bytes:624214573 (595.2 MiB)
Here, too, we note the most important aspects of the interface configuration:
The IP address is marked with "inet addr".
The hardware address follows the "HWaddr" tag.
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:
Now the card can be configured, either using the graphical or the command line interface. Prior to taking the card out, use this command:
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:
The Modem-HOWTO: Help with selecting, connecting, configuring, trouble-shooting, and understanding analog modems for a PC.
LDP HOWTO Index, section 4.4: categorized list of HOWTOs about general networking, protocols, dial-up, DNS, VPNs, bridging, routinfg, security and more.
Most systems have a version of the ip-cref file (locate it using the locate command); the PS format of this file is viewable with for instance gv.
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:
bob:~> netstat -nr Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.42.0 0.0.0.0 255.255.255.0 U 40 0 0 eth0 127.0.0.0 0.0.0.0 255.0.0.0 U 40 0 0 lo 0.0.0.0 192.168.42.1 0.0.0.0 UG 40 0 0 eth0
This is a typical client machine in an IP network. It only has one network device, eth0. The lo interface is the local loop.
|The modern way|
The novel way to get this info from your system is by using the ip command:
ip route show
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:
[emmy@pc10 emmy]$ host www.eunet.be www.eunet.be. has address 220.127.116.11 [emmy@pc10 emmy]$ host -t any eunet.be eunet.be. SOA dns.eunet.be. hostmaster.Belgium.EU.net. 2002021300 28800 7200 604800 86400 eunet.be. mail is handled by 50 pophost.eunet.be. eunet.be. name server ns.EU.net. eunet.be. name server dns.eunet.be.
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:
[emmy@pc10 emmy]$ ping a.host.be PING a.host.be (18.104.22.168) from 22.214.171.124: 56(84) bytes of data. 64 bytes from a.host.be(126.96.36.199):icmp_seq=0 ttl=244 time=99.977msec --- a.host.be ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max/mdev = 99.977/99.977/99.977/0.000 ms
To check the route that packets follow to a network host, use the traceroute command:
[emmy@pc10 emmy]$ /usr/sbin/traceroute www.eunet.be traceroute to www.eunet.be(188.8.131.52),30 hops max,38b packets 1 blob (10.0.0.1) 0.297ms 0.257ms 0.174ms 2 adsl-65.myprovider.be (184.108.40.206) 12.120ms 13.058ms 13.009ms 3 220.127.116.11 (18.104.22.168) 13.845ms 14.308ms 12.756ms 4 gigabitethernet2-2.intl2.gam.brussels.skynet.be (22.214.171.124) 13.123ms 13.164ms 12.527ms 5 pecbru2.car.belbone.be (126.96.36.199) 16.336ms 13.889ms 13.028ms 6 ser-2-1-110-ias-be-vil-ar01.kpnbelgium.be (188.8.131.52) 14.602ms 15.546ms 15.959ms 7 unknown-195-207-939.eunet.be (184.108.40.206) 16.514ms 17.661ms 18.889ms 8 S0-1-0.Leuven.Belgium.EU.net (220.127.116.11) 22.714ms 19.193ms 18.432ms 9 dukat.Belgium.EU.net (18.104.22.168) 22.758ms * 25.263ms
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:
[emmy@pc10 emmy]$ whois cnn.com [whois.crsnic.net] Whois Server Version 1.3 $<--snap server message--> Domain Name: CNN.COM Registrar: NETWORK SOLUTIONS, INC. Whois Server: whois.networksolutions.com Referral URL: http://www.networksolutions.com Name Server: TWDNS-01.NS.AOL.COM Name Server: TWDNS-02.NS.AOL.COM Name Server: TWDNS-03.NS.AOL.COM Name Server: TWDNS-04.NS.AOL.COM Updated Date: 12-mar-2002 >>> Last update of whois database: Fri, 5 Apr 2002 05:04:55 EST <<< The Registry database contains ONLY .COM, .NET, .ORG, .EDU domains and Registrars. [whois.networksolutions.com] $<--snap server message--> Registrant: Turner Broadcasting (CNN-DOM) 1 CNN Center Atlanta, GA 30303 Domain Name: CNN.COM Administrative Contact: $<--snap contactinfo--> Technical Contact: $<--snap contactinfo--> Billing Contact: $<--snap contactinfo--> Record last updated on 12-Mar-2002. Record expires on 23-Sep-2009. Record created on 22-Sep-1993. Database last updated on 4-Apr-2002 20:10:00 EST. Domain servers in listed order: TWDNS-01.NS.AOL.COM 22.214.171.124 TWDNS-02.NS.AOL.COM 126.96.36.199 TWDNS-03.NS.AOL.COM 188.8.131.52 TWDNS-04.NS.AOL.COM 184.108.40.206
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: