docker配置桥接网络
配置桥接网络复制网卡配置文件ifcfg-ens33为ifcfg-br0,修改ifcfg-br0
# cd /etc/sysconfig/network-scripts/
# cp ifcfg-ens33 ifcfg-br0
# vim ifcfg-br0 //修改TYPE,NAME,DEVICE
https://s1.运维网.com/images/blog/201804/12/1d3d374beebadd816fbf4489e803463b.png
修改网卡配置文件
//删除UUID,IPADDR,NETMASK,GATEWAY,DNS
//增加 BRIDGE=br0
# vim ifcfg-ens33
https://s1.运维网.com/images/blog/201804/12/734eb26c544c9b6d77f57ee2bc126ce4.png
重启网卡服务
# systemctl restart network
查看
https://s1.运维网.com/images/blog/201804/12/2cd2baa3974f72f0b60a093ef7b6bb0b.png
https://s1.运维网.com/images/blog/201804/12/0a31721a8ecdce327471f180167d4936.png
安装pipwork
# yum install git -y
# git clone https://github.com/jpetazzo/pipework
复制 /root/pipwork/pipwork到 /usr/local/bin/
# cd pipework/
# cp pipework /usr/local/bin/
开启一个容器,给这个容器设置ip,gateway,进入容器看看是否能联网
# docker run -itd --net=none centos bash
20e3285100628f86c21e0cfc887f2b874667001917568fcc34cb56cb4ce278ff
# pipework br0 20e32851 192.168.221.100/24@192.168.221.2
# docker exec -it 20e32851 /bin/bash
# ping www.baidu.com
PING www.a.shifen.com (119.75.213.61) 56(84) bytes of data.
64 bytes from 119.75.213.61 (119.75.213.61): icmp_seq=1 ttl=128 time=23.2 ms
64 bytes from 119.75.213.61 (119.75.213.61): icmp_seq=2 ttl=128 time=23.5 ms
64 bytes from 119.75.213.61 (119.75.213.61): icmp_seq=3 ttl=128 time=23.2 ms
页:
[1]