LXC Container: Use dhcp, but ignore default route?

Dec 6, 2021
8
0
6
40
Hi,

i want to setup a container, which uses VPN and only VPN to access the internet. For that I want to remove the default route from the network config, so that if the VPN is down, it doesn't have any way to access the internet. VPN works, but I am struggling with the default route. What is the best way to achieve this? If I use a fixed IP, my router won't be reachable using a DNS entry, since my routers DNS server won't know about it, never being asked for an IP. I also don't want to manually handle DNS entries. If I use DHCP, I seem to not be able to tell the container to only apply the IP but not the routes. Does someone here have an idea to create such a network setup?

Thanks!
 
Ok ignore what I said. Removing the default gateway obviously won't work, since the vpn traffic also has to leave the machine in the end. So I am probably looking for a suitable iptables ruleset now