Configuring routing table running on Linux Machine
Question: How do I examine the routing table on a machine?
Once the network interfaces have been configured, the next part of TCP/IP configuration is configuring routing.
TCP/IP routing may be handled in two ways: static routing or dynamic routing. In static routing, routing information is programmed into the machine at boot time. In dynamic routing, a program (a route daemon) communicates with other routing daemons to continually update the system's routing information in response to changing network conditions.
Configure Static Routing
In this course, we will discuss how to configure static routing only, in the simplest case of a machine with only one network interface, on a local network with only one gateway. Routing is controlled by a table called the routing table, which is maintained by the kernel. To view the routing table, using the route command:
View the routing table, using the route command. If you are on a laptop or PC, place your mouse over the IP address table below to see information displayed regarding the table.
How does one monitor traffic for Network Addresses?
Output of the route command
Any traffic destined for the network address 18.104.22.168 (the local network) does not need a gateway, and should be sent out interface eth0.
Any traffic intended for network address 127.0.0.1 (the loopback address) should be sent out the loopback interface.
Traffic not intended for the local network or the loopback address defaults to the machine 22.214.171.124, which is the gateway machine.
“U” indicates that the route is UP.
“G” indicated that the route is a gateway.
Reading Routes and IP Information
Assuming an already configured machine named isolde, let uslook at the IP addressing and routing table. Next we will examine how the machine communicates with computers (hosts) on the locally reachable network. We will then send packets through our default gateway to other networks. After learning what a default route is, we will look at a static route.
One of the first things to learn about a machine attached to an IP network is its IP address. We will begin by looking at a machine named isolde on the main desktop network (192.168.99.0/24). The machine isolde is alive on IP 192.168.99.35 and has been properly configured by the system administrator. By examining the route and ifconfig output we can learn a good deal about the network to which isolde is connected.
On Solaris, use the command netstat -nr to dump the routing table. The output is nearly identical to the output of the route command used on Linux. The routing table gives a list of potential destinations, and for each destination, the IP address of a gateway. Information intended for one of the listed destinations is sent to the specified gateway.
We are assuming that this machine is on a local network with only one gateway (this is a typical situation), so any traffic not for the local network should be directed to that gateway.
The only entry in the routing table that needs to be set is the default route, because the local route is set automatically by the ifconfig command. To set the default route, use:
host# /sbin/route add default gw [address]
The route command may also be used to delete a route: