$ sudo docker run --rm ubuntu:14.04 route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    0      0        0 eth0     U     0      0        0 eth0

Doesn't this mean that is routed towards the gateway of and not the loopback device ?

  • I meant: Why isn't there a route for loopback in Ubuntu?
    – Balazs Rau
    Apr 17, 2015 at 14:02
  • I suppose explicit routes for loopback network are from the past. Seeing your question I take a look to some of our servers and there are no routes on the routing table for loopback. That's also valid for Solaris 10, not for Solaris 8 (yeah, we still have some boxes with Solaris 8). Apr 17, 2015 at 14:11

2 Answers 2


The route command is deprecated, and should not be used anymore.

The new way is to use the iproute set of commands, which are all invoked with ip followed by an object. For example:

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

Now, I hear you say, this is basically the same info! Yes, but this isn't the whole story. Before the routing tables (yes, plural) comes the rule table:

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

The routing table we were looking at before is the main routing table. Your question concerns the local routing table, which contains all routes relating to local connections. This table can be shown as follows:

$ ip ro sh 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

(You can abbreviate ip options / parameters as long as they're still unique, hence ip ro sh is the same as ip route show.)

Here you can see the loopback routes.

You can do all sorts of wonderful things with this policy-based routing, I recommend you read Policy Routing with Linux by Matthew G. Marsh for all the info you'll ever need.

  • 1
    Just a concern about your wording: His question was actually about routing for local addresses ( table local is the answer, but not the question. It's the answer because traffic to any 127.* address gets converted to having a source address of, and I think also is forced to use dev lo. Apr 17, 2015 at 22:18
  • 1
    So the real answer to the question is "because loopback is special and doesn't need one", is the real answer. None of those routing table entries say anything about how to route to, for example, but it still works (as you can tell from ping times). Presumably the networking code special-cases local addresses for performance reasons, since ip addr doesn't show lo having more than just as its own address, but it will actually receive traffic for any ip in 127.../8 Apr 17, 2015 at 22:23
  • 4
    @PeterCordes Actually the line local dev lo proto kernel scope host src covers the route to; it means that anything starting with 127. is local.
    – wurtel
    Apr 20, 2015 at 7:08
  • Ah, ok I hadn't understood everything that a local entry in the local table implied. Thanks. Apr 20, 2015 at 8:25

The route command was old since 10 years ago and you should go with the iproute2 packages.

When you're using ip route show the main table is displayed. To display the local table use ip route show table local.

Hope it helped.

You must log in to answer this question.

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