Virtualbox Virtual Machine Network Settings Tutorial

  
Virtualbox is a free and open source virtual machine that many friends use to conduct virtual experiments. Virtualbox is the ability to run multiple virtual machines on the same computer, and these virtual machines are running different operating systems. The following small series will share with you how to set up virtualbox network settings, under what circumstances is suitable for the mode Xiaobian recommended "VirtualBox virtual machine" has four different modes in virtualbox: 1, NAT network address translation mode (NAT, Network Address Translation 2, Bridged Adapter bridge mode 3, Internal internal network mode 4, Host-only Adapter host mode The first NAT mode NAT mode is the easiest way to achieve virtual machine Internet access, you can understand this: Vhost access to all data of the network It is provided by the host. The vhost does not exist in the network. The host and any machine on the network cannot view and access the existence of Vhost. Relationship between a virtual machine and a host: It can only be accessed in one direction. The virtual machine can access the host through the network, and the host cannot access the virtual machine through the network. The relationship between a virtual machine and other hosts on the network: only one-way access, the virtual machine can access other hosts on the network, and other hosts cannot access the virtual machine through the network. The relationship between a virtual machine and a virtual machine: the virtual machine and the virtual machine are completely independent of each other, and each other cannot access each other through the network. IP: 10.0.2.15 Gateway: 10.0.2.2 DNS: 10.0.0.3 Multiple NICs of a virtual machine can be set to use NAT, the first NIC is connected to the private network 10.0.2.0, and the second NIC is connected to the dedicated network. Network 10.0.3.0, and so on. The default client ip (IP Address) is 10.0.2.15, the gateway (Gateway) is 10.0.2.2, and the domain name server (DNS) is 10.0.0.3. You can manually modify this by referring to this. Advantages and Disadvantages of NAT Solution: When the notebook is plugged in the network cable: The virtual machine can access the host, and the virtual machine can access the Internet. After port mapping (final description), the host can access the service (such as database) on the virtual machine. When the notebook is not plugged in: The host's "local connection" has a red cross, the virtual machine can access the host, the virtual machine can not access the Internet, after doing the port mapping, the host can access the service on the virtual machine (such as the database) The second Bridged Adapter mode explanation: Bridge mode is one of my favorite modes, and the simulation is quite perfect. You can understand this, it is through the host network card, set up a bridge, directly connected to the network. Therefore, it enables virtual machines to be assigned to independent IPs in a network, all network functions are exactly the same as real machines in the network. Relationship between virtual machine and host: You can access each other because the virtual machine has independent IP in the real network segment. The host and the virtual machine are in the same network segment and can access each other through their respective IPs. The virtual machine is in other host relationships in the network: it can access each other. Similarly, because the virtual machine has independent IP in the real network segment, the virtual machine is in the same network segment as other hosts on the network, and can access each other through their respective IPs. Virtual machine in virtual machine relationship: can access each other for the same reason. IP: Generally, it is assigned by DHCP. The IP of the local connection to the host is the same network segment. The virtual machine can communicate with the host. When the notebook has been plugged in: (If there is a DHCP server in the network), the host and the virtual machine respectively get an IP through DHCP, and the two IPs are on the same network segment. The host and the virtual machine can be pinged, and the virtual machine can be connected to the Internet. When the notebook is not plugged in: The host and the virtual machine cannot communicate. The host's "local connection" has a red cross, so you cannot manually specify the IP. The virtual machine cannot obtain the IP address through DHCP. After manually specifying the IP address, it cannot communicate with the host because the host has no IP. At this time, the host's VirtualBox Host-Only Network card has ip, 192.168.56.1. Even if the virtual machine manually specifies IP 192.168.56.*, it can't ping the host. The third internal mode explanation: the intranet mode, as the name implies, is the internal network mode. The virtual machine is completely disconnected from the external network, and only the internal network mode between the virtual machine and the virtual machine is realized. Relationship between virtual machine and host: Cannot access each other, do not belong to the same network, and cannot access each other. The relationship between the virtual machine and other hosts in the network: they cannot access each other for the same reason. Virtual machine and virtual machine relationship: You can access each other, provided that when setting up the network, the two virtual machines set the same network name. In the configuration diagram above, the name is intnet. IP: VirtualBox's DHCP server will assign IP to it. Generally, it gets 192.168.56.101. Since it is from 101, you can also specify 192.168.56.* manually. When the notebook is plugged in: The virtual machine can communicate with the host's VirtualBox Host-Only Network card. This scheme is not affected by the host's local connection (network card). The fourth Host-only Adapter mode explanation: Host mode, which is a more complex mode, requires a solid network basics to play. It can be said that the functions implemented in the previous modes can be implemented through the settings of the virtual machine and the network card. We can understand that Vbox simulates a network card used by the virtual machine in the host. All virtual machines are connected to the network card. We can set this network card to realize the Internet and many other functions, such as (network card). Sharing, network card bridging, etc.). The relationship between the virtual machine and the host cannot be mutually accessed by default. The two sides do not belong to the same IP segment. The default IP segment of the host-only NIC is 192.168.56.X. The subnet mask is 255.255.255.0. The subsequent virtual machines are also assigned. This network segment. Through network card sharing, network card bridging, etc., virtual machines can be accessed from each other. The relationship between the virtual machine and the network host cannot be mutually accessed by default. For the same reason, the settings can be used to access each other. The virtual machine and virtual machine relationships can access each other by default, and all belong to the same network segment. The virtual machine accesses the host using the IP address of the host's VirtualBox Host-Only Network card: 192.168.56.1, regardless of the host "local connection", whether there is a red cross, always pass. The host accesses the virtual machine, and the virtual machine's NIC 3 IP: 192.168.56.101, regardless of the host "local connection", there is no red cross, always pass. The virtual machine accesses the Internet and uses its own network card 2. At this time, the host should be able to use the "local connection" wired Internet access (the wireless network card does not work) through the understanding of the above network modes, we can flexibly use, simulate Form any kind of network environment we want. For example, I want to simulate a single host to monitor the network environment of a LAN. First of all, I opened two virtual machines vhost1 and vhost2. Of course, if the hardware allows, I can also add vhost3, vhost4… all vhosts are set to internat intranet mode, the network name is intnal, the gateway is 192.168.56.100, meaning Is to access the Internet through the 192.168.56.100 network card. One of them has vhost1 set to dual network card, one for intranet mode (192.168.56.100) and one for bridge mode (192.168.1.101). Two NICs are set up to share the NICs between the virtual machines and the local area network. One virtual machine vhost1 is connected to the external network, and all the virtual machines in the local area network are used to implement the external network through vhost1. In this way, vhost1 can monitor the entire virtual machine LAN access. NAT Set Port Mapping http://huzhangsheng.blog.163.com/blog/static/34787784200802801435931/You can set up a virtual machine's service (such as WEB service) by using the command line tool VboxManage agent. You need to know which port the virtual machine's service uses and then decide which port to use on the host (usually but not always wanting the virtual machine and host to use the same port). Providing a service on the host requires a port, and you can use any port on the host that is not ready to serve. An example of how to set up a new NAT, connecting to an ssh server on a virtual machine, 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" 22VBoxManage setextradata "Linux Guest""VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222 Description: VboxManage is a command line program, please check your VirtualBox installation directory, "Linux Guest" is the virtual host name. The guestsh is a custom name, you can set it arbitrarily, and forward the 22 port of the virtual machine to the port 2222 of the host through the above three commands. For example, I installed the apache2 server on the virtual machine debian, using port 80, mapped 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: For the settings to take effect, please turn off VirtualBox and run the virtual machine, install VirtualBox on winxp, install debian in the virtual machine. 4.02r, the virtual machine name is debian, and apache2 php5 mysql-server is installed. On the host, use IE to browse http://localhost, and successfully forward it to the virtual machine debian apache2 web server. This article comes from [system home] www .xp85.com
Copyright © Windows knowledge All Rights Reserved