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.

  • As you don't explain how the interfaces are connected, it's hard to tell which one is "closer to the Internet". Also given several answers, would you care to accept one of those?
    – U. Windl
    Sep 30, 2022 at 6:35

5 Answers 5


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, headed for the gateway.

There is no way to say which route is "closer" to the internet as none of those routes deal with publicly routed addresses, rather those are all Class A private addresses. Class A, B, and C addresses ranges that are reserved for private use and are not typically routed to the internet. It is entirely possible that the packets will be routed through other networks before reaching the internet or they may never reach the internet at all.

  • There are two record in the route table handled by eth1. Does that mean eth1 connects two networks? When different packets arrives, does eth1 sends the packets to different network based on the destination ip address?
    – Ryan Lyu
    Mar 9, 2022 at 7:10
  • 1
    @RyanLyu Eth1 itself is only connected to one network, as indicated by the single network route ( However, the default route ( is also on eth1, so any traffic not handled by a more specific route (bitmask greater than 0) will be handled by the default route and sent out through eth1. For instance, traffic destined for the network will be sent out eth0, due to the more specific (/24) route.
    – smokes2345
    Mar 15, 2022 at 21:13

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 sent out over eth1, and a packet to is sent 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.

  • the destination for first route record is not a gateway. when eth1 gets the packets to, what will eth1 do? who is the next step?
    – Ryan Lyu
    Mar 9, 2022 at 7:15

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .