SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Slackware 14.2 soon to be Slackware 15
Posts: 699
Rep:
Network sharing question with VMs and VPNs.
I currently have a Windows VM that connects to a corporate VPN. I have VirtualBox setup with a "hosts-only" network, which appears in the VM as a network connection. This "host-only" type of network connection can be accessed outside of the VM via whatever ip address you give it inside of the VM.
In Windows, there is a dialog that lets you share this VPN connection with the host-only connection. Once I do that, I can access VPN resources via the hosts-only ip address, outside of the VPN. This works well, I've been doing this for a while. It has limitations. I have to manually set a route for each IP on the VPN I want to access. Since there are only a half dozen of these, this works very well. I do not have, nor do I want, DNS from VPN exposed to my Linux box. No name lookup. I can only access VPN resources by manually setting a route on the linux host, and then I can access it via its ip. I've been doing this for a while now, and it works very well.
So - how do I do this with a Linux VM? In my Linux VM I can see the VPN connection, I think it is gpd1. I see the host-only connection, eth1. I can access this host-only connection via it's ip address outside of the VM. So far so good.
The only step missing is sharing gpd1 through eth1. How, in Linux, do I tell it to share gpd1 through eth1? I do this with Windows and it works but I don't know what it is doing behind the scenes.
To configure your linux box as a router it will need to know where to route different packages (it probably already does know that as you have configured your vpn and eth1) and it will need to be told to let other machines send their traffic through its interfaces. You tell your machine to do that with:
Code:
sysctl -w net.ipv4.ip_forward=1
If you think the above solves your problem you probably want to put that command in some startup file like /etc/rc.d/rc.local or you might want to create a file in /etc/sysctl.d.
Distribution: Slackware 14.2 soon to be Slackware 15
Posts: 699
Original Poster
Rep:
Quote:
Originally Posted by henca
To configure your linux box as a router it will need to know where to route different packages (it probably already does know that as you have configured your vpn and eth1) and it will need to be told to let other machines send their traffic through its interfaces. You tell your machine to do that with:
Code:
sysctl -w net.ipv4.ip_forward=1
If you think the above solves your problem you probably want to put that command in some startup file like /etc/rc.d/rc.local or you might want to create a file in /etc/sysctl.d.
For example /etc/sysctl.d/if_forward.conf:
Code:
net.ipv4.ip_forward=1
regards Henrik
How does that tell it to route traffic from gpd0 through eth1?
Is *absolutely* necessary. Nothing works without it.
It's not at all neccesary because it enables forwarding everywhere on every interface, globally.
More secure practice is to only enable forwarding per specific interface (for example eth0 only):
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.