* Incorrect routing to lo in spite of correct record in routing table
@ 2011-09-12 17:14 Марк Коренберг
2011-09-12 18:47 ` Eric Dumazet
0 siblings, 1 reply; 2+ messages in thread
From: Марк Коренберг @ 2011-09-12 17:14 UTC (permalink / raw)
To: netdev
Suppose this (note netowrk masks):
[mmarkk@mmarkk-devel ~]# uname -a
Linux mmarkk-devel 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT
2010 x86_64 x86_64 x86_64 GNU/Linux
[mmarkk@mmarkk-devel ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
inet 127.0.0.1/32 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UP qlen 1000
inet 10.80.20.21/16 brd 10.80.255.255 scope global eth0
3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN
inet 127.0.0.2/32 scope host dummy0
[mmarkk@mmarkk-devel ~]# ip route show
10.80.0.0/16 dev eth0 proto kernel scope link src 10.80.20.21
unreachable 127.0.0.0/8 <---------------------- has been added by hand
default via 10.80.90.40 dev eth0
[mmarkk@mmarkk-devel ~]# ip route show table local
broadcast 10.80.0.0 dev eth0 proto kernel scope link src 10.80.20.21
local 10.80.20.21 dev eth0 proto kernel scope host src 10.80.20.21
local 127.0.0.2 dev dummy0 proto kernel scope host src 127.0.0.2
broadcast 10.80.255.255 dev eth0 proto kernel scope link src 10.80.20.21
local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1
[mmarkk@mmarkk-devel ~]# ip route flush cache
[mmarkk@mmarkk-devel ~]# ip route get 127.0.0.3
RTNETLINK answers: Network is unreachable <------------ good, that is OK
[mmarkk@mmarkk-devel ~]# ip route get 127.0.0.1
local 127.0.0.1 dev lo src 127.0.0.1 <--------- Good, that's OK too
cache <local> mtu 16436 advmss 16396 hoplimit 64
[mmarkk@mmarkk-devel ~]# ip route get 127.0.0.2
local 127.0.0.2 dev lo src 127.0.0.2 <------------ HAY! this is not I
want. Why device is "lo" (instead of dummy0) ?!
cache <local> mtu 16436 advmss 16396 hoplimit 64
=========================
The problem is that I want to do DNAT to localhost. I know, why DNAT
to 127.0.0.1 (to interface "lo") does not work. I decide to do that
using interface dummy0. It works as expected if I choose any address
not in 127.0.0.0/8.
RFC 3330 said:
-------------
A datagram sent by a higher level protocol to an address anywhere
within this block should loop back inside the host. This is ordinarily
implemented using only 127.0.0.1/32 for loopback, but no addresses
within this block should ever appear on any network anywhere
-------------
So, my question: Why the kernel routes 127.0.0.2 to lo (instead of dummy0) ?
Well, If kernel is so smart to route any 127.0.0.0/8 to "lo", why it
routes 127.0.0.3 to default gateway if I remove "unreachable
127.0.0.0/8" ?!
I think there is some bug in kernel. What are you thinking about?
--
Segmentation fault
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: Incorrect routing to lo in spite of correct record in routing table
2011-09-12 17:14 Incorrect routing to lo in spite of correct record in routing table Марк Коренберг
@ 2011-09-12 18:47 ` Eric Dumazet
0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2011-09-12 18:47 UTC (permalink / raw)
To: Марк Коренберг
Cc: netdev
Le lundi 12 septembre 2011 à 23:14 +0600, Марк Коренберг a écrit :
> Suppose this (note netowrk masks):
>
> [mmarkk@mmarkk-devel ~]# uname -a
> Linux mmarkk-devel 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT
> 2010 x86_64 x86_64 x86_64 GNU/Linux
>
> [mmarkk@mmarkk-devel ~]# ip addr
> 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
> inet 127.0.0.1/32 scope host lo
> 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
> state UP qlen 1000
> inet 10.80.20.21/16 brd 10.80.255.255 scope global eth0
> 3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN
> inet 127.0.0.2/32 scope host dummy0
>
> [mmarkk@mmarkk-devel ~]# ip route show
> 10.80.0.0/16 dev eth0 proto kernel scope link src 10.80.20.21
> unreachable 127.0.0.0/8 <---------------------- has been added by hand
> default via 10.80.90.40 dev eth0
>
> [mmarkk@mmarkk-devel ~]# ip route show table local
> broadcast 10.80.0.0 dev eth0 proto kernel scope link src 10.80.20.21
> local 10.80.20.21 dev eth0 proto kernel scope host src 10.80.20.21
> local 127.0.0.2 dev dummy0 proto kernel scope host src 127.0.0.2
> broadcast 10.80.255.255 dev eth0 proto kernel scope link src 10.80.20.21
> local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1
>
> [mmarkk@mmarkk-devel ~]# ip route flush cache
>
> [mmarkk@mmarkk-devel ~]# ip route get 127.0.0.3
> RTNETLINK answers: Network is unreachable <------------ good, that is OK
>
> [mmarkk@mmarkk-devel ~]# ip route get 127.0.0.1
> local 127.0.0.1 dev lo src 127.0.0.1 <--------- Good, that's OK too
> cache <local> mtu 16436 advmss 16396 hoplimit 64
>
> [mmarkk@mmarkk-devel ~]# ip route get 127.0.0.2
> local 127.0.0.2 dev lo src 127.0.0.2 <------------ HAY! this is not I
> want. Why device is "lo" (instead of dummy0) ?!
> cache <local> mtu 16436 advmss 16396 hoplimit 64
>
> =========================
> The problem is that I want to do DNAT to localhost. I know, why DNAT
> to 127.0.0.1 (to interface "lo") does not work. I decide to do that
> using interface dummy0. It works as expected if I choose any address
> not in 127.0.0.0/8.
>
> RFC 3330 said:
> -------------
> A datagram sent by a higher level protocol to an address anywhere
> within this block should loop back inside the host. This is ordinarily
> implemented using only 127.0.0.1/32 for loopback, but no addresses
> within this block should ever appear on any network anywhere
> -------------
> So, my question: Why the kernel routes 127.0.0.2 to lo (instead of dummy0) ?
>
> Well, If kernel is so smart to route any 127.0.0.0/8 to "lo", why it
> routes 127.0.0.3 to default gateway if I remove "unreachable
> 127.0.0.0/8" ?!
>
Because you have 127.0.0.1/32 on lo, not 127.0.0.1/8
> I think there is some bug in kernel. What are you thinking about?
>
I have no idea why you think there is a bug.
127.0.0.2 (dummy0) is a local address like 10.80.20.21 (eth0)
When you ping 10.80.20.21, the frame goes through loopback, not eth0.
# ip ro get 10.80.20.21
local 10.80.20.21 dev lo src 10.80.20.21
cache <local>
BTW, if you 'ifconfig lo down', ping to 10.80.20.21 doesnt work.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-09-12 18:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-12 17:14 Incorrect routing to lo in spite of correct record in routing table Марк Коренберг
2011-09-12 18:47 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox