4.2. Routing to Locally Connected Networks

Any IP network is defined by two sets of numbers: network address and netmask. By convention, there are two ways to represent these two numbers. Netmask notation is the convention and tradition in IP networking although the more succinct CIDR notation is gaining popularity.

In the example network, isolde has IP address In CIDR notation, isolde's address is, and in traditional netmask notation, Any of the IP calculators, confirms that the first usable IP address is and the last usable IP address is Importantly, the IP network address,, is reachable through the directly connected Ethernet interface (refer to classification 2). Therefore, isolde should be able to reach any IP address in this range directly on the locally connected Ethernet segment.

Below is the routing table for isolde, first shown with the conventional route -n output [15] and then with the ip route show [16] command. Each of these tools conveys the same routing table and operates on the same kernel routing table. For more on the routing table displayed in Example 4.3, consult Section 4.8.3, “The Main Routing Table”.

Example 4.3. Identifying the locally connected networks with route

[root@isolde]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface   U     0      0        0 eth0       U     0      0        0 lo         UG    0      0        0 eth0
[root@isolde]# ip route show dev eth0  scope link dev lo  scope link 
default via dev eth0

In the above example, the locally reachable destination is which can also be written as in ip route show. In classful networking terms, the network to which isolde is directly connected is called a class C sized network.

When a process on isolde needs to send a packet to another machine on the locally connected network, packets will be sent from (isolde's IP). The kernel will consult the routing table to determine the route and the source address to use when sending this packet. Assuming the destination is, the kernel will find that falls inside the IP address range and will select this route for the outbound packet. For further details on source address selection, see Section 4.6, “Source Address Selection”. The source address on the outbound packet conveys vital information to the host receiving the packet. In order for the packet to be able to return, isolde has to use an IP address that is locally available, has to have a route to isolde and neither host must block the packet.

The packet will be sent to the locally connected network segment directly, because isolde interprets from the routing table that is directly reachable through the physical network connection on eth0.

Occasionally, a machine will be directly connected to two different IP networks on the same device. The routing table will show that both networks are reachable through the same physical device. For more on this topic, see Section 9.2, “Multiple IP Networks on one Ethernet Segment”. Similarly, multi-homed hosts will have routes for all locally connected networks through the locally-connected network interface. For more on this sort of configuration, see Section 9.6, “Multihomed Hosts”.

This covers the classification of IP destinations which are available on a locally connected network. This highlights the importance of an accurate netmask and network address. The next section will cover IP ranges which are neither locally hosted nor fall in the range of the locally reachable networks. These destinations must be reached through a router.

[15] The route -n output can also be produced with netstat -rn and is commonly used by admininstrators who rely on platform independent behaviour across heterogeneous Unix and Unix-like systems. This traditional routing table output uses conventional netmask notation to denote network size.

[16] Refer to the ip route section for a fuller discussion of this linux specific tool. The routing table output from ip route uses exclusively CIDR notation.