(1) The latest virtualbox can be simply configured as a bridge connection,
(2) If the virtualbox version is earlier, try the following operations:
I haven't used a virtual machine for a long time. I installed virtualbox in the source yesterday and found that there is a "ose" character in the window title, so I didn't care too much about it. Nat is used for installation.
After installing the system, you can find that the guest cannot access the Internet and check the network configuration. Everything is normal. The guest can obtain the IP address through DHCP, but the address and gateway are strange.
"10.0.0.x", and cannot ping the internet.
Go to the official virtualbox website
After reading it, vbox recently changed its release policy and divided it into a closed-source version and an open-source version. The open-source version has fewer functions than the closed-source version, however, the closed source version is free of charge, and the OSE is short for "Open Source edition.
Although the list of functional differences between the two versions
Medium
No network-related content found. I finally downloaded and installed the closed source version. Starting guest again, the miracle did not happen. However, I had to decide to use the bridge network. Master
The difference is that Nat is very simple. You only need to select the NAT method in virtualbox and then select to automatically obtain the IP address in guest. In fact, it uses the network of the host.
Therefore, it does not exist as an independent individual in the network. Instead, the bridging method allows guest to obtain its own IP address, so that it can be used as an independent individual on the network and tied with the host, this method is flexible
It is not subject to host restrictions and influences. The disadvantage is that it is relatively troublesome to configure.
Virtualbox's bridge network is the same as VMware's bridged, but unlike it, virtualbox's Windows and Linux versions have different ways to configure the bridge network, this document only describes how to configure the virtualbox bridging network in Linux.
First, install two libraries for bridging the network. Run the following commands in Ubuntu to install these libraries:
Sudo apt-Get install UML-utilities bridge-utils
Then, a user group named "UML-Net" will appear in the system. Use the following command to add users running virtual machines to the group:
Sudo gpasswd-A user_name UML-Net
Replace "user_name" with the user name of the user running the virtual machine, and then edit the network interface configuration file:
Sudo VI/etc/Network/interfaces
Add the following paragraph at the end or beginning of the file:
Auto tap0
Iface tap0 inetmanual
Up ifconfig $ iface 0.0.0.0 up
Down ifconfig $ iface down
Tunctl_user user_name
The configuration information above indicates that the virtual network interface is set to "tap0", its IP configuration method is manual, and the user using this interface is "user_name ". Configure a bridge and add the following content below the configuration information:
Auto br0
Iface br0 Inet DHCP
Bridge_ports all tap0
The configuration information indicates that a bridge named "br0" is created, and the IP address is obtained automatically through DHCP. All network interfaces of the local machine are obtained, the "tap0" virtual interfaces will all be built on this bridge. If you want to manually specify an IP address, you can replace the preceding configuration information with the following:
Auto br0
Iface br0 Inet static
Address 192.168.0.5
Netmask 255.255.255.0
Network 192.168.0.0
Broadcast 192.168.0.255
Gateway 192.168.0.1
The configuration information above sets the IP address of the bridge to "192.168.0.5 ".
Save the file, restart the system, and enter the following command in the virtual terminal to enable the bridge network. This command only needs to be executed once:
Sudo/sbin/IFUP br0
Sudo/sbin/IFUP tap0
Open open
Virtualbox, select the guest system from the list, click "Settings"> "network" on the toolbar, and select one of the listed network adapters. Generally, only one
"Network adapter 0", click "enable network adapter", and select "host" in the drop-down list after "Connect"
Interface, and make sure that the "access network cable" is selected. Then, enter "tap0" in the "host network interface name. Click "OK" and start guest,
If you set the system IP address to automatically retrieve, the bridge network will take effect.
To disable the bridge, run the following command:
Sudo/sbin/ifdown br0
Sudo/sbin/ifdown tap0
Then, delete the configuration information added in the/etc/Network/interfaces file.
(3) introduce another method.
1. Download several software packages
Sudo apt-Get install UML-utilities bridge-utils
2. Create a new file named tap. SH and copy the following content to it.
Sudo tunctl-T tap0-u HONGJIANG # create a tap device named HONGJIANG as the tap0 owner
Sudo brctl addbr br0 # create a bridge
Sudo ifconfig eth0 0.0.0.0 promisc # enable eth0 to enter promiscuous mode
Sudo brctl addif br0 eth0 # Add eth0 to br0
# Sudo ifconfig br0 192.168.1.12 up # fixed IP Address
# Sudo route del default
# Sudo route add default GW 192.168.1.149 Dev br0
Sudo ifconfig br0 up # DHCP Mode
Sudo dhclient br0
Sudo brctl addif br0 tap0 # Add tap0 to br0
Sudo ifconfig tap0 up # activate tap0
Sudo chmod A + RW/dev/NET/TUN
3. Set permissions
Chmod U + x tap. Sh
4. Copy tap. Sh to/home/HONGJIANG/. vritualbox
5. Add a startup Item
Sudo gedit/etc/rc. Local
Add/home/HONGJIANG/. virtualbox/TAP. Sh before exit 0
6. Select "host interface" in the network tag of VM setting in virtualbox, and fill in tap0 in the following interface
7. Restart or manually run tap. Sh.
Make sure that the host and the virtual machine are in the same network segment. Otherwise, the communication will fail.