Article title: virtualbox bridging network configuration in Ubuntu. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Generally, the default NAT mode is selected after VirtualBox is installed to set the network, and Guest can be connected smoothly. However, this method is rigid and requires more elastic changes, the bridge mode should be adopted. here, the bridge mode is like the Bridged mode in VMware, and the Host and Guest are equal in the LAN.
1. on Debian and Ubuntu-based systems, first install the uml-utilities tool and bridge-utils tool, which contain the virtual network device (TAP interfaces:
Sudo apt-get install uml-utilities
Sudo apt-get install bridge-utils
To enable your VM to access network interfaces, you must set the user name (usually your ubuntu login user name) of the user running the VM) add to the uml-net user group (replace "vboxuser" with your user name "):
Sudo gpasswd-a vboxuser uml-net
Note: To make the change take effect, restart your computer.
2. describe the virtual network device you want to add to your Debian or ubuntu operating system, and edit/etc/network/interfaces: (back up first)
Sudo vim/etc/network/interfaces
Add the following content after the opened file, name the virtual network interface "tap0", and specify the interface IP configuration method as manual, and specify the user using this interface (replace "vboxuser" with your user name "):
Auto tap0
Iface tap0 inet manual
Up ifconfig $ IFACE 0.0.0.0 up
Down ifconfig $ IFACE down
Tunctl_user vboxuser
3. activate the created virtual network interface and network Bridge for the first time:
Sudo/sbin/ifup tap0
Sudo/sbin/ifup br0
This step only needs to be performed once. the interface and bridge will be automatically activated the next time the host restarts.
3. in addition, add the following content to/etc/network/interfaces to create a bridge named "br0". the IP address of the bridge is configured through DHCP, all network interfaces in the host, including the virtual network interface tap0, will be built on this bridge:
Auto br0
Iface br0 inet dhcp
Bridge_ports all tap0
Here, you can make changes based on your network conditions. you can make the network Bridge use static IP:
# Iface br0 inet static
Address 192.168.1.2
Netmask 255.255.255.0
Network 192.168.1.0
Broadcast 192.168.1.255
Gateway 192.168.1.1
4. activate the created virtual network interface and network Bridge for the first time:
Sudo/sbin/ifup tap0
Sudo/sbin/ifup br0
This step only needs to be performed once. the interface and bridge will be automatically activated the next time the host restarts.
5. let virtualbox use this virtual network interface to start virtualbox. on the main interface, select the virtual machine to use the created virtual network interface tap0, and click "set ", in the displayed window, select "network", select one network adapter (usually "network adapter 0"), select "enable network adapter", and select "Host Interface" after "connect ", select "access network cable", enter the name of the created virtual network interface "tap0" in "host network interface name", and click OK. You can also use the VBoxManage command line tool (replace "My VM" with your VM name ):
VBoxManage modifyvm "My VM"-hostifdev1 tap0 \
Finally, configure the network of the host and the virtual machine so that the host and the virtual machine are in the same network segment, so that the host and the virtual machine become two machines with the same position in the Lan and can access each other.
Cancel network Bridge
1. disable bridges and virtual NICs:
Sudo/sbin/ifdown br0
Sudo/sbin/ifdown tap0
2. restore the modified/etc/network/interfaces file.