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:
Code:
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:
Code:
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.:
Code:
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.:
Code:
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:
Code:
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
Any ideas how to pinpoint the problem?