Show
Interface Configuration for IPAfter setting up your hardware as explained in Chapter 4, you have to make these devices known to the kernel networking software. A couple of commands are used to configure the network interfaces and initialize the routing table. These tasks are usually performed from the network initialization script each time you boot the system. The basic tools for this process are called ifconfig (where “if” stands for interface) and route. ifconfig is used to make an interface accessible to the kernel networking layer. This involves the assignment of an IP address and other parameters, and activation of the interface, also known as “bringing up” the interface. Being active here means that the kernel will send and receive IP datagrams through the interface. The simplest way to invoke it is with: ifconfig This command assigns route allows you to add or remove routes from the kernel routing table. It can be invoked as: route [add|del] [-net|-host] The The Loopback InterfaceThe very first interface to be activated is the loopback interface: # Occasionally, you will see the dummy hostname localhost being used instead of the IP address.
ifconfig will look up the name in the # Sample /etc/hosts entry for localhost localhost 127.0.0.1 To view the configuration of an interface, you invoke ifconfig, giving it only the interface name as argument: $ As you can see, the loopback interface has been assigned a netmask of 255.0.0.0, since 127.0.0.1 is a class A address. Now you can almost start playing with your mini-network. What is still missing is an entry in the routing table that tells IP that it may use this interface as a route to destination 127.0.0.1. This is accomplished by using: # route add 127.0.0.1 Again, you can use localhost instead of the IP address, provided you’ve entered it into your Next, you should check that everything works fine, for example by using ping. ping is the networking equivalent of a sonar device.[31] The command is used to verify that a given address is actually reachable, and to measure the delay that occurs when sending a datagram to it and back again. The time required for this process is often referred to as the “round-trip time”: # When you invoke ping as shown here,
it will continue emitting packets forever, unless interrupted by the user. The The previous example shows that packets for 127.0.0.1 are properly delivered and a reply is returned to ping almost instantaneously. This shows that you have successfully set up your first network interface. If the output you get from
ping does not resemble that shown in the previous example, you are in trouble. Check any errors if they indicate that some file hasn’t been installed properly. Check that the ifconfig and route binaries you use are compatible with the kernel release you run, and above all, that the kernel has been compiled with networking enabled (you see this from the presence of the The steps previously described are enough to use networking applications on a standalone host. After adding the lines mentioned earlier to your network initialization script and making sure it will be executed at boot time, you may reboot your machine and try out
various applications. For instance, telnet localhost should establish a telnet connection to your host, giving you a However, the loopback interface is useful not only as an example in networking books, or as a test bed during development, but is actually used by some applications during normal operation.[32] Therefore, you always have to configure it, regardless of whether your machine is attached to a network or not. Ethernet InterfacesConfiguring an Ethernet interface is pretty much the same as the loopback interface; it just requires a few more parameters when you are using subnetting. At the Virtual Brewery, we have subnetted the IP network, which was originally a class B network, into class C subnetworks. To make the interface recognize this, the ifconfig incantation would look like this: # This command assigns the # You can see that ifconfig automatically sets the broadcast address (the Just as for the loopback interface, you now have to install a routing entry that informs the kernel about the network that can be reached through # At first this looks a little like magic, because it’s
not really clear how route detects which interface to route through. However, the trick is rather simple: the kernel checks all interfaces that have been configured so far and compares the destination address (172.16.1.0 in this case) to the network part of the interface address (that is, the bitwise AND of the interface address and the netmask). The only interface that matches is Now, what’s that Of course, the route command is a little tedious to type, and it’s prone to
spelling mistakes. A more convenient approach is to use the network names we defined in # Now that you’ve finished the basic configuration steps, we want to make sure that your Ethernet interface is indeed running happily. Choose a host from your Ethernet, for instance vlager, and type: # If you don’t see similar output, something is broken. If you encounter unusual packet loss rates, this hints at a hardware problem, like bad or missing terminators. If you don’t receive any replies at all, you should check the interface configuration with netstat described later in
Section 5.9. The packet statistics displayed by ifconfig should tell you whether any packets have been sent out on the interface at all. If you have access to the remote host too, you should go over to that machine and check the interface statistics. This way you can determine exactly where the packets got dropped. In
addition, you should display the routing information with route to see if both hosts have the correct routing entry. route prints out the complete kernel routing table when invoked without any arguments ( # The
detailed meaning of these fields is explained later in Section 5.9.” The Routing Through a GatewayIn the previous section, we covered only the case of setting up a host on a single Ethernet. Quite frequently, however, one encounters networks connected to one another by gateways. These gateways may simply link two or more Ethernets, but may also provide a link to the outside world, such as the Internet. In order to use a gateway, you have to provide additional routing information to the networking layer. The Ethernets of the Virtual Brewery and the Virtual Winery are linked through such a gateway, namely the host
vlager. Assuming that vlager has already been configured, we just have to add another entry to vstout’s routing table that tells the kernel it can reach all hosts on the Winery’s network through vlager. The appropriate incantation of route is shown below; the # Of course, any host on the Winery network you wish to talk to must have a routing entry for the Brewery’s network. Otherwise you would only be able to send data to the Winery network from the Brewery network, but the hosts on the Winery would be unable to reply. This example describes only a gateway that switches packets between two isolated Ethernets. Now assume that vlager also has a connection to the Internet (say, through an additional SLIP link). Then we would want datagrams to any destination network other than the Brewery to be handed to vlager. This action can be accomplished by making it the default gateway for vstout: # The network name default is a shorthand for 0.0.0.0, which denotes the default route. The default route matches every
destination and will be used if there is no more specific route that matches. You do not have to add this name to If you see high packet loss rates when pinging a host behind one or more gateways, this may hint at a very congested network. Packet loss is not so much due to technical deficiencies as to temporary excess loads on forwarding hosts, which makes them delay or even drop incoming datagrams. Configuring a GatewayConfiguring a machine to switch packets between two Ethernets is pretty straightforward. Assume we’re back at vlager, which is equipped with two Ethernet cards, each connected to one of the two networks. All you have to do is configure both interfaces separately, giving them their respective IP addresses and matching routes, and that’s it. It is quite useful to add information on the two interfaces to the 172.16.1.1 vlager.vbrew.com vlager vlager-if1 172.16.2.1 vlager-if2 The sequence of commands to set up the two interfaces is then: # If this sequence doesn’t work, make sure your kernel has been compiled with support for IP forwarding enabled. One good way to do this is to ensure that the first number on the second line of The PLIP InterfaceA PLIP link used to connect two machines is a little different from an Ethernet. PLIP links are an example of what are called point-to-point links, meaning that there is a single host at each end of the link. Networks like Ethernet are called broadcast networks. Configuration of point-to-point links is different because unlike broadcast networks, point-to-point links don’t support a network of their own. PLIP provides very cheap and portable links between computers. As an example, we’ll consider the laptop computer of an employee at the Virtual Brewery that is connected to vlager via PLIP. The laptop itself is called vlite and has only one parallel port. At boot time, this port will be registered as
# The first command configures the interface, telling the kernel that this is a point-to-point link, with the remote side having the address of vlager. The second installs the default route, using vlager as gateway. On vlager, a similar ifconfig command is necessary to activate the link (a route invocation is not needed): # Note that the Now we have configured routing from the laptop to the Brewery’s network; what’s still missing is a way to route from any of the Brewery’s hosts to vlite. One particularly cumbersome way is to add a specific route to every host’s routing table that names vlager as a gateway to vlite: # Dynamic routing offers a much better option for temporary routes. You could use gated, a routing daemon, which you would have to install on each host in the network in order to distribute routing information dynamically. The easiest option, however, is to use proxy ARP (Address Resolution Protocol). With proxy ARP, vlager will respond to any ARP query for vlite by sending its own Ethernet address. All packets for vlite will wind up at vlager, which then forwards them to the laptop. We will come back to proxy ARP in the section Section 5.10.” Current The SLIP and PPP InterfacesAlthough SLIP and PPP links are only simple point-to-point links like PLIP connections, there is much more to be said about them. Usually, establishing a SLIP connection involves dialing up a remote site through your modem and setting the serial line to SLIP mode. PPP is used in a similar fashion. We discuss SLIP and PPP in detail in Chapter 7 and Chapter 8. The Dummy InterfaceThe dummy interface is a little exotic, but rather useful nevertheless. Its main benefit is with standalone hosts and machines whose only IP network connection is a dialup link. In fact, the latter are standalone hosts most of the time, too. The dilemma with standalone hosts is that they only have a single network device active, the
loopback device, which is usually assigned the address 127.0.0.1. On some occasions, however, you must send data to the “official” IP address of the local host. For instance, consider the laptop vlite, which was disconnected from a network for the duration of this example. An application on vlite may now want to send data to another application on the same host. Looking up
vlite in This is where the dummy device steps in. It solves the dilemma by simply serving as the alter ego of the loopback interface. In the case of vlite, you simply give it the address 172.16.1.65 and add a host route pointing to it. Every datagram for 172.16.1.65 is then delivered locally. The proper invocation is:[35] # IP AliasNew kernels support a feature that can completely replace the dummy interface and serve other useful functions. IP Alias allows you to configure multiple IP addresses onto a physical device. In the simplest case, you could replicate the function of the dummy interface by configuring the host address as an alias onto the loopback interface and completely avoid using the dummy interface. In more complex uses, you could configure your host to look like many different hosts, each with its own IP address. This configuration is sometimes called “Virtual Hosting,” although technically it is also used for a variety of other techniques.[36] To configure an alias for an interface, you must first ensure that your kernel has been compiled with support for IP Alias (check that you have a # This command would produce an alias for the loopback interface with the address Each alias may be treated as though it is a separate device, and as far as the kernel IP software is concerned, it will be; however, it will be sharing its hardware with another interface. Which command is used to add information about the network connected to the interface?The following two commands are used to gather more detailed interface information: show interfaces: Displays interface information and packet flow count for all interfaces on the device. show ip interface: Displays the IPv4-related information for all interfaces on a router.
What command will show all information about the interface?Use the show interfaces EXEC command to display statistics for all interfaces configured on the router or access server.
Which command is used to activate the interface?To enable an interface, it must be activated using the no shutdown command. (This is similar to powering on the interface.) The interface must also be connected to another device (a hub, a switch, or another router) for the physical layer to be active.
Which command displays IP information for an interface?The ipconfig command displays the basic IP addressing information for each network interface on the Windows system. This information includes both the IP address and subnet mask.
|