How to change network adapter(bridged) for virtualbox trough terminal using Ubuntu

Discussions related to using VirtualBox on Linux hosts.
Post Reply
cloud_kicker
Posts: 2
Joined: 9. Apr 2018, 15:53

How to change network adapter(bridged) for virtualbox trough terminal using Ubuntu

Post by cloud_kicker »

Description of problem:
So I have virtualbox on host pc somewhere. At the beggining on host PC I had network adapter "enp2s0". Virtualbox what is on host PC used "enp2s0" adapter in bridged mode. Today on host PC I created new network adapter "enp2s0.4". Unfortunately at the moment I dont have access to GUI, all I have is ssh and ubuntu. Problem is that somehow I need to swap adapters, so virtualbox is using the new created "enp2s0.4" adapter in bridged mode.

Question:
Is it even possible to do it using terminal and if it is, then how to do it?

Thanks for help!
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: How to change network adapter(bridged) for virtualbox trough terminal using Ubuntu

Post by mpack »

See the VBoxManage chapter of the user manual.
cloud_kicker
Posts: 2
Joined: 9. Apr 2018, 15:53

Re: How to change network adapter(bridged) for virtualbox trough terminal using Ubuntu

Post by cloud_kicker »

mpack wrote:See the VBoxManage chapter of the user manual.
As far as I understand that it has something to do with "VBoxManage modifyvm", but I cant find any info on what I should type in terminal to make virtual box use "enp2s0.4" adapter as the main one. Would be nice if you could help with comands.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: How to change network adapter(bridged) for virtualbox trough terminal using Ubuntu

Post by mpack »

See "VBoxManage modifyvm --nicn bridged" to set virtual NIC n to bridged mode (if it might be in another mode). See "VBoxManage modifyvm --bridgeadaptern <devicename>" to select which host NIC is bridge to the virtual NIC.

The bridged mode for each VM is configured separately, then is no setting to make VirtualBox use the same host NIC for all VMs. You can't force NAT more to use a particular NIC, as NAT mode by definition means to use the host OS networking API, in which case it's up to the host OS to control what NIC it is using.
Post Reply