virtualbox is a very good Virtual Machine Program developed by Sun, and has a complete version, on the official website, you can find versions suitable for various operating system platforms.
here I will give you a brief introduction to the vbox network configuration and application.
virtualbox provides four network access modes:
1. Nat, Network Address Translation)
2. bridged adapter bridging mode
3. Internal internal network mode
4. Host-only adapter host mode
The following describes the four network types: analysis and explanation of the Mode:
the first Nat mode
explanation:
the NAT mode is the simplest way to Implement Virtual Machine Internet access. You can understand it as follows: all data of the vhost accessing the network is provided by the host, and the vhost does not exist in the network. The host and any machine on the network cannot view and access the existence of the vhost.
relationship between the VM and the Host:
only one-way access is allowed. The VM can access the host over the network, and the host cannot access the VM over the network.
relationships between virtual machines and other hosts in the Network:
only one-way access is allowed. virtual machines can access other hosts in the network, and other hosts cannot access virtual machines through the network.
relationship between virtual machines:
the virtual machines are completely independent of each other and cannot access each other through the network.
IP: 10.0.2.15
Gateway: 10.0.2.2
DNS: 10.0.2.3
multiple NICs of a virtual machine can be configured to use NAT, the first Nic is connected to the private network 10.0.2.0, the second Nic is connected to the private network 10.0.3.0, and so on. The Default Client IP address is 10.0.2.15, the gateway is 10.0.2.2, And the DNS is 10.0.2.3.
advantages and disadvantages of the NAT solution:
when a network cable is inserted in a notebook, the virtual machine can access the host, and the virtual machine can access the internet. After port ing is completed (this is finally described ), 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
explanation:
the bridge mode is my favorite mode, and the simulation degree is also 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 the virtual machine has an independent IP address in the real network segment, and the host and virtual machine are in the same network segment, each Other can access each other through their respective IP addresses.
Other VM relationships in the Network:
mutual access is allowed, because the virtual machine has an independent IP address in the real network segment, the virtual machine is in the same network segment as all other hosts on the network and can access each other through their respective IP addresses.
relationship between virtual machines:
mutual access is allowed for the same reason.
IP Address: generally assigned 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
explanation:
Intranet mode, as the name suggests, is internal network mode. The virtual machine is completely disconnected from the Internet, only the internal network mode between virtual machines is implemented.
relationship between virtual machines and hosts:
mutual access is not allowed. virtual machines and hosts are not in the same network and cannot be accessed.
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 have the same network name when setting the network. In the preceding configuration chart, the name is intnet.
IP Address: the DHCP server of virtualbox will assign an IP address to it. Generally, 192.168.56.101 is obtained. Because the score starts 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
explanation:
host mode, which is a complex mode. You must have a solid basic network knowledge before you can use it. 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 vbox is used to create a dedicated Nic in the host. All VMS are connected to this Nic, we can set this Nic to achieve Internet access and many other functions, such as NIC sharing and nic bridging ).
relationship between the VM and the host
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
mutual access is allowed by default, and both are 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 is connected locally or not.
when the host accesses the VM, it uses the IP address 192.168.56.101 of network adapter 3 of the VM, regardless of whether the host "Local Connection" has a red cross.
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" (wireless network adapter is not available)
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" TCP
Vboxmanage 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.