Networking Forums

Networking Forums > Computer Networking > Linux Networking > Generate traffic with only one machine - what's wrong with thisrouting?

Reply
Thread Tools Display Modes

Generate traffic with only one machine - what's wrong with thisrouting?

 
 
purplerain
Guest
Posts: n/a

 
      05-06-2009, 10:04 AM
I'm trying to generate Ip-traffic for testing purproses. As we now are
testing multipoint performance of PLC networks I need some 4 to 8
endpoints to communicate but I can't afford to set up a dedicated
linux box for each endpoint.
After looking into kernel routing I found that the routing of packets
can also depend of the incoming device. 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.
Here is my solution:
---------------
clapham:~# ip addr show
4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UP qlen 1000
link/ether 00:50:8b:b2:47:fb brd ff:ff:ff:ff:ff:ff
inet 10.0.1.1/24 brd 10.0.1.255 scope global eth1
inet6 fe80::250:8bff:feb2:47fb/64 scope link
valid_lft forever preferred_lft forever
5: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UP qlen 1000
link/ether 00:50:8b:b2:47:fc brd ff:ff:ff:ff:ff:ff
inet 10.0.1.11/24 brd 10.0.1.255 scope global eth2
inet6 fe80::250:8bff:feb2:47fc/64 scope link
valid_lft forever preferred_lft forever
--------------
I will try to run traffic from eth1 to eth2. Here is my batch file to
modify the routing:
--------------
clapham:~# cat setnetix
# add routing policy if packet generated on host
ip rule add to 10.0.1.0/24 iif lo table ixchariot
# if all packets generated on host are sent out on the other interface
ip route add 10.0.1.11 table ixchariot dev eth1 src 10.0.1.1 proto
ixchariot
ip route add 10.0.1.1 table ixchariot dev eth2 src 10.0.1.11 proto
ixchariot
# routes in table local are always processed - delete the routes
# making local delivery of the packets with the interface ip address
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
---------------
I have added the table "ixchariot" into \etc\iproute2\rt_tables with
the ID 7 and the protocol "ixchariot" into \etc\iproute2\rt_protos
with the ID 77.
My routing policy seems O.K.:
---------------
clapham:~# ip rule show
0: from all lookup local
32765: from all to 10.0.1.0/24 iif lo lookup ixchariot
32766: from all lookup main
32767: from all lookup default
---------------
The main table seems O.K.:
---------------
clapham:~# ip route show table main
local 10.0.1.11 dev eth2 proto kernel scope host
local 10.0.1.1 dev eth1 proto kernel scope host
192.168.178.0/24 dev eth0 proto kernel scope link src
192.168.178.98
10.0.1.0/24 dev eth1 proto kernel scope link src 10.0.1.1
10.0.1.0/24 dev eth2 proto kernel scope link src 10.0.1.11
default via 192.168.178.254 dev eth0
---------------
But it does't work:
---------------
clapham:~# ping 10.0.1.1
connect: Invalid argument
clapham:~# ping 10.0.1.11
connect: Invalid argument
clapham:~# ping 192.168.178.98
PING 192.168.178.98 (192.168.178.98) 56(84) bytes of data.
64 bytes from 192.168.178.98: icmp_seq=1 ttl=64 time=0.132 ms
64 bytes from 192.168.178.98: icmp_seq=2 ttl=64 time=0.047 ms
------------------

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. So the first part
af the changes:
-------------
ip rule add to 10.0.1.0/24 iif lo table ixchariot
ip route add 10.0.1.11 table ixchariot dev eth1 src 10.0.1.1 proto
ixchariot
ip route add 10.0.1.1 table ixchariot dev eth2 src 10.0.1.11 proto
ixchariot
ip route add local 10.0.1.1 dev eth1 proto ixchariot scope host src
10.0.1.1 table main
ip route add local 10.0.1.11 dev eth2 proto ixchariot scope host src
10.0.1.11 table main
------------
has no effect on the routing of packets to 10.0.1.1 as the route in
the local table are processed first. 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.
If I delete the other route in the local table I get the strange error
message again:
----------
clapham:~# ip route del local 10.0.1.11 table local
clapham:~# ping 10.0.1.1
connect: Invalid argument
clapham:~# ping 10.0.1.11
connect: Invalid argument
--------------
it seems that the following lines in table main:
--------------
local 10.0.1.11 dev eth2 proto ixchariot scope host src 10.0.1.11
local 10.0.1.1 dev eth1 proto ixchariot scope host src 10.0.1.1
--------------
have not the same effect as the deleted lines from table local:
--------------
local 10.0.1.11 dev eth2 proto kernel scope host src 10.0.1.11
local 10.0.1.1 dev eth1 proto kernel scope host src 10.0.1.1
-------------

Any hints?

 
Reply With Quote
 
 
 
 
Pascal Hambourg
Guest
Posts: n/a

 
      05-07-2009, 02:54 PM
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.
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Traffic going through wrong interface Rodrigo A B Freire Linux Networking 8 08-09-2007 05:10 PM
MSCS: Outbound traffic to different subnet uses wrong NIC tachnem Windows Networking 1 07-25-2007 02:26 AM
Howto redirect traffic from local machine to internet back to local machine? Martin Kahlert Linux Networking 0 11-25-2005 07:40 AM
How can I generate TCP/IP traffic (L2 lever and L3 lavel) santa19992000@yahoo.com Linux Networking 5 04-17-2005 09:27 AM
HELP: How to generate a CBR traffic? catnaps Linux Networking 1 03-16-2005 11:51 AM



1 2 3 4 5 6 7 8 9 10 11