Recently, it took a lot of time to merge network connections by using the bridge virtual machine. There are two reasons: first, I am new to linux, and I am not familiar with various operations; however, the school's Internet access method is quite special (Campus Network + BRAS: broadband remote access service equipment ). In addition, the information on the network is in a general broadband connection environment and there is no specific details. When I was struggling to seek, I boldly set up an IP address. I didn't expect it to be okay !..... Life is like this, and it is full of surprises. Let's talk nonsense. Next we will go to the topic.
Environment Introduction:
Host OS: Win7
Network: wired
Virtual Machine: VMware 8.0.2
OS: Ubuntu 12.0.4
Note:
Ubuntu looks like the default Internet access method is NAT. If you select the NAT mode (corresponding to the Virtual Switch: VMnet8) when you first set the network adapter ), you can access the Internet without any operation (the premise is that the host must be able to access the Internet ).
Step: assume that the VM and Ubuntu OS have been successfully installed.
(1) set the Bridge Mode for the Virtual Machine Network Adapter---- Corresponding vswitch: VMnet0
Working principle:
Bridge mode, that is, Bridge. View the VM as another physical host in the same network segment of the host. The following information can be obtained from this sentence:
I. The virtual machine IP address is in the same network segment as the host
II. The virtual machine subnet mask, gateway, and DNS server address are the same as those of the host.
To better understand this, you can see the network topology:
Start setting:
Open the VM, click the "Network Adapter" option, and under "Network connection", select "Bridged ..."
Click "Edit" in the upper part of the VM and select "Virutal Network Editor... ", then select Bridged under" VMnet Information "in the Virutal Network Editor, and set the nic of the Bridged to host (cannot be set to" Automatic ").
(2) set the Virtual Machine IP Address
Log on to Ubuntu and modify the interfaces file.
CD/etc/Network
Vim Interfaces
The settings are as follows:
Auto eth0
Iface etho Inet static
Address 10.3.7.201 (Host IP Address: 10.3.7.200)
Netmask 255.255.252.0 (same as the host)
Network 10.3.4.0 (same as host)
Broadcast 10.3.7.255 (same as host)
Gateway 10.3.4.1 (same as host)
(3) set the Virtual Machine DNS server address
Note:
Here is the details. Generally, you must set the dns server address inResolv. confFile, but later you will find that every time you restart Ubuntu, all the content modified by resolv. conf is cleared, that isEmpty.
Solution:Find the source of resolv. conf
Cd/etc/resolvconf/resolv. conf. d
There are four files in this directory: base, head, original, tail.
InTail(If this file does not exist, create one) to add the DNS server address.
Vim tail
The settings are as follows:
Nameserver xx. xx (same as host)
Nameserver xx. xx (same as host)
Note: You can also find that the content in the head file under this directory is the same as that in resolv. conf. After the restart, the resolv. conf content is the head content + tail content.
(4) restart the network and test connectivity
/Etc/init. d/networking restart
In this case, you can test the connectivity between the host and the virtual machine:
In a virtual machine: ping 10.3.7.200. You can also try to ping 10.3.4.1 (GATEWAY)
Yes !!!
Under the Host: ping 10.3.7.201
Yes !!!
Certificate --------------------------------------------------------------------------------------------------------------------------------------------
In this case, you can test the connectivity between the VM and the campus network: ping www.seu.edu.cn (school homepage domain name)
Yes !!!
Certificate ---------------------------------------------------------------------------------------------------------------------------------------------
Note:
At this time, it is only the internal communication between the LAN host and the virtual machine. Although the host can connect to the Internet, the virtual machine cannot connect to the Internet.
To enable the Internet access of virtual machines, you need to configureInternet Connection Sharing (ICS )"That is, set the bandwidth connection to "share" so that the virtual machine can share the Internet connection of the host. (For details, referHttp://blog.csdn.net/heyabo/article/details/7726522)
Therefore, we need to continue the operation below:
(5) set the Internet connection of the host(That is, broadband connections. due to special circumstances, I use BRAS connections, but the functions are the same)For sharing
First, set the sharing according to the conventional Internet Connection Sharing.
Then, when setting the TCP/IP connection of the client (this refers to the virtual machine), you need to set it according to the actual situation, which can be set to dynamic acquisition, you can also set the static IP address of the same network segment as the host.
Select the latter. After "Broadband connection" is set to shared, the IP address of the "local connection" of the host is set to 192.168.137.1. According to the general idea, next we needReset the IP address of the VMIt is in the same network segment as 192.168.137.1, and the virtual machine gateway is set to 198213137.1.
However, considering its specific situation, the Internet access mode is Campus Network + BRAS (you need to configure an accurate static IP address and gateway, DNS, etc ). For example, if the IP address of the "local connection" of the host is set to 192.168.137.1, the host will not be connected to the Internet, and the virtual machine will not be connected to the Internet at that time, that is, there will be no subsequent ...... therefore, the host must access the Internet, and the host must be set to the IP segment, gateway, DNS, and so on specified by the school.
Solution:
Considering the concept of ICS, multiple computers in the same network segment share Internet connections, that isMaintaining the same network segment of the host and virtual machine is critical.
There is an idea: after the "local connection" of the host is modified, the "sharing" method of "Broadband connection" (Bras connection here) will be maintained, however, force the "local connection" back to the original setting-first surfing the Internet on the host, and then considering the connectivity of the virtual machine.
Hosts can be connected to the Internet!
(5) restart the network
/Etc/init. d/networking restart
At this time, we found that the virtual machine can still communicate with internal hosts and connect to the internal campus network, just as before.
That is, the host connects to the external network and the ICS + Virtual Machine connects to the internal network ----> the host and virtual machine share the Internet, both of which can access the Internet.
(6) test
After "share"
Test connectivity with the Host: ping 10.3.7.200!
Test connectivity with the campus network: ping www.seu.edu.cn!
Test and Internet connectivity: ping www.google.com!
Conclusion: The Key to selecting bridge to access the Internet is to make the host and virtual machine in the same network segment, but the specific IP address is not the focus.