Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Routing table entry

I want to ask a question about route command in Linux. I have enter following command in Linux terminal

> route 

and got the output:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface 192.168.1.0     *               255.255.255.0   U     1      0        0 eth0 192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0 link-local      *               255.255.0.0     U     1000   0        0 eth0 default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0 

I don't understand it. Does this mean that any packet with ip 192.168.1.0 will go out from * gateway? Why is it DESTINATION written there shouldn't it be source because the packet going out from my host have source IP of 192.168.1.0?

Can anyone explain me the meaning of this entry in terms of packet going out and coming to my host?

like image 259
mainajaved Avatar asked Dec 22 '11 04:12

mainajaved


People also ask

What is Route table entry?

Each entry in a routing table—called a route entry or route —is identified by the destination network to which traffic can be forwarded. The destination network, in the form of an IP address and netmask, can be an IP network, subnetwork, supernet, or a host.

What does the first line in the routing table mean?

The first line says that the default route for any packet (i.e., the route which is taken by a packet when no other route applies) is through the network device wlan0 via the default gateway (the router) which has the IP address 192.168.


1 Answers

Let's go through the lines one by one:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface 192.168.1.0     *               255.255.255.0   U     1      0        0 eth0 

This says that any packet with a destination of 192.168.1.0 through 192.168.1.255 will be sent out eth0 without using a gateway (unless a more-specific route overrides this one).

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface 192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0 

This says that any packet with a destination of 192.168.122.0 through 192.168.122.255 will be sent out virbr0 without using a gateway. (Again, unless a more-specific route overrides this one.)

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface link-local      *               255.255.0.0     U     1000   0        0 eth0 

This says that any packet with a link-local address will be sent out interface eth0 with no gateway.

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0 

This says that any packet to a destination without another route will be sent out eth0, using 192.168.1.1 as a gateway.

like image 169
David Schwartz Avatar answered Oct 14 '22 04:10

David Schwartz