LXC iproute2 ip rule & udp packets

NStorm

Active Member
Dec 23, 2011
64
2
28
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 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:
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
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?
 
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

About

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!