Re: Generate traffic with only one machine - what's wrong with this routing?
- From: Pascal Hambourg <boite-a-spam@xxxxxxxxxxxxxxx>
- Date: Thu, 07 May 2009 16:54:51 +0200
Hello,
purplerain a écrit :
So basically I tried to set up
a routing which send out any packet generated on this host to an
external interface even if the IP address is assigned to interface
attached on this host.
You cannot do this with a standard kernel.
Here is my solution:[...]
ip route del local 10.0.1.1 table local
ip route del local 10.0.1.11 table local
# add local delivery route for the packets coming from outside
# basically it's moving the routes deleted above from table local to
table main
ip route add local 10.0.1.1 dev eth1 proto kernel table main
ip route add local 10.0.1.11 dev eth2 proto kernel table main
AFAIK, local routes are valid only in the local table.
But it does't work:[...]
---------------
clapham:~# ping 10.0.1.1
connect: Invalid argument
clapham:~# ping 10.0.1.11
connect: Invalid argument
the "connect: Invalid argument" message is somewhat disturbing. It
seems like an sytax error in the routing tables. But everything is
O.K. until I delete the routes in the local table.
My explanation : a local route in the local table is what really makes the destination local, what makes the routing subsystem recognize an address as its own. Removing the local route to 10.0.1.1 from the local table has the same effect on routing as removing 10.0.1.1 from eth1. 10.0.1.1 is used as a source address in the main table route to 10.0.1.11 but is not a local address (and the source address must be a local address), I guess this is what causes the error message.
I delete the one route in the local table:
------------
ip route del local 10.0.1.1 table local
-------------
pinging 10.0.1.1 is now partly successful:
-------------
clapham:~# ping 10.0.1.1
PING 10.0.1.1 (10.0.1.1) 56(84) bytes of data.
From 10.0.1.11 icmp_seq=1 Destination Host Unreachable
From 10.0.1.11 icmp_seq=2 Destination Host Unreachable
-----------
the packets are sent out on the other interface eth2 as the "From
10.0.1.11" tells - just as intended. Both interfaces are connected to
the same switch. But the packet is not recognized as local entering
eth1.
As I wrote, removing the local route to 10.0.1.1 from the local table makes the routing subsystem consider that the address is not local, and discard incoming packets destined to it.
.
- References:
- Prev by Date: Re: Socket: recvfrom
- Next by Date: Re: Linux sys as a ADSL router?
- Previous by thread: Generate traffic with only one machine - what's wrong with this routing?
- Next by thread: Linux sys as a ADSL router?
- Index(es):
Relevant Pages
|