I'm trying to simulate many network hops, similar to Star Wars Traceroute. The author provided a script here, however it's designed for Cisco routers by using vrf
, rather than Linux.
Here is my current attempt;
echo 1 > /proc/sys/net/ipv4/ip_forward
ifconfig br0 172.16.100.1 netmask 255.255.255.0
ifconfig br0:1 172.16.101.1 netmask 255.255.255.0
ifconfig br0:2 172.16.102.1 netmask 255.255.255.0
ifconfig br0:2 172.16.103.1 netmask 255.255.255.0
ip rule add iif br0 table 100
ip rule add iif br0:1 table 101
ip rule add iif br0:2 table 102
ip route add default table 100 dev 172.16.101.1
ip route add default table 101 dev 172.16.102.1
ip route add default table 102 dev 172.16.103.1
ping -I br0 172.16.103.2
I've tried to accomplish the same thing using Source Based Routing, which apparently reproduces the effects of vrf
, see here, but attaching tcpdump -i br0
shows no traffic at all, and the packets are instead being picked up on lo0
.
Alternative solutions seem to include mangling source IPs and other trickery using iptables
which feels quite dirty, so I'm not sure where to focus my efforts.
Any tips/pointers would be appreciated