NAT and Network Bridge

Source: Internet
Author: User

There are 2 ways to surf the Internet in a virtual machine or Docker container: Bridging and NAT

(1) Basic principle of bridge connection

A virtual machine configured as a bridged network connection mode can be used as a standalone host for the Ethernet of the host, the relationship between the virtual system and the host machine, like two computers connected to the same hub, which can access all the shared resources and network connections in the Ethernet as a host. Internet access can be directly shared with the host network, and the Internet can also access the virtual machine independently. Each virtual machine is connected to the host Ethernet via the default VMNET0 virtual network card, and the virtual machine between virtual machines is VMnet0. The virtual host only needs to be configured with the physical machine as the network segment IP, the same subnet mask, DNS, and gateway. What you need to do (set up a virtual machine VMnet0 bridge to a physical network card, set up a virtual machine NIC Bridge to a network bridge, configure the virtual machine IP address, DNS, and gateway-may require a local connection to the local host to enable VMware Bridge protocal)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/8B/E4/wKiom1hblG_gdA-AAAAyVxGQYEU651.png "title=" net_ Bridge_mode. PNG "alt=" Wkiom1hblg_gda-aaaayvxgqyeu651.png "/>

Set up a virtual machine can configure multiple virtual network cards to obtain multiple IP addresses, only need to change the/etc/network/interfaces file to add eth0 virtual subnets:

Auto Eth0

Iface eth0 inet Static

Address 10.66.47.8

Netmask 255.255.0.0

Gateway 10.66.255.254

Dns-nameservers 192.168.1.1

Auto eth0:1

Iface eth0:1 inet Static

Address 10.66.47.7

Netmask 255.255.0.0

Gateway 10.66.255.254

Dns-nameservers 192.168.1.1

Auto eth0:2

Iface eth0:2 inet Static

Address 10.66.47.6

Netmask 255.255.0.0

Gateway 10.66.255.254

Dns-nameservers 192.168.1.1

(2) Nat Mode

Using NAT mode, the virtual system uses the NAT (network address translation) function to access the public network through the network where the host machine resides. In other words, the use of NAT mode allows access to the Internet in virtual systems, but the Internet cannot access virtual machines. The TCP/IP configuration information for a virtual system in NAT mode is provided by the DHCP server of the VMNET8 (NAT) virtual network and cannot be modified manually, so the virtual system cannot communicate with other real hosts on the local area network. The biggest advantage of using NAT mode is that virtual system access to the Internet is very simple, you do not need to do any other configuration, only the host machine can access the Internet.


This article from "Tech record" blog, declined reprint!

NAT and Network Bridge

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.