On my PC I have to following routing table:

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface         UG        0 0          0 wlan0   U         0 0          0 wlan0

I don't understand how it is analyzed, I mean from top-down or bottom-up?

If it is analyzed from top-down then everything will always be sent to the router in my home even though the IP destination was; but what I knew (wrongly?) was that if a PC is inside my same local network then once I recovered the MAC destination through a broadcast message then my PC could send directly the message to the destination.

2 Answers 2


The routing table is used in order of most specific to least specific.

However on linux it's a bit more complicated than you might expect. Firstly there is more than one routing table, and when which routing table is used is dependent on a number of rules.

To get the full picture:

$ ip rule show
0:  from all lookup local 
32766:  from all lookup main 
32767:  from all lookup default

$ ip route show table local
broadcast dev lo  proto kernel  scope link  src 
local dev lo  proto kernel  scope host  src 
local dev lo  proto kernel  scope host  src 
broadcast dev lo  proto kernel  scope link  src 
broadcast dev eth0  proto kernel  scope link  src 
local dev eth0  proto kernel  scope host  src 
broadcast dev eth0  proto kernel  scope link  src 

$ ip route show table main
default via dev eth0 dev eth0  proto kernel  scope link  src 

$ ip route show table default


The local table is the special routing table containing high priority control routes for local and broadcast addresses.

The main table is the normal routing table containing all non-policy routes. This is also the table you get to see if you simply execute ip route show (or ip ro for short). I recommend not using the old route command anymore, as it only shows the main table and its output format is somewhat archaic.

The table default is empty and reserved for post-processing if previous default rules did not select the packet.

You can add your own tables and add rules to use those in specific cases. One example is if you have two internet connections, but one host or subnet must always be routed via one particular internet connection.

The Policy Routing with Linux book explains all this in exquisite detail.

  • is there a way to change that priority ?
    – Mheni
    May 30, 2018 at 15:59

The routing table is usually applied in order from "most specific" to "least specific". A destination of with a netmask of, i.e. your default route, is the least specific possible and so will always be applied last.

If you had the MAC address for another PC on your local network, but that was on a different subnet, you could add a specific host route for that PC and you would probably get communication.

  • s/usually/always/ . That's pretty fundamental to the way routing tables work.
    – Celada
    Mar 6, 2015 at 11:12
  • 2
    @Celada I have omitted mention of metrics for "same specific" routes. And then there's policy routing. For the moment at least, I stand by usually.
    – roaima
    Mar 6, 2015 at 11:27
  • @roaima Could you please a bit clarify what you mean by "same specific" routes? Does policy routing have some specificity compared with regular routing? I thought that the priority in all the routing tables is defined based on Longest Prefix Match - so the longest prefix is more specific.
    – NK-cell
    Jun 11, 2021 at 14:41
  • 1
    @NK-cell we're getting way into deep water territory here. Consider a computer with a wired connection to a local network and also wireless to that same local network. Imagine the computer has (wired) and (wireless). Both addresses would reference the same gateway for an example named route In order to ensure that the (faster?) wired network takes precedence, the routing table has a has a lower metric for this route via than the route via Two of the same specific routes, one with a priority over the other. Does this help you?
    – roaima
    Jun 11, 2021 at 14:49
  • @roaima This helped, thanks! But what's the reason for having the second(slower) route? Will not traffic never go through it? I'll try to explain what's still unclear for me. Consider the following. We have two routes: via, and 10.11.12/24 via with the same metrics. In usual destination routing the longest prefix match will choose because the destination is more specific. Returning to your comment "I stand by usually": Is there some unusual routing, where can be chosen? Sorry if my question is a bit stupid.
    – NK-cell
    Jun 11, 2021 at 18:35

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.