Virtual machine bridging way to the Internet

Source: Internet
Author: User
Tags nameserver

Recently, the Virtual Machine Bridge network cost a lot of time, for two reasons: first, just contact with Linux, a variety of operations are not familiar with the basic, but the school is relatively special Internet access (Campus network +bras: Broadband Remote Access Service equipment). And the information on the network is in the comparison of universal broadband connection environment, there is no specific relevant details. In the hard pursuit of time, boldly set a bit of IP, did not think of the pass ... Life is like this, inadvertently filled with surprises. Cut the crap, let's get to the point.

Introduction to the environment:

Host os:win7

Network: Wired

Virtual machine: VMware 8.0.2

Os:ubuntu 12.0.4

Note:

Ubuntu seems to default to the Internet is NAT, if you initially set the network card when the NAT mode (corresponding to the virtual Switch: VMNET8), then do not have any operation to access the Internet (of course, if the host should be able to access the Internet).

Step: Assume that the virtual machine and Ubuntu OS have been installed successfully

(1) Virtual Machine network adapter set bridge mode ----corresponding Virtual switch: VMnet0

working principle:

Bridge way, that is bridging. Consider a virtual machine as another physical host on the same network segment as the host. From this sentence we can draw the following information:

I, the virtual machine IP address and host on the same network segment

II, virtual subnet masks, gateways, and DNS server addresses are the same as hosts

To get a clearer picture of this, look at its network topology:

Start setting:

Open the virtual machine, click on the "Network Adapter" option, under "Network connection" select "Bridged ..."

Click the "Edit" option on the upper part of the virtual machine, select "Virutal network Editor ...", and then open Virutal network Editor, select Vmnet under information bridged, and set the NIC for the bridged to host (cannot be set to "Automatic").

(2) Set the virtual machine IP address

Login to Ubuntu, modify 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: 10.3.7.200)

Netmask 255.255.252.0 (same as 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's a little bit of detail, it's generally thought, to set the DNS server address in the resolv.conf file, but later you'll notice that every restart ubuntu,resolv.conf modification is cleared, that is, empty .

Solution: Find the source of resolv.conf

Cd/etc/resolvconf/resolv.conf.d

There are four files in this directory: base, head, original, tail.

In tail(if there is no such file, create one), add the DNS server to its address.

Vim tail

The settings are as follows:

NameServer xx.xx.xx.xx (same as host)

NameServer xx.xx.xx.xx (same as host)

Note: You can also find that the head file in this directory has the same content as resolv.conf. After the reboot, the resolv.conf content will be the head content + tail content.

(4) Restart the network and test connectivity

/etc/init.d/networking restart

At this point you can test the connectivity between the host and the virtual machine:

Under Virtual machine: Ping 10.3.7.200, you can also try Ping 10.3.4.1 (Gateway)

Pass ...

Under Host: Ping 10.3.7.201

Pass ...

--------------------------------------------------------------------------------------------------------------- -----------------------------

At this point you can also test the connectivity of the virtual machine and campus network: Ping www.seu.edu.cn (School home page domain name)

Pass ...

--------------------------------------------------------------------------------------------------------------- ------------------------------

Note:

at this point only the LAN host and virtual machine internal interoperability, although the host can connect the Internet, but the virtual machine is not connected to the Internet.

For virtual machines to also be connected to the Internet, you need to set up Internet Connection Sharing (ICS)on the host, which is to set the broadband connection to shared so that the virtual machine shares the host's Internet connection. (Details can refer to http://blog.csdn.net/heyabo/article/details/7726522)

So here's how to continue:

(5) Set up the host's Internet connection (that is, the broadband connection, because of special circumstances, my bras connection, but the function is the same) for the sharing mode

First, share settings based on regular Internet Connection Sharing

Then, when you set up a TCP/IP connection for the client (which refers to the virtual machine), you need to set it to either dynamically or as a static IP address to the same network segment as the host.

Here, select the latter. Because the IP address of the host's "Local Area Connection" is set to 192.168.137.1 after the broadband connection is set to be shared. Following the usual ideas, next, you need to reset the IP address of the previous virtual machine For the same segment as the 192.168.137.1, and set the virtual machine gateway to 1982.168.137.1.

However: In view of their specific situation: the way to the Internet for the campus network +bras (the need to configure accurate static IP and gateway, DNS, etc. can be networked). So when the host's "Local connection" IP address is set to 192.168.137.1, the host will not be networked, so that the virtual machine can not be networked, that is, no follow-up ... Therefore, the host must be connected to the Internet, and the host to the Internet, it must be set for the school given the IP network segment, gateway, DNS, etc.

Solution:

Considering the idea of ICS: multiple computers in the same network segment share an Internet connection, which is key to maintaining the same network segment of the host and the virtual machine .

Create an idea: When the host's "Local Area Connection" is modified, keep the "shared" mode of "broadband connection" (here is the Bras connection), but force the "local Area Connection" to be restored to the original setting------the host computer to the Internet, and then consider the connectivity of the virtual machine.


Host can be networked.


(5) Restart network

/etc/init.d/networking restart

At this point, the virtual function and the same as before, can still communicate with the internal host, and can connect the internal campus network.

That is, the host connects to the external network and sets ICS + virtual machine to connect the internal network----> host, Virtual machine share the Internet, both can access the Internet.

(6) test

after "sharing"

Test and host connectivity: Ping 10.3.7.200 pass.

Test connectivity with the campus network: Ping www.seu.edu.cn pass.

Test and Internet connectivity: Ping www.google.com.

Conclusion: The key is to make the host and the virtual machine in the same network segment, and the specific IP address is not the key point.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.