LXC iproute2 ip rule & udp packets


Active Member
Dec 23, 2011
Russia, Rostov-na-Donu
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 with gateway x.x.x.x and isp2 has IP with gw y.y.y.y. Then I do:
ip route add default via x.x.x.x dev eth1 src table isp1
ip route add default via y.y.y.y dev eth2 src table isp2
ip rule add from lookup isp1
ip rule add from lookup isp2
ip route add default via x.x.x.x dev eth1
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, I can see UDP packets reaching eth2/isp2 interface, but replies are coming from eth1/isp1 with as source IP. And everything works fine if I use TCP mode of OpenVPN instead. Any thoughts?
That's not an LXC or OS issue, openvpn works like this (you will get rid of it when you bind it to a specific address).
  • Like
Reactions: NStorm


The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!