networking - How to forward packets from one network interface via another interface -
see picture below architecture.
i know there lot of similar questions. however, having read multiple posts , trying out still unable set required. posting new question.
scenario:
- i have 3 containers (c1, c2 , c3)
- i have different interfaces each running in 3 containers (eth0 , peervpnxx)
- c1 has interfaces: eth0 , peervpn12
- c2 has interfaces: eth0 , peervpn12 , peervpn23
- c3 has interfaces: eth0 , peervpn23
whilst eth0 interfaces on same subnet peervpnxx interfaces on different subnets:
- peervpn12 - 10.12.0.0/24
- peervpn23 - 10.23.0.0/24
note peervpnxx interfaces tunnel interfaces running on top of eth0
now ip_addresses assigned each container follows:
- c1 : 172.17.0.2 (eth0) , 10.12.0.2 (peervpn12)
- c2 : 172.17.0.3 (eth0) , 10.12.0.1 (peervpn12) , 10.23.0.1 (peervpn23)
- c3 : 172.17.0.4 (eth0) , 10.23.0.2 (peervpn23)
what trying enable c1 communicate c3 via middleman c2. in principle, trying to:
- route packets intended 10.23.0.0/24 c1 c3 via c2.
- route packets intended 10.12.0.0/24 c3 c1 via c2.
i created routing rule on c1 & c3 send packets subnets 10.23.0.0/24 & 10.12.0.0/24 via interfaces peervpn12 , peervpn23. however, think missing forwarding rule needs set on c2.
ps: assume 'eth0' interface locked down , used underlying interface route packets of 'peervpnxx' interface
any regards figuring highly appreciated.
thank in advance.
shabir
managed find issue.
whilst adding route container in other subnet haven't correctly specified gateway. gateway still points host machine in docker run (see above figure). added correct routing rule specific 2 end-containers - c1 & c3.
c1 - ip route add 10.23.0.0/24 via 10.12.0.1 dev peervpn12 c3 - ip route add 10.12.0.0/24 via 10.23.0.1 dev peervpn23
in meantime, had add correct forward rules in c2 container's iptables:
iptables -a forward -s 10.12.0.2 -i peervpn12 -d 10.23.0.2 -o peervpn23 -j accept iptables -a forward -s 10.23.0.2 -i peervpn23 -d 10.12.0.2 -o peervpn12 -j accept
with setup able achieve flow expected.
thank , don't know why it's down-voted.
maybe if know reason can correct myself in future :)
Comments
Post a Comment