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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With