ArticleDirectory
- First Nat Mode
- The second bridged adapter Mode
- Third Internal Mode
- Fourth host-only adapter Mode
- Configure port ing in Nat
Virtualbox is a very good virtual machine produced by Sun.Program, The version is also very complete, you can find a suitable version for a variety of operating system platforms on the official website.
Here I will give you a brief introduction to the vbox network configuration and application. Virtualbox provides four network access modes:
- Nat network address translation mode)
- Bridged adapter Bridging Mode
- Internal internal network mode
- Host-only adapter Host Mode
First Nat Mode
The Nat mode is the simplest way to access the Internet through virtual machines. You can understand that all data accessed by vhost is provided by the host, and vhost does not actually exist in the network, the existence of the vhost cannot be viewed or accessed by any host on the host or network.
Relationship between virtual machines and hosts: Only one-way access is allowed. virtual machines can access hosts through the network, and hosts cannot access virtual machines through the network.
Relationship between virtual machines and other hosts in the Network: Only one-way access is allowed. virtual machines can access other hosts in the network, while other hosts cannot access virtual machines through the network.
Relationship between virtual machines: they cannot access each other. They are completely independent from each other and cannot access each other through the network.
When a laptop has a network cable inserted: the virtual machine can access the host, and the virtual machine can access the internet. After port ing ), the host can access services (such as databases) on virtual machines )..
When no network cable is inserted in the notebook: the "local connection" of the host has a Red Cross, the virtual machine can access the host, and the virtual machine cannot access the Internet. After port ing, the host can access services (such as databases) on virtual machines ).
The second bridged adapter Mode
The bridge mode is my favorite mode, and the simulation degree is also quite perfect. As you can understand, it sets up a bridge through the host Nic and connects it directly to the network. Therefore, it allows virtual machines to be allocated to independent IP addresses in a network. All network functions are the same as those of real machines in the network.
Relationship between virtual machines and hosts: mutual access is allowed. Because virtual machines have independent IP addresses in the real network segment, the host and virtual machines are in the same network segment and can access each other through their respective IP addresses.
Virtual machines have relationships with other hosts in the Network: they can access each other. Likewise, because virtual machines have independent IP addresses in the real network segment, the virtual machines are in the same network segment as other hosts on all networks, each Other can access each other through their respective IP addresses.
Virtual machines are connected to virtual machines: they can access each other for the same reason.
IP Address: It is generally allocated by DHCP. It is in the same network segment as the "local connection" IP address of the host. The VM can communicate with the host.
When a laptop has a network cable inserted: (if there is a DHCP server in the Network) the host and the virtual machine obtain an IP address through DHCP. The two IP addresses are in the same network segment. The host and virtual machine can be pinged, and the virtual machine can be connected to the Internet.
When no network cable is inserted in the notebook: the host cannot communicate with the virtual machine. If the host's "Local Connection" has a Red Cross, you cannot manually specify an IP address. The virtual machine cannot obtain an IP address through DHCP. After the IP address is manually specified, it cannot communicate with the host because the host has no IP address.
In this case, the virtualbox host-only network adapter of the host has an IP address, 192.168.56.1. Even if the IP address 192.168.56. * is manually specified for the VM, the host cannot be pinged.
Third Internal Mode
Intranet mode, as its name implies, is the internal network mode. virtual machines are completely disconnected from the Internet, and only the internal network mode between virtual machines is implemented.
Relationship between virtual machines and hosts: they cannot access each other, they do not belong to the same network, and they cannot access each other.
Relationship between virtual machines and other hosts in the Network: mutual access is not allowed for the same reason.
Relationship between virtual machines: mutual access is allowed, provided that the two virtual machines set the same network name when setting the network. In the preceding configuration chart, the name is intnet.
IP: the DHCP server of virtualbox will assign an IP address to it. Generally, 192.168.56.101 is obtained. Because the IP address ranges from 101, you can also manually specify 192.168.56 .*.
When a laptop has a network cable inserted: the VM can communicate with the virtualbox host-only network adapter of the host.
This solution is not affected by the host's local connection (NIC.
Fourth host-only adapter Mode
Host mode. This is a complex mode that requires a solid basic network knowledge. It can be said that the functions implemented in the previous modes can be achieved through virtual machine and nic settings in this mode.
We can understand that the vbox model a dedicated Nic for the virtual machine in the host. All virtual machines are connected to the NIC. We can set this Nic to achieve Internet access and many other functions, such as NIC sharing and nic bridging ).
Relationship between virtual machines and hosts: mutual access is not allowed by default. Both parties do not belong to the same IP segment. The default IP segment of the Host-only NIC is 192.168.56.x, And the subnet mask is 255.255.255.0, this CIDR block is also assigned to virtual machines. Through Nic sharing and nic bridging, virtual machines can access each other on the host.
Relationship between virtual machines and network hosts: mutual access is not allowed by default. The reason is the same as above. Mutual access can be achieved through settings.
Relationship between virtual machines: by default, virtual machines can access each other, both in the same network segment.
The VM accesses the host using the virtualbox host-only network Nic IP address 192.168.56.1 of the host, regardless of whether the host "Local Connection" has a Red Cross, always pass.
When the host accesses the VM, it uses the IP address 192.168.56.101 of network interface card 3 of the VM, regardless of whether the host is "locally connected" or not, it will always be connected.
When a virtual machine accesses the internet, it uses its own network adapter 2. In this case, the host must be able to access the Internet through a "Local Connection" Wired Network (wireless network adapter is unavailable)
By understanding the above several network modes, we can use them flexibly to simulate the establishment of any network environment we want. For example, I want to simulate a host to monitor the network environment of a local area network.
First, I started two virtual machines, vhost1 and vhost2. Of course, if the hardware permits, I can also add vhost3, vhost4...
All vhosts are set to internat Intranet mode. The network name is intnal and the gateway is 192.168.56.100, which means accessing the Internet through the 192.168.56.100 Nic. One vhost1 is set to a dual-nic, one is the Intranet mode (192.168.56.100), and the other is the bridge mode (192.168.1.101 ). Set two NICs to share the Internet
There is a LAN between virtual machines. One of them is connected to the Internet through vhost1, and all the virtual machines in the LAN are connected to the Internet through vhost1. In this way, vhost1 can monitor the Internet access of the entire virtual machine LAN.
Configure port ing in Nat
Http://huzhangsheng.blog.163.com/blog/static/34787784200802801435931/
You can set a virtual machine service (such as a web service) by using the command line tool vboxmanage proxy. You need to know which port is used by the virtual machine service, and then decide which port is used on the host (usually but not always want to make the virtual machine and the host use the same port ). A port is required to provide a service on the host. You can use any port on the host that is not prepared to provide the service. How to set up a new Nat instance and connect to an SSH server on a VM requires the following three commands:
Vboxmanage setextradata " Linux guest " " Vboxinternal/devices/pcnet/0/Lun #0/config/guestssh/protocol " Tcpvboxmanage setextradata " Linux guest " " Vboxinternal/devices/pcnet/0/Lun #0/config/guestssh/guestport " 22 Vboxmanage setextradata " Linux guest " " Vboxinternal/devices/pcnet/0/Lun #0/config/guestssh/hostport " 2222
Note: vboxmanage is a command line program. Check your virtualbox installation directory. "Linux guest" is the virtual host name. Guestssh is a custom name. You can set it as needed. Use the preceding three commands to forward port 22 of the VM to port 2222 of the host.
For example, I installed the apache2 server on the Virtual Machine Debian and used port 80 to map it to port 80 of the host. Use the following command.
" C: \ Program Files \ innotek virtualbox \ vboxmanage.exe " Setextradata " Debian " " Vboxinternal/devices/pcnet/0/Lun #0/config/huzhangsheng/protocol " TCP " C: \ Program Files \ innotek virtualbox \ vboxmanage.exe " Setextradata " Debian " " Vboxinternal/devices/pcnet/0/Lun #0/config/huzhangsheng/guestport " 80 " C: \ Program Files \ innotek virtualbox \ vboxmanage.exe " Setextradata " Debian " " Vboxinternal/devices/pcnet/0/Lun #0/config/huzhangsheng/hostport " 80
Note: To make the settings take effect, turn off virtualbox and run the virtual machine. I have installed virtualbox on WINXP and Debian 4.02r on the virtual machine. The virtual machine name is Debian, apache2 PhP5 mysql-server is installed, and http: // localhost is browsed with IE on the host, which is successfully forwarded to The apache2 Web server of Debian virtual machine.
Address: http://www.cnblogs.com/coltiam/archive/2010/03/26/1696939.html