Output of route n with NoDefault Route

bible:~ # route -n Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

As you can see, this example uses the -n option to suppress the use of name resolution. When you suppress name resolution, it speeds up the execution of the command because it will not try to resolve an IP address to a name using your name resolver, which could at best be your local host's file or at worst be your network's DNS server.

You have two routes that have automatically been assigned by the kernel when the two devices, eth0 and lo, were created. If you need to talk to a machine in the network, that traffic is routed to the eth0 device. The same is true for the network, which is routed over the lo (loopback) adaptor.

However, if you want to communicate with a machine on any other network, say, you get an error that the machine cannot be found because you are currently unable to route packets outside of your network.

To combat this, you need to set up a default route for all traffic you do not know about. To do this, you create a default route with the following command:

bible:~ # route add default gw

Here you have used the route command to add a new route to the routing table. Table 15-2 explains the options used in the preceding command example.

The route Command-Line Options




Adds a route to the routing table


Specifies that packets should be sent to this gateway The IP address of the gateway/default router The IP address of the gateway/default router i- : i j The route command can also be used to add static routes for other networks f-c '3 ^ ^à^'-vï-j (for example, if you know that a specific router attached to ethl is servicing a destination network you want to reach without using your default route). For example, if you want to add a specific route for the network, you can use route add -net This routes traffic for through the router.

When the default route has been added, you can take another look at the routing table (see Listing 15-3).

Was this article helpful?

0 0

Post a comment