[Svc]linux Bridge-docker Network Bridge

Source: Internet
Author: User
Tags docker run

Bridges and Switches

2-Port switch = Bridge


Switch: Works on the data link layer, based on the source Mac Learning (control layer), the purpose of MAC forwarding (data layer).

Network adapter for Linux

Bridging in VMware Workstation

Reference: http://blog.daocloud.io/docker-bridge/

Bridging the Docker0

Reference: http://blog.daocloud.io/docker-bridge/



Bridge Operation Tool
yum install bridge-utils -y如果需要使用网桥模式,需要关掉NetworkManager服务systemctl stop NetworkManager systemctl disable NetworkManager
Two network cards are placed under a bro

We already know that the BR Nic is a virtual bridge, which is equivalent to a switch that can connect eth0 access eth1

Realize

Method 1: Command-line configuration
- 添加br0brctl addbr br0- 将eth0连到br0brctl addif br0 eth0brctl addif br0 eth1- 清理eth0的地址-这里有点问题吧ifconfig eth0  0.0.0.0- 配置br0的地址ifconfig br0 192.168.1.10 netmask 255.255.255.0 upbrctl addif br0 ath0
Method 2: Persist the configuration

Reference: http://www.solutionsatexperts.com/how-to-create-a-bridge-interface-on-rhelcentos/

-Planning combine eth1 and eth2 physical interfaces and create a virtual interface Br0, assign IP to It.eth1:No IPeth2           : No ipnote:eth1 and eth2 connect to same physical layer/media.br0–> eth1–> eth2 NOTE:BR0 is a virtual interface mapped to eth0 and eth1br0–> 192.168.1.10netmask–> 255.255.255.0G ateway–> 192.168.1.1dns–> 8.8.8.8-Procedure Step 1:disable Network managerstep 2:create virtual Interfa  Ce br0step 3:configure physcial interfaces eth1 and Eth2step 4:restart Network Service and verify network Settingsstep  1:disable Network Managersystemctl Stop NetworkManager # NIC on bridge mode needs to be turned off Networkmanagerstep 2:create virtual interface Br0add ifcfg-br0 file under/etc/sysconfig/network-script/#vi/etc/sysconfig/network-scripts/ifcfg-br0device= br0type=bridgeonboot=yesbootproto=staticipaddr=192.168.1.10netmask=255.255.254.0gateway=192.168.1.1dns1= 114.114.114.114dns2=8.8.8.8save & Exit (: Wq) Step 3:  Configure physcial interfaces eth1 and eth2vi/etc/sysconfig/network-script/ifcfg-eth1device=eth1bootproto= Staticonboot=yesbridge=br0type=ethernetsave & Exit (: WQ) Step 4:restart Network Service and verify network Settingsre Start the network services# systemctl restart networkverify network settings# ifconfig-a
Need a PC to surf the internet via another two-port Linux server

Here to understand, the interaction data between the two bridges: Anza by Table (or NAT)

The idea is actually simple:

    • 1. is to be virtual out of a bridge port
    • 2. Bind the corresponding wired LAN and wireless LAN to this virtual bridge port and assign an address to the bridge port
    • 3. Other subnets microcomputer configuration gateway is the address of bridge port can be.
    • 4. Of course, because the device is a gateway mode, Routing and NAT are also required.
源地址转换iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to 192.168.1.10
Brctl command
$ docker run -itd --name=b1 busybox$ brctl showbridge name bridge id       STP enabled interfaces      docker0     8000.0242fb188161   no      veth0a226d0                                                                               $ docker run -itd --name=b2 busybox                                    $ brctl showbridge name bridge id       STP enabled interfaces  docker0     8000.0242fb188161   no      veth0a226d0                                        vethd9de1b2                                                                                $ brctl showshow      showmacs  showstp- 看到容器的mac地址,docker0这个交换机下接了2个$ brctl showmacs docker0port no mac addr        is local?   ageing timer  1 02:42:ac:11:00:02   no         2.36$ docker exec -it b1 ip ad14: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue     link/ether 02:42:ac:11:00:02
Configuration of the loopback port in Linux
ifconfig lo 130.0.0.1  

[Svc]linux-docker 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.