I'm trying to learn Linux routing tables and ran into bit of snag. In the example below I'm not sure what is happening. My understanding is means that for line 1 and 2 any packets outside of its network look at the default gateway

Destination Gateway Genmask       Flags MSS Window  irtt    Iface  U   40  0          0    eth1  U   40  0          0    eth0     UG  40  0           0   eth1

So my question is this, which interface is closer to the Internet? Im not sure if packets immediate leave eth0 and eth1 sends packets to the gateway or if both eth0 and eth1 both route packets to for the Internet.


You don't get it completely right. The first two lines tell you that there is no »gateway« for reaching networks and, but they are reachable through the respective interfaces eth1 and eth0, respectively. So if you want to send a packet to, the packet is send out over eth1, a packet to over eth0.

To reach »the Internet«, the destination address won't be in the networks or so the last line would match ( and the kernel would know that it would have to send the packet to the given gateway ( A dependent routing decision would be made to decide how to reach this gateway and as mentioned earlier, this would be made possible by sending the packet out over interface eth1.


Economic routers, have 2 IP addresses

  1. LAN, 99% is and we can (should) change it.
  2. WAN. It is assigned automatically by ISP

The Gateway is the address to which packet are destinated, in each computer it is setted using DHCP (most times), if gateway is not setted computers in your LAN can communicate, but can't send packets outside.

Here you can find the answer well explained: https://stackoverflow.com/questions/8599424/understanding-routing-table-entry


in your routing table you computer know about 2 subnetwork.
rest traffic will be send to your gateway (

what does mean? if you send packet to addres from subnet 1, then your computer try send it via eth1.

Answer to your question is that eth1 is nearest "internet", because each ask to internet will go thru (gateway).


So my question is this, which interface is closer to the Internet?

None of them - is not globally routable as of RFC 1918. However, the third entry says that is the default gateway (traffic to goes there except for destinations at and, which may have a route (using NAT) to the Internet. In this case eth1 is "closer" to the Internet (in a suitable sense).


When a packet is sent to the IP stack, the driver searches your routing table for the route that best matches the destination IP address. It does this by performing a binary and of the destination defined in each route and the destination defined in the packet. Whichever result most closely matches the destination defined in the packet is the route the driver uses. If there is a default gateway defined for that route then the packet is sent to the gateway. If there is no gateway defined for that route then it is assumed that the destination is on the local network and the packet is sent directly to the destination.

Thus, a packet with a destination address of will match the route and will leave on port eth0 as configured by the second route. A packet with a destination address of will leave on eth1 as configured by the first route. Any other destination address will only match the third route and will leave via eth1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.