i'm trying to setup a linux machine as router for the following subnets:
+--------------------------------------------+ host3 | router | 10.1.0.254 | | | | | | | | | -----------------------------+ ---+ eth1 eth3 +--- +--------------------+----- 10.1.0.0/16 | | 10.1.0.254 10.1.0.1 | | 10.1.0.0/16 subnet1 | | | | subnet3 | | | | | | forward forward | | | | | | | | | | -----------------------------+ ---+ eth2 eth4 +--- +-------------------------- 10.2.0.0./16 | 10.2.0.254 10.2.0.254 | 10.2.0.0/16 subnet2 | | subnet4 +--------------------------------------------+
the router should:
- forward traffic between subnet1 and sebnet2.
- forward traffic between subnet3 and setnet4.
- keep subnets 1+2 isolated from subnets 3+4
i've implemented this setup using
- ip route (4 route tables, 1 per nic)
- ip rule (each nic is associated with a its own route table)
this works well with one exception:
- traffic gets forwarded between subnets 1 and 2.
- traffic gets forwarded between subnets 3 and 4.
- the one exception is host3
- it cannot send/receive traffic from subnet4
- it cannot get an arp reply for 10.1.0.1.
- its ip is identical to the router's own ip on eth1.
- if i give host3 a different ip on subnet3, all issues are resolved.
for reasons outside the scope of this post i cannot change its ip.
i also can't change eth1's ip.
googling similar issues pointed me to the local route table.
- the local route table has a route entry for eth1's ip (created automatically)
- this table has the highest priority in the system and appears to be hijacking host3's traffic.
- i tried deleting this entry -
ip route del table local 10.1.0.254 dev eth1 proto kernel scope host src 10.1.0.254
- it solves the issue, host3 can send/receives traffic from subnet4.
- it's not a real solution however because eth1 stops replying to arp requests from subnet1.
(unnoticeable as long as subnet1 hosts have its MAC cached).
what is the proper solution to this issue?
how do i keep the local route table from "coupling" these L3 domains i'm trying to keep separate?
how do i disable local route entries without loosing arp functionality?
(eth1-4 are only used for forwarding, they're never themselves the target of any tcp traffic)