I have an oddly-specific networking question that I'm hoping to get solved (and would like to have Lemmy be the home of the solution, in case I stumble upon this myself.)
I have a device that needs to "phone home" on a weekly basis. This device needs to have a static IP in order to be "valid". On windows, I usually can get it to work by starting openvpn, plugging in the external device in question and "routing that" through Openvpn. You do this by simply connecting the external nic and then right click on the nic in the control panel and set the "Allow other network users to connect through this computer's internet connection" along with assigning the external device to the OpenVPN connection. This routes all internet packets from X device to the internet via the OpenVPN connection without a major problem. I should note that it's extremely fickle, and it hurts my ability to remote in the machine on occasion, so I'm looking to change it.
What I'd like on my linux system is to simulate the same setup, but with 1) a permanent "connection" to the openvpn end point that is always available but not used by most networking tasks on the computer (for example, browser will use standard ethernet connection) and 2) The external nic will automatically route itself through the OpenVPN server, acting as a "router" for a (singular) external device that needs to access the internet.
Is this possible? Are there any guides for setting up this kind of complex network setup? Is it possible to do without going crazy and making my computer a full-blown router (like, doing DHCP work and the like)?
Yes it should be possible, although somewhat challenging.
If this device acts an an ethernet interface that is behind windows, then you are probably going to want:
This is the first solution I can think of, off of the off my head, provided that the external device is actually pretending to be a network interface you are connecting.
In addition to that, you will likely have to create a custom service to recreate this setup on boot. The tools for managing linux firewalls and network namespaces independently of abstraction layers aren't great.
Alternatively, if you are actually running an app that is connecting to that device via USB or the like, you can run that app within a network namespace to force traffic through the VPN. But the steps and solution would be similar.
Thanks, I've been looking into this and it seems like you're probably on the money. When I get some time I'll mess with this.