CENTOS7 installation of Docker (15.3 cross-host network-macvlan)

Source: Internet
Author: User

In addition to Ovrlay,docker has developed another driver:macvlan that supports cross-host containers

Macvlan itself is the Linu kernel module, its function is to allow the same physical network card configured with more MAC address, that is: multiple interface, each interface can configure their own IP. Macvlan itself is a network card virtualization technology, Docker with Macvlan to implement the container network is not surprising

the biggest advantage of Macvlan is the excellent performance, compared to other scenarios, Macvlan does not need to create a Linux bridge, but directly through the Ethernet interface connected to the physical network .

Prepare the lab environment:

We will create Macvlan using separate NIC ens192 and ens160 on Docker1 and Docker2. To ensure that multiple MAC address network packets can be passed from ens190 or ens160, we need to turn on the NIC promiscuous mode

Because the Docker1 number Docker2 is a virtual machine, set promiscuous mode in the NIC configuration options

The current test environment is as follows: Theft map

Create a Macvlan network

Docker network create-d Macvlan--subnet 192.168.2.1/24--gateway 192.168.2.1-o parent=ens160 Macnet1

Note: Macvlan network is the local network, in order to ensure that cross-host communication, users need to manage their own IP subnet

Unlike other networks, Docker does not create a gateway for the Macvlan network, where the gateway should be real, or the route will not pass

-O parent Specifies the network interface to use

The same command is also executed in Docker2: Docker network create-d macvlan--subnet 192.168.2.1/24--gateway 192.168.2.1-o parent=ens160 Macnet1

Running the container in Docker1

Docker network create-d Macvlan--subnet 192.168.2.1/24--gateway 192.168.2.1-o parent=ens160 Macnet1

Perform the same operation in Docker2:

Verify the connectivity of the MAC1 on the Docker1 to the MAC2 on the Docker2

The containers between the two different hosts can ping each other, but the host name of the container cannot be resolved, and Docker does not provide DNS services for Macvlan, which is different from overlay

Note: Macvlan is a real network in physics, Macvlan is actually the sub-interface of our commonly used NIC, similar to: eth0:1

MACVLAN Network Structure Analysis:

Macvlan does not rely on Linux Bridge,brctl Show can confirm that Macvlan did not create a new bridge

Check the network device for the container MAC1:

In addition to Lo, the container has only one eth0, please note: Eth0 is also followed by @if2, indicating that the NIC has a corresponding interface, the global number is 2,. According to the principle of macvlan, we suspect that this interface is ens192,

Confirm as follows:

As can be seen, the eth0 of the container is ens192 through Macvlan virtual interface. The interface of the container is directly connected to the host's NIC, which means that the container can communicate directly with the external network without NAT and port mapping (as long as there is a gateway) there is no difference from other independent hosts on the network

Current network:

CENTOS7 installation of Docker (15.3 cross-host network-macvlan)

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.