Bridged NIC Name Not Set During Command Line Creation

Discussions related to using VirtualBox on Linux hosts.
Post Reply
ITSM Guy
Posts: 13
Joined: 3. Oct 2021, 23:39

Bridged NIC Name Not Set During Command Line Creation

Post by ITSM Guy »

When I create a vm using the gui, everything works fine. When I use a script I wrote, the nic values aren't set properly. Everything is set except for the name. I'm using --nic1 bridged and that sets properly but I have to go into the gui, open settings and then click OK for the name (that is already there) to be assigned (enp4s0). I've tried setting the nic to nat and then change it to bridged but that doesn't resolve the issue.
VBoxManage createvm --name "$MACHINE" --ostype "$TYPE" --register --basefolder "$VMHOME"
VBoxManage modifyvm "$MACHINE" --ioapic on --cpus 6 --memory $RAM --vram 128 --graphicscontroller vmsvga --nic1 nat
VBoxManage createhd --filename "$VMHOME/$MACHINE/$MACHINE"_DISK.vdi --size $SPACE --format VDI
VBoxManage storagectl "$MACHINE" --name "SATA Controller" --add sata --controller IntelAhci
VBoxManage storageattach "$MACHINE" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$VMHOME/$MACHINE/$MACHINE"_DISK.vdi
VBoxManage storagectl "$MACHINE" --name "IDE Controller" --add ide --controller PIIX4
VBoxManage storageattach "$MACHINE" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium "$ISO"
VBoxManage modifyvm "$MACHINE" --boot1 dvd --boot2 disk --boot3 none --boot4 none
VBoxManage modifyvm "$MACHINE" --nic1 bridged
VBoxHeadless --startvm "$MACHINE"
If I do this line by line I get the same result. All I need to do to resolve the issue is click Settings then click OK but I shouldn't have to do that.
Attachments
Screenshot from 2021-10-03 17-52-03.png
Screenshot from 2021-10-03 17-52-03.png (36.08 KiB) Viewed 1672 times
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Bridged NIC Name Not Set During Command Line Creation

Post by scottgus1 »

There is another command to be used after 'modifyvm nic# bridged':
VBoxManage modifyvm "$MACHINE" --bridgeadapter<1-N> none|<devicename>
Only has an effect if bridged networking has been enabled for a virtual network card. Use this option to specify which host interface the given virtual network interface will use.
I think --bridgeadapter# has to be the same # as nic#.
ITSM Guy
Posts: 13
Joined: 3. Oct 2021, 23:39

Re: Bridged NIC Name Not Set During Command Line Creation

Post by ITSM Guy »

That did it.

Is there a way to mark this "solved"? VBoxManage modifyvm "Fedora Server 35" --nic1 bridged --bridgeadapter1 enp4s0
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Bridged NIC Name Not Set During Command Line Creation

Post by scottgus1 »

Excellent! Glad you're up and running.

No need to mark solved, that's just fine.
Post Reply