Weird thing. I'm runinng latest Proxmox 5.1 with CentOS 7 LXC container inside. It's "multi-homed", i.e. having 2 networks attached with 2 different Internet IPv4's. This takes iproute2 rules to work. And such setup usually works perfectly fine for me with KVM/OpenVZ/Physical hosts. I just create 2 new tables in /etc/iproute2/rt_tables. Called for example isp1 and isp2. Assume isp1 has IP 1.2.3.4 with gateway x.x.x.x and isp2 has IP 2.3.4.5 with gw y.y.y.y. Then I do:
This makes isp1 my default link for any outgoing connections. But I can accept connection on isp2 link and rules ensure that reply packets goes through eth2 interface that way.
Then I did this with LXC for 1st time I've encountered error with UDP packets that way. I'm running OpenVPN server in UDP mode. Config doesn't specifies interface to listen, i.e. it listens on all interfaces. But when I'm trying to connect to 2.3.4.5, I can see UDP packets reaching eth2/isp2 interface, but replies are coming from eth1/isp1 with 1.2.3.4 as source IP. And everything works fine if I use TCP mode of OpenVPN instead. Any thoughts?
Code:
ip route add default via x.x.x.x dev eth1 src 1.2.3.4 table isp1
ip route add default via y.y.y.y dev eth2 src 2.3.4.5 table isp2
ip rule add from 1.2.3.4 lookup isp1
ip rule add from 2.3.4.5 lookup isp2
ip route add default via x.x.x.x dev eth1
Then I did this with LXC for 1st time I've encountered error with UDP packets that way. I'm running OpenVPN server in UDP mode. Config doesn't specifies interface to listen, i.e. it listens on all interfaces. But when I'm trying to connect to 2.3.4.5, I can see UDP packets reaching eth2/isp2 interface, but replies are coming from eth1/isp1 with 1.2.3.4 as source IP. And everything works fine if I use TCP mode of OpenVPN instead. Any thoughts?