Starting with a localhost Interface


Starting with a localhost Interface

Before setting up any kind of Internet connection, you'll need to create a dummy interface that the TCP/IP protocol uses to determine the network capability of your machine. This is called the loopback (lo) interface, or localhost. Many network-aware applications reference this interface as well, so it is important.

What is a loopback interface? To a Linux networking driver, this is a network composed of exactly one computer. The kernel loops back network traffic to and from itself using the 127.0.0.1 IP address.

SUSE Linux should create the localhost interface during the initial installation. To confirm this, open a root console and run the ifconfig utility to identify your setup. Running this command should generate a response similar to this:

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:2187 errors:0 dropped:0 overruns:0 frame:0           TX packets:2187 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:0           RX bytes:114362 (111.6 Kb)  TX bytes:114362 (111.6 Kb) 

This output tells you that the local loopback interface is active and is assigned the standard IP address for local connections, 127.0.0.1, and a broadcast mask of 255.0.0.0 is used. You even take a small peek into the future, as this version of ifconfig lists an Ipv6 address of ::1/128. This next version of the Internet Protocol (IP version 6) offers exponentially more IP address space than the existing IP version 4.

Configuring localhost Manually

In the off chance localhost was not created during your SUSE Linux installation, it is easy to do yourself.

The localhost interface address is stored in a text file called /etc/hosts. This file stores all network IP address and hostname information. The kernel and other network utilities reads this to understand how this computer is connected to others.

Tip

You can also access and edit the Hosts file in YaST. Go to Network Services, then Hosts. Add, edit, or delete hosts here.


When you open this file, you will see a comment that describes the file and the syntax you should follow: IP-Address [tab] Full-Qualified-Hostname [tab] Short-Hostname.

If localhost is not already there, you may add this line:

127.0.0.1        localhost 

You can leave the Short-Hostname blank. Save and exit. Reopen your root console and use ifconfig and route to create the interface:

ifconfig lo 127.0.0.1 

This puts the localhost interface in memory, as with all other Linux network interfaces, like an Ethernet (eth0) or dial-up (ppp0) interface.

route add 127.0.0.1 lo 

This adds the IP address to a routing table the kernel's networking code uses to track routes to different addresses.

Test the new connection by running ifconfig again.

You should now be able to run your own loopback test by trying to ping localhost. You should see something like this (we'll use the -c option to count out 3 packets to send):

 # ping -c 3 localhost PING localhost (127.0.0.1) 56(84) bytes of data. 64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.087 ms 64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.087 ms 64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.081 ms --- localhost ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2000ms rtt min/avg/max/mdev = 0.081/0.085/0.087/0.003 ms 

We have completed our prerequisites; now it's time to take on the main course.



SUSE Linux 10 Unleashed
SUSE Linux 10.0 Unleashed
ISBN: 0672327260
EAN: 2147483647
Year: 2003
Pages: 332

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net