Virtualbox linux виртуальный адаптер

How to add Network Adapter in Oracle VirtualBox

Add network adapter (additional) — Oracle VirtualBox

Most of use are already familiar with Oracle VirtualBox which gives us a platform to create Virtual Machines. I am personally a big fan of Oracle VirtualBox software as now I don’t have to worry about multiple hardware or server to test different configurations on multiple setups. I can just create multiple VMS, add additional disks, add additional Network Adapter to the VM and continue with my test.

When we create a new VM, by default we only have single single Network Adapter assigned to the VM. Now single network interface should be enough in most cases but if we want to add additional network interface to the same VM then the same can be done very easily. Although for beginners this may look little tricky so I plan to write a step by step tutorial to add additional network adapter to existing VM and steps to be done. Additionally I will share the steps to configure this new network on your Linux server which is installed on the VM.

I have AlmaLinux 8 installed on my VM so my steps would work on distributions like Rocky Linux, Fedora, CentOS etc.

Lab Environment

I have already explained about my setup, but let me just put in consolidated order so it is easier for you to understand. I have a Oracle VirtualBox installed on my Windows 10 Laptop where I have created a VM with single network adapter. This VM is installed with AlmaLinux 8. Now I intend to add one more network adapter to this VM for some tests.

Step-1: Power Off VM

If your VM is already in powered off state then you can skip this step.

You MUST power off the VM to be able to add additional network adapter in Oracle VirtualBox. From the Linux terminal as root user or using sudo you can execute the following command to power off the VM:

How to add Network Adapter in Oracle VirtualBox

Alternatively, if you do not wish to do a graceful power off then you can also initiate power off using VM’s settings. Right-click on the VM in your VirtualBox console and select «Power Off» under «Close» as shown below:

Step-2: Access VM’s Network Settings

Next open the Network Settings of the VM. Right click on the VM and select Settings as shown below:

How to add Network Adapter in Oracle VirtualBox

Step-3: Add additional network adapter in the VM

This will open a new pop-up window with the different Settings option. Click on Network form the left sidebar menu. Next select on Adapter 2 and click on the checkbox to enable this adapter.

Читайте также:  Linux изменить права до root

Select the Network Type from the drop down menu under Attached to section, in most cases you can select Bridged Adapter. Click on OK once done.

How to add Network Adapter in Oracle VirtualBox

HINT: There is one additional field here Name: which means the device to be used to Bridge the network. In most cases the default network device from your host machine will be selected which should work out of the box. But if you have multiple interfaces on your host server then you can select your preferred device from the drop down menu under Name:

Step-4: Power ON the VM

Next we will power on the VM to further complete the network configuration. Again right click on your VM and select Start -> Normal Start to power on the VM.

How to add Network Adapter in Oracle VirtualBox

Step-5: Configure network in Linux

Once the VM is powered on, we need to configure the network in our Linux VM to be able to use it. List the available interfaces and their network configuration.

[root@server-1 ~]# ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s3: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:d4:f8:cf brd ff:ff:ff:ff:ff:ff inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3 valid_lft 86009sec preferred_lft 86009sec inet6 fe80::a00:27ff:fed4:f8cf/64 scope link valid_lft forever preferred_lft forever 3: enp0s8: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:93:8c:70 brd ff:ff:ff:ff:ff:ff 4: virbr0: mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:c3:ea:45 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 5: virbr0-nic: mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:c3:ea:45 brd ff:ff:ff:ff:ff:ff

So, enp0s8 seems to be newly added as enp0s3 was already there on this VM. But we don’t see any network IP assigned to this interface so we will have to fix this issue. Ideally in most cases the newly added network adapter should get the IP from DHCP Server (Our HOME or OFFICE Router).

To configure network we will use nmtui tool. Execute nmtui as root user from the terminal which will open a new terminal UI to configure network as shown below

How to add Network Adapter in Oracle VirtualBox

Select Edit a connection using arrow button on your keyboard, using TAB navigate to and hit ENTER. In the next screen we should be able to see all our network interfaces. But we don’t see enp0s8 here. So the configuration file is missing for our newly added network adapter, this is the reason IP was not assigned to this interface,

Читайте также:  Linux listing open ports

How to add Network Adapter in Oracle VirtualBox

To fix this, we need to manually create a new configuration file for this interface. Navigate to select and hit ENTER which will show you below prompt to select the type of connection to create. We will create Ethernet Type.

How to add Network Adapter in Oracle VirtualBox

In the next screen, we need to provide different details to configure the network for the newly added network adapter.

  • Profile name: This can be any name, this name will be used to create your configuration file.
  • Device: This should be same as interface name
  • ETHERNET: Leave this section empty.
  • IPv4 CONFIGURATION: If you plan to add static IP then you can select Manual instead of Automatic and provide the network details. We will leave it to Automatic to use DHCP for our VM.
  • IPv6 CONFIGURATION: If you plan to add IPv6 IP then you can modify the same by switching to Manual instead of Automatic. We can also change it to Ignore if we don’t want to use IPv6. For now I will leave it to Automatic as it will not get any IP Address as I don’t have any DHCPv6 server.
  • Automatically connect: Leave this checked to make sure your interface is automatically connected after reboot
  • Available to all users: I think this is self explanatory

How to add Network Adapter in Oracle VirtualBox

Click on to save the configuration. On the next screen now you should be able to see your interface. Navigate the cursor to to go back to previous terminal:

How to add Network Adapter in Oracle VirtualBox

Next we must activate this interface to fetch the IP Address from the DHCP server. We will again use nmtui console to re-activate this interface. You should see the below screen on your nmtui. Select Activate a connection and navigate to , press ENTER.

How to add Network Adapter in Oracle VirtualBox

Select your interface and navigate to Activate. Hit ENTER to Activate the interface.

How to add Network Adapter in Oracle VirtualBox

Once the interface is successfully activate, go back to the main screen and Quit the nmtui session.

How to add Network Adapter in Oracle VirtualBox

Now you can check, your interface should have a proper IP Address assigned:

[root@server-1 yum.repos.d]# ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s3: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:d4:f8:cf brd ff:ff:ff:ff:ff:ff inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3 valid_lft 86399sec preferred_lft 86399sec 3: enp0s8: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:93:8c:70 brd ff:ff:ff:ff:ff:ff inet 192.168.0.196/24 brd 192.168.0.255 scope global dynamic noprefixroute enp0s8 valid_lft 7199sec preferred_lft 7199sec inet6 fe80::a00:27ff:fe93:8c70/64 scope link valid_lft forever preferred_lft forever 4: virbr0: mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:c3:ea:45 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 5: virbr0-nic: mtu 1500 qdisc fq_codel master virbr0 state DOWN group default

So we have successfully added additional network adapter to our existing VM in Oracle VirtualBox.

Читайте также:  Linux access mysql server

Summary

In this tutorial I shared steps to add a new network adapter to our existing Virtual Machine running on Oracle Virtual Box. You can add multiple Network Adapters to any VM and configue network using the steps from this tutorial. Let me know if you face any issues using the comment section.

Further Reading

Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Источник

Настройка виртуального адаптера хоста в VirtualBox.

В качестве хост машины выступает Linux Mint 19 , на который установлен VirtualBox 5.2.18 . Гостевая машина — сервер на Debian 9 .

Способ получить доступ к виртуальной машине извне — использовать виртуальный адаптер хоста.

Тут можно настроить все более подробно, а также получить отдельный ip для машины, что дает больше возможностей.

Примечание.

Виртуальный адаптер хоста — создается виртуальный сетевой адаптер, к которому можно подключить несколько виртуальных машин, тем самым объединив их в локальную сеть. Доступа к интернету нет , но зато машины находятся в одной сети и каждая имеет свой ip адрес, теперь они могут взаимодействовать между собой. Основная система тоже доступна по ip 192.168.56.1. Машины доступны не только между собой, но и из основной системы.

Для того чтобы все это заработало в Linux, нам нужно чтобы были загружены модули ядра vboxnetadp и vboxnetflt:

Возможно, для их правильной работы вам придется установить пакет net-tools.

1. Создаем виртуальный адаптер.

Сначала нужно создать виртуальный адаптер. Для этого откройте меню «Файл» , затем «Менеджер сетей хоста» :

Нажимаем « Создать виртуальную сеть хоста »:

Появится созданный адаптер. Если DHCP сервер не включен его надо включить.

2. Настройка VirtualBox.

Открываем меню « Машина » — « Настроить »:

Открываем раздел « Сеть »:

В разделе « Тип подключения » изменяем тип адаптера с « NAT » на « Виртуальный адаптер хоста ». В разделе « Имя » должен появиться наш адаптер « vboxnet0 ».

Нажимаем « OK » и идем дальше.

3. Подключение к гостевой машине.

Запускаем нашу виртуальную машину. Входим под root и смотрим наш ip адрес:

Адрес нашей машины 192.168.56.3. Пробуем подключиться. Открываем терминал на хостовой машине и вводим:

Соединение успешно установлено.

Источник

Оцените статью
Adblock
detector