Page 1 of 1
Bind NAT network to a host interface
Posted: 5. Oct 2015, 02:26
by leonbnu
Is there a way to bind the NAT network to a host interface instead of iP address?
Host: Win 7
Guest: Linux
Use case:
I am running Vbox on my laptop, which has both Lan and Wlan. When I am at my desk, they will both be connected. When I move around, only Wlan is connected. Even though the manual showed a way to bind nat to an ip,
Code: Select all
VBoxManage setextradata global "NAT/win-nat-test-0/SourceIp4" 192.168.1.185
But this is not very flexible, since the IP address changes due to DHCP.
So I am wondering if there is a way to bind NAT network to an interface instead of IP?
Thanks,
Re: Bind NAT network to a host interface
Posted: 5. Oct 2015, 03:26
by TSU
Based on how I use VBox,
That's how things already work.
NAT(actually I use nat-network to support multiple Guests in the same virtual network) binds to a bridging device which in turn is associated with a network interface (in my case, my laptop's wlan).
When I move from one Internet connection to another, my WLAN will connect to whatever AP is available and is issued a different IP address each time. So the interface is always the same but the IP address is always changing.
Exclusive of these physical network changes outside the NAT network, nothing in the Guests change. They can connect to other Guests in the nat-network and have access to the Internet without any changes at all.
If you have both LAN and WLAN connected simultaneously to the physical network, in the first place that is a big no-no.
Windows today has some code to manage this common newbie mistake but I haven't seen anything comparable in Linux... You have to connect only <one> physical network connect and configure your Guest settings to connect to a virtual bridging device that is associated with that interface.
Re: Bind NAT network to a host interface
Posted: 5. Oct 2015, 04:32
by leonbnu
TSU wrote:
If you have both LAN and WLAN connected simultaneously to the physical network, in the first place that is a big no-no.
Windows today has some code to manage this common newbie mistake but I haven't seen anything comparable in Linux... You have to connect only <one> physical network connect and configure your Guest settings to connect to a virtual bridging device that is associated with that interface.
big no no? no modern OS would disable multiple network interfaces...
Re: Bind NAT network to a host interface
Posted: 5. Oct 2015, 06:35
by BillG
Why not? If you are on a desktop connected to Gigabit Ethernet, why would you enable Wi Fi?
Re: Bind NAT network to a host interface
Posted: 5. Oct 2015, 11:14
by socratis
Because they might be on different subnets?
I do it all the time at home, where my WLAN is connected to the Internet (via a 192.168.x.x DHCP assigned address from the router) and my wired is connected to my (non-internet enabled) SAN network (10.0.10.x, static). When I'm at the office, the wired is disabled. If you haven't seen "Locations" on a MacOS X, take a look at this article:
https://support.apple.com/en-us/HT202480
Re: Bind NAT network to a host interface
Posted: 5. Oct 2015, 20:43
by leonbnu
socratis wrote:Because they might be on different subnets?
I do it all the time at home, where my WLAN is connected to the Internet (via a 192.168.x.x DHCP assigned address from the router) and my wired is connected to my (non-internet enabled) SAN network (10.0.10.x, static). When I'm at the office, the wired is disabled. If you haven't seen "Locations" on a MacOS X, take a look at this article:
https://support.apple.com/en-us/HT202480
exactly! They are two different networks in my case as well, I work mostly in my linux vm through ssh connections to servers at work. Sometimes I need grab my laptop and go to some meetings without disrupting the ssh sessions. And yes I know, there are "screen/tmux" for that. But that's really not ideal, sometimes I skip that for short tasks which turns out take more time, and it doesn't work for some other types of connections, e.g. long lived http connections, etc.
With that being said, the current work around I have been using is setting a smaller default route metric for the wireless adapter. But this has limitations, e.g. everything on the host will go through the wireless adapter as well.