Yes, you can configure your VPN as a separate network device outside the default setup.
Yes, you can configure your VPN as a separate network device outside the default setup.
I possess Docker containers on a Linux machine that I aim to connect via VPN. The optimal approach is to integrate your VPN as a network interface, allowing the containers to pass through it. (Using WireGuard) Updated July 11, 2024 by Champe21 Specification
You can modify the config file to disable automatic VPN routing while keeping the VPN active by adjusting the settings that control traffic flow. Look for sections related to routing rules or tunneling preferences and set them to prioritize local connections instead of always tunneling through the VPN.
Yeah. You can have more than one gateway defined, and it's the "metric" that decides which of the gateways will be used first (in the case that more than one can reach the same network). In some nomenclature the "default gateway" is sometimes referred to as the "gateway of last resort" to push this point home. We used to control these things with the "route" command, but it's done with "ip route" now. You should be able to find somewhere in your VPN documentation on how set the metric of the gateway it provides, so it's not chosen unless specified. Yeah, I've messed with similar "network configs", using mask bits to route traffic from specific sources differently through the firewall, and even differently through the routing table*. But, I'm not familiar enough with docker and my gut feeling is there is an easier way provided by the way networking is provisioned to containers. *I was working with a "simulation" to help a guy setting it up in hardware. There was a specific reason not to use multiple vlans, which would be much easier.
Gluetun is a small Docker container that creates a tunnel, allowing you to direct traffic from other containers through it. It can also handle routing of external data, though this seems unnecessary for your use case. Learn more at https://github.com/qdm12/gluetun