Configuring an Ethernet interface goes pretty much the same as with 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 assigns the eth0 interface the IP address of vstout (188.8.131.52). If we had omitted the netmask, ifconfig would have deduced the the netmask from the IP network class, which would have resulted in a netmask of 255.255.0.0. Now a quick check shows:
You can see that ifconfig automatically set the broadcast address (the Bcast field above) to the usual value, which is the hosts network number with the host bits all set. Also, the message transfer unit (the maximum size of Ethernet frames the kernel will generate for this interface) has been set to the maximum value of 1500 bytes. All these values can be overidden with special options that will be described later.
Quite similar to the loopback case, you now have to install a routing entry that informs the kernel about the network that can be reached through eth0. For the Virtual Brewery, you would invoke route as
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 (184.108.40.206 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 eth0.
Now, what's that -net option for? This is used because route can handle both routes to networks and routes to single hosts (as you have seen above with localhost). When being given an address in dotted quad notation, it attempts to guess whether it is a network or a hostname by looking at the host part bits. If the address' host part is zero, route assumes it denotes a network, otherwise it takes it as a host address. Therefore, route would think that 220.127.116.11 is a host address rather than a network number, because it cannot know that we use subnetting. We therefore have to tell it explicitly that it denotes a network, giving it the -net flag.
Of course, the above 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 have defined in /etc/networks above. This makes the command much more readable; even the -net flag can now be omitted, because route now knows that 18.104.22.168 denotes a network.
Now that you've finished the basic configuration steps, we want to make sure your Ethernet interface is indeed running happily. Choose a host from your Ethernet, for instance vlager, and type
If you don't see any output similar to this, then something is broken, obviously. If you encounter unusual packet loss rates, this hints at a hardware problem, like bad or missing terminators, etc. If you don't receive any packets at all, you should check the interface configuration with netstat. 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, too. In 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 -n option only makes it print addresses as dotted quad instead of using the hostname):
The detailed meaning of these fields is explained below in section . The Flag column contains a list of flags set for each interface. U is always set for active interfaces, and H says the destination address denotes a host. If the H flag is set for a route that you meant to be a network route, then you have to specify the -net option with the route command. To check whether a route you have entered is used at all, check if the Use field in the second to last column increases between two invocations of ping.