Table of Contents

About

If you want to use TCP/IP to send a data packet, the network layer (in the OSI layer model or the IP layer) must determine if and how the target IP address can be accessed.

Routing Table

The routing information necessary for this is stored in the routing table.

Route

The entire route to the target address is not described in the routing table, instead, only the route up to the next node (next hop) to which the data packet is forwarded.

There, a check is made in one of its own routing tables as to how the target address should be accessed.

Direct

This is called an indirect route, since the route goes through at least one gateway.

Indirect

If the address can be directly accessed, this is called a direct route.

Example

Simple Route

In this example, the three hosts are connected together by network A and network B:

Network Simple Route

A host is usually addressed by its host name. If Host 3 makes a connection to Host 1, the target address 192.5.5.7 (R1) is addressed. By default, this connection goes over network A. If you want the connection to the same target address to run over network B instead, you must have a corresponding routing entry in Host 3. You may want to route the connection over network B, for example, to increase performance (network B is faster than network A). For communication to run in both directions over network B, there must also be a corresponding routing entry for Host 3 on Host 1.

Management

tracing

route tracing, see:

Tools

UNIX

The above example described an indirect host route. The target address is a complete IP address (a host route), and it is also accessed through a gateway using the IP name R1B (an indirect route). On UNIX hosts, you can display the routing table by using the command netstat –r. For indirect routes, the flag G is used, and for host routes, the flag H is used. To create an indirect route, you must specify in the command route add a Metric (hop count) greater than 0.

Action Command
Create route on host 1: route add R3 R3B 1
Create route on host 3: route add R1 R1B 1
Display all static routes: netstat –r
Test routes: traceroute

Host 3:

Destination Gateway Flag
R1 R1B UGH

Host 1:

Destination Gateway Flag
R3 R3B UGH

Netstat Routes

netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         172.19.0.1      0.0.0.0         UG        0 0          0 eth0
172.19.0.0      0.0.0.0         255.255.0.0     U         0 0          0 eth0

Windows NT

On Windows NT hosts, you can display the routing table by using the command route print. Indirect routes are indicated by a Metric = 1 and are made defaults with the command route add.

Action Command
Create route on host 1: route add R3 R3B 1
Create route on host 3: route add R1 R1B 1
Display all static routes: route print
Test routes: tracert

Host 3:

Network address Gateway address Metric
R1 R1B 1

Host 1:

Network address Gateway address Metric
R3 R3B 1

Route PRINT

route PRINT
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 50 56 c0 00 08 ...... VMware Virtual Ethernet Adapter for VMnet8
0x3 ...00 50 56 c0 00 01 ...... VMware Virtual Ethernet Adapter for VMnet1
0x4 ...02 00 4c 4f 4f 50 ...... Microsoft Loopback Adapter
0x5 ...00 1c 23 33 c8 42 ...... Broadcom NetXtreme 57xx Gigabit Controller - Pac
ket Scheduler Miniport
0x6 ...00 1d e0 8d 1b 21 ...... Intel(R) Wireless WiFi Link 4965AGN - Packet Sch
eduler Miniport
0x10008 ...00 ff 02 a9 5b 2d ...... TAP-Win32 Adapter V8 - Packet Scheduler Mini
port
===========================================================================
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0    192.168.1.254   192.168.1.145       20
         10.0.0.0    255.255.255.0         10.0.0.6        10.0.0.6       30
         10.0.0.6  255.255.255.255        127.0.0.1       127.0.0.1       30
       10.10.10.0    255.255.255.0      10.10.10.10     10.10.10.10       30
      10.10.10.10  255.255.255.255        127.0.0.1       127.0.0.1       30
   10.255.255.255  255.255.255.255         10.0.0.6        10.0.0.6       30
   10.255.255.255  255.255.255.255      10.10.10.10     10.10.10.10       30
        127.0.0.0        255.0.0.0        127.0.0.1       127.0.0.1       1
      192.168.1.0    255.255.255.0      192.168.1.1     192.168.1.1       20
      192.168.1.0    255.255.255.0    192.168.1.145   192.168.1.145       20
      192.168.1.0    255.255.255.0         10.0.0.1        10.0.0.6       1
      192.168.1.1  255.255.255.255        127.0.0.1       127.0.0.1       20
    192.168.1.145  255.255.255.255        127.0.0.1       127.0.0.1       20
    192.168.1.255  255.255.255.255      192.168.1.1     192.168.1.1       20
    192.168.1.255  255.255.255.255    192.168.1.145   192.168.1.145       20
     192.168.12.0    255.255.255.0     192.168.12.1    192.168.12.1       20
     192.168.12.1  255.255.255.255        127.0.0.1       127.0.0.1       20
   192.168.12.255  255.255.255.255     192.168.12.1    192.168.12.1       20
        224.0.0.0        240.0.0.0         10.0.0.6        10.0.0.6       30
        224.0.0.0        240.0.0.0      10.10.10.10     10.10.10.10       30
        224.0.0.0        240.0.0.0      192.168.1.1     192.168.1.1       20
        224.0.0.0        240.0.0.0    192.168.1.145   192.168.1.145       20
        224.0.0.0        240.0.0.0     192.168.12.1    192.168.12.1       20
  255.255.255.255  255.255.255.255         10.0.0.6               6       1
  255.255.255.255  255.255.255.255         10.0.0.6        10.0.0.6       1
  255.255.255.255  255.255.255.255      10.10.10.10     10.10.10.10       1
  255.255.255.255  255.255.255.255      192.168.1.1     192.168.1.1       1
  255.255.255.255  255.255.255.255    192.168.1.145   192.168.1.145       1
  255.255.255.255  255.255.255.255     192.168.12.1    192.168.12.1       1
Default Gateway:     192.168.1.254

Documentation / Reference