Automatically change bridged adapter name on connection
Automatically change bridged adapter name on connection
Is there a way to get VirtualBox to automatically select the bridged adapter based on what your computer is connected to? For instance, if I'm connected by land line, it should select my land card. If I'm connected only to wifi, it should select my wifi card.
-
- Site Moderator
- Posts: 34369
- Joined: 6. Sep 2008, 22:55
- Primary OS: Linux other
- VBox Version: OSE self-compiled
- Guest OSses: *NIX
Re: Automatically change bridged adapter name on connection
Why not set up a second adapter? Choose the connection type other than the one that you have in the first.
Re: Automatically change bridged adapter name on connection
It's already set up out of the box. The problem is I have to go in and select the adapter manually. I want it to either detect it automatically or have some command/script to run on the Linux client to either switch the adapter or restart it with the correct adapter.
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: Automatically change bridged adapter name on connection
That idea doesn't really work. If your host has more than one connection then VirtualBox has no way of knowing which one some other software prefers - in bridged mode remember it is using almost none of the hosts software, all it does is connect to the lowest driver for the right NIC.dhinge wrote:Is there a way to get VirtualBox to automatically select the bridged adapter based on what your computer is connected to?
However, I've occasionally wished for something similar, i.e. a priority scheme similar to how Windows handles moving between WiFi hotspots: if this connection is available, use it. Otherwise if this one is available, use it... and so on. Maybe a wildcard setting to use whatever is available (VirtualBox must have this info available because it offers a list).
IMHO: this isn't really a "Windows Hosts" specific issue - moving to "Suggestions".
-
- Site Moderator
- Posts: 34369
- Joined: 6. Sep 2008, 22:55
- Primary OS: Linux other
- VBox Version: OSE self-compiled
- Guest OSses: *NIX
Re: Automatically change bridged adapter name on connection
I guess I must be living a charmed life, or maybe because I run Linux as host.
I have (3) adapters on my laptop set up in several of my guests. Host-only, Bridged, & NAT, with wired and wifi on the host. If I uncheck (in the guest) all and then check the adapter I want to be active it connects. On rare occasions I need to run dhclient in a Linux guest to get a new release. You don't need to deactivate the host-only adapter in any case as this one will talk to the host regardless of the network you are connected with. Using host-only and Bridged or NAT I don't need to do anything. The host-and guest/s continue to communicate while off LAN and once I have LAN connected the guest seamlessly has the Internet.
Here's a guest with all 3 active at the same time. eth0=bridged, eth1=host-only, & eth2=NAT. You can also see that they are actually sending and receiving data. I don't use anything other that the VirtIO adapter type though in all guests, Linux or Windows, maybe that has something to do with it.
I have (3) adapters on my laptop set up in several of my guests. Host-only, Bridged, & NAT, with wired and wifi on the host. If I uncheck (in the guest) all and then check the adapter I want to be active it connects. On rare occasions I need to run dhclient in a Linux guest to get a new release. You don't need to deactivate the host-only adapter in any case as this one will talk to the host regardless of the network you are connected with. Using host-only and Bridged or NAT I don't need to do anything. The host-and guest/s continue to communicate while off LAN and once I have LAN connected the guest seamlessly has the Internet.
Here's a guest with all 3 active at the same time. eth0=bridged, eth1=host-only, & eth2=NAT. You can also see that they are actually sending and receiving data. I don't use anything other that the VirtIO adapter type though in all guests, Linux or Windows, maybe that has something to do with it.
Code: Select all
root@LT-debian-wheezy:~# ifconfig -a
eth0 Link encap:Ethernet HWaddr 08:00:27:ae:5d:e9
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:feae:5de9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:75 errors:0 dropped:0 overruns:0 frame:0
TX packets:79 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:14120 (13.7 KiB) TX bytes:11337 (11.0 KiB)
eth1 Link encap:Ethernet HWaddr 08:00:27:94:73:0a
inet addr:192.168.56.101 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe94:730a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:65 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1895 (1.8 KiB) TX bytes:10501 (10.2 KiB)
eth2 Link encap:Ethernet HWaddr 08:00:27:fd:56:22
inet addr:10.0.4.15 Bcast:10.0.4.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fefd:5622/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:68 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1502 (1.4 KiB) TX bytes:10643 (10.3 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: Automatically change bridged adapter name on connection
My VMs will not start up if they are bridged to an adapter that doesn't exist (e.g. a USB wireless dongle, so if not plugged it simply doesn't exist). So, you can't bridge to both wireless and wired from the same VM, and still be able to run the VM if the wireless isn't available. That's a scenario I had in mind. Another scenario is moving a VM back and fore between two host PCs. On "PC A" the NIC might be called "Gigabit Network", on "PC B" it might be called something else - and the VM will not start if bridged was used.
I'm not saying it's a major problem, I'm just saying that I've occasionally wished for a way to deal with this.
I'm not saying it's a major problem, I'm just saying that I've occasionally wished for a way to deal with this.
-
- Site Moderator
- Posts: 34369
- Joined: 6. Sep 2008, 22:55
- Primary OS: Linux other
- VBox Version: OSE self-compiled
- Guest OSses: *NIX
Re: Automatically change bridged adapter name on connection
Ah ha! But that's missing hardware and not a connection. I wonder how that would be handled?(e.g. a USB wireless dongle, so if not plugged it simply doesn't exist)
Now this would be a perfect use for VirtIO, not to mention the increase in speed.Another scenario is moving a VM back and fore between two host PCs. On "PC A" the NIC might be called "Gigabit Network", on "PC B" it might be called something else - and the VM will not start if bridged was used.
-
- Oracle Corporation
- Posts: 2973
- Joined: 19. Dec 2007, 15:45
- Primary OS: MS Windows 7
- VBox Version: PUEL
- Guest OSses: Any and all
- Contact:
Re: Automatically change bridged adapter name on connection
He's talking about the host NICs changing, which messes up bridging. VirtIO is not going to help with that at all.Perryg wrote:Now this would be a perfect use for VirtIO, not to mention the increase in speed.
-
- Site Moderator
- Posts: 34369
- Joined: 6. Sep 2008, 22:55
- Primary OS: Linux other
- VBox Version: OSE self-compiled
- Guest OSses: *NIX
Re: Automatically change bridged adapter name on connection
Ah yes you are right of course. Now I understand what Don was getting at. I was fixated on the OP and laptop. Time to clean my glasses.
So the issue now is hardware detection and automatically selection in multiple OSes. Somehow while interesting, I don't see this as trivial to accomplish, but that's just me.
So the issue now is hardware detection and automatically selection in multiple OSes. Somehow while interesting, I don't see this as trivial to accomplish, but that's just me.
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: Automatically change bridged adapter name on connection
I suspect that it would in fact be fairly trivial. There is code in there now whose effect is something like :-Perryg wrote:I don't see this as trivial to accomplish, but that's just me.
Code: Select all
if attempting a bridged connection ::-
if NIC_Available(NIC_name) :: MakeConnection()
else Error(...)
endif
endif
Of course the user interface would be complicated, so I'd probably leave it out of the UI. It would be yet another VBoxManage gizmo.
Not a high priority, it's just a pain in the ass when I hit one of the scenarios mentioned above - because I always forget! I have to swear, dismiss the error dialogs, and edit the VM settings.
-
- Site Moderator
- Posts: 34369
- Joined: 6. Sep 2008, 22:55
- Primary OS: Linux other
- VBox Version: OSE self-compiled
- Guest OSses: *NIX
Re: Automatically change bridged adapter name on connection
Not trying to be argumentative but I see several obstacles that would need to be overcome.
- What about multiple adapters? Wired, wifi, Etc.
More than one active NIC on host. One for VBox to use and one for a different LAN as one example.
Multi-platforms and different versions that require different adapter types.
How complex would the test logic need to be and how to turn it on and off?
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: Automatically change bridged adapter name on connection
It would not affect the use of multiple adapters. It's simply that the logic for a single NIC "slot" would be "if <> {elsif<>} else <error>" instead of just "if <> else <error>", as it is now. You would still have eight slots in which this logic of this kind would separately apply.
Re: Automatically change bridged adapter name on connection
I think this is the closest answer to what I'm looking for, though I'm not sure how to set it up (maybe I need more Linux education). Basically what I want is to detach the LAN and have the client automatically have internet through the host's wifi and not have to adjust the IP address of the client, meaning I have a text editor, a browser, and a putty window I want to be able to connect with without having to switch IP's or close the windows or change the etc/hosts file in Windows or shut down the virtual box and change the adapter settings... it's a pain in the butt and limiting at work when I need to detach from my desk dock and bring it into a meeting or bring it home on another network (not sure if the latter is possible).Perryg wrote:I have (3) adapters on my laptop set up in several of my guests. Host-only, Bridged, & NAT, with wired and wifi on the host. If I uncheck (in the guest) all and then check the adapter I want to be active it connects. On rare occasions I need to run dhclient in a Linux guest to get a new release. You don't need to deactivate the host-only adapter in any case as this one will talk to the host regardless of the network you are connected with. Using host-only and Bridged or NAT I don't need to do anything. The host-and guest/s continue to communicate while off LAN and once I have LAN connected the guest seamlessly has the Internet.
I don't see VirtIO adapter in the Network settings, but maybe that's something I need to install.Perryg wrote:I don't use anything other that the VirtIO adapter type though in all guests, Linux or Windows, maybe that has something to do with it.
-
- Posts: 13
- Joined: 26. Feb 2011, 07:38
- Primary OS: MS Windows 7
- VBox Version: OSE other
- Guest OSses: xp
Re: Automatically change bridged adapter name on connection
Hi
Is there a way to solve this trouble. Now, I encountered this issue. when my windows host switchs its connection, the bridge-adapter of virtualbox won't change automatically.
How does it switch to active-connection automatically?
Is there a way to solve this trouble. Now, I encountered this issue. when my windows host switchs its connection, the bridge-adapter of virtualbox won't change automatically.
How does it switch to active-connection automatically?