How to route one bridge connect to one pppoe

Assume that we have 5 docker networks (DN1, DN2... DN5) and 5 pppoe connections (WAN1, WAN2... WAN5)
I need to route docker network 1 (DN1) to use WAN1 to connect to internet, DN2 use WAN2 and so on.

I have try iptables:
#172.17.1.2 is docker1's ip address in DN1 network
iptables -t nat -A POSTROUTING -s 172.17.1.2 -o WAN1 -j MASQUERADE
#172.17.2.2 is docker2's ip address (DN2 network)
iptables -t nat -A POSTROUTING -s 172.17.2.2 -o WAN2 -j MASQUERADE
but when I check public ip in both docker1 and docker2, they are the same (WAN1) ip

I also try
brctl addbr br-DN1 #add another bridge that contain Docker Network Interface and PPPoe Interface
brctl addif br-DN1 DN1
brctl addif br-DN1 WAN1

brctl addbr br-DN2 #add another bridge that contain Docker Network Interface and PPPoe Interface
brctl addif br-DN2 DN2
brctl addif br-DN2 WAN2
But both could not connect to internet

Don't know why, please help or any suggest

1 Like