Table of Contents
- About the Lead Authors
- About the Contributing Authors
- Tell Us What You Think!
- I. Red Hat Linux Installation and User Services
- Chapter 1. Introduction to Red Hat Linux
- Chapter 2. Installation of Your Red Hat System
- Chapter 3. LILO and Other Boot Managers
- Chapter 4. Configuring the X Window System, Version 11
- Chapter 5. Window Managers
- Chapter 6. Connecting to the Internet
- Chapter 7. IRC, ICQ, and Chat Clients
- Chapter 8. Using Multimedia and Graphics Clients
- II. Configuring Services
- Chapter 9. System Startup and Shutdown
- Chapter 10. SMTP and Protocols
- Chapter 11. FTP
- Chapter 12. Apache Server
- Chapter 13. Internet News
- Chapter 14. Domain Name Service and Dynamic Host Configuration Protocol
- Chapter 15. NIS: Network Information Service
- Chapter 16. NFS: Network Filesystem
- Chapter 17. Samba
- III. System Administration and Management
- Chapter 18. Linux Filesystems, Disks, and Other Devices
- Chapter 19. Printing with Linux
- Chapter 20. TCP/IP Network Management
- Chapter 21. Linux System Administration
- Chapter 22. Backup and Restore
- Chapter 23. System Security
- IV. Red Hat Development and Productivity
- Chapter 24. Linux C/C++ Programming Tools
- Chapter 25. Shell Scripting
- Chapter 26. Automating Tasks
- Chapter 27. Configuring and Building Kernels
- Chapter 28. Emulators, Tools, and Window Clients
- V. Appendixes
- A. The Linux Documentation Project
- B. Top Linux Commands and Utilities
- C. The GNU General Public License
- D. Red Hat Linux RPM Package Listings
Setting Up the Dummy Interface
A dummy interface is used by TCP/IP to assign an IP address to your machine, which is required for both SLIP and PPP. The reason for a dummy interface is simple: When you connect to an ISP, your IP address is often assigned dynamically, and you never know what the IP address will be in advance. This can cause problems for TCP/IP routines in your kernel that need to know an IP address to function properly. TCP/IP is happy when you assign an IP address—the dummy interface IP address—to your machine. The need for an IP address internally is most important when you are not connected to your ISP because many network-aware applications (such as email, newsreaders, and so on) need to have some IP address to connect to, even if it doesn't lead anywhere. This dummy interface IP address does not conflict with the one assigned by your ISP.
Fortunately, setting up a dummy interface is simple. All that is required are a couple of commands to create the interface and a couple more commands to test that the interface is working, and you're done. The file that Linux uses to store all network IP address information is called /etc/hosts, and every system should have one (even if it is empty).
The /etc/hosts file is an ASCII file that provides two pieces of information to the TCP/IP drivers and applications: an IP address and the names associated with that IP address. Usually, you will find the /etc/hosts file has a single line in it when you install Linux without network support:
001 127.0.0.1 localhost localhost.localdomain 002
This line essentially tells TCP/IP that a special interface called localhost is assigned the IP address 127.0.0.1. The localhost interface is called the dummy interface because it is not a real address. This interface is also called the loopback interface because it leads back to the same machine.
127.0.0.1 is a special IP address reserved for the local machines on all networks. Every networked Linux machine has this IP address for its localhost. If you display the contents of your /etc/hosts file and this line already exists, then the dummy interface is set up for you and you can skip this section. If the /etc/hosts file doesn't exist or this line is not in the file, you have to set up the interface yourself. If your machine has an IP address other than 127.0.0.1 in your /etc/hosts file, and the interface 127.0.0.1 is not there, you do not have the localhost interface set up.
To create the dummy interface, your Linux system needs the networking software installed. The installation happens automatically with most root and boot images, even if the network interfaces are not configured.
Begin the dummy interface setup by editing (or creating, if it doesn't exist) the /etc/hosts file, and add the following line:
127.0.0.1 localhost localhost.localdomain
The number of spaces between the IP address and the name localhost does not matter, as long as there is at least one. Make sure you enter the IP address exactly as shown—with no spaces between the parts of the dotted-quad notation. If you already had an IP address in the /etc/hosts file for your local machine but no localhost entry with this IP address, you still need to add this line. The localhost line is usually the very first line in the /etc/hosts file.
After updating the /etc/hosts file, you need to tell TCP/IP about the new interface. To set up the dummy interface, issue the following commands when you are logged in as root:
# ifconfig lo 127.0.0.1 # route add 127.0.0.1
The first command tells the system to add an interface called the localhost (lo is the short form for localhost) with an IP address of 127.0.0.1. The second command adds the IP address 127.0.0.1 to an internal table that keeps track of routes to different addresses.
After you have issued these two commands, the dummy interface should be created and ready to use. A machine reboot usually helps ensure that the proper configurations are read. To test the dummy interface, use the ifconfig command again with the name of the interface (lo for localhost) to tell you statistics about the interface (or just use ifconfig to see all interfaces). The command and a sample output look like this:
# ifconfig lo lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:3924 Metric:1 RX packets:60 errors:0 dropped:0 overruns:0 frame:0 TX packets:60 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0
This output shows that the loopback interface is active and running, that it has been assigned the IP address 127.0.0.1, that the broadcast mask of 255.0.0.0 is used, and that the interface hasn't had much traffic. Don't worry about the errors in the last couple of lines: You haven't used the interface yet so there are no meaningful statistics available.
As a check that your kernel knows about the interface and that your machine responds to the IP address 127.0.0.1 and the name localhost (defined in your system's /etc/hosts file), you can use the ping command to check that the interface is responding properly:
# ping localhost PING localhost (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.3 ms 64 bytes from 127.0.0.1: icmp_seq=1 ttl=255 time=0.2 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=255 time=0.1 ms 64 bytes from 127.0.0.1: icmp_seq=3 ttl=255 time=0.1 ms 64 bytes from 127.0.0.1: icmp_seq=4 ttl=255 time=0.2 ms 64 bytes from 127.0.0.1: icmp_seq=5 ttl=255 time=0.1 ms --- localhost ping statistics --- 6 packets transmitted, 6 packets received, 0% packet loss round-trip min/avg/max = 0.1/0.1/0.3 ms
To stop the output press Ctrl+C. You should get similar results using either the name localhost or the IP address 127.0.0.1 (because they both refer to exactly the same interface according to the /etc/hosts file).
If you get the following message, then the interface is not set up properly and you should check the /etc/hosts file and the ifconfig command to make sure you installed the interface properly:
# ping localhost unknown host
Repeating the installation steps should correct the problem. After you complete those simple steps and tests, the dummy interface is ready to be used by your system, its applications, and both PPP and SLIP.