首页 > 代码库 > docker配置桥接网络
docker配置桥接网络
[root@localhost ~]# cd /etc/sysconfig/network-scripts/[root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-br0[root@localhost network-scripts]# vi ifcfg-eth0//改成这样DEVICE=eth0HWADDR=00:0C:29:06:A2:35TYPE=EthernetUUID=34b706cc-aa46-4be3-91fc-d1f48c301f23ONBOOT=yesBRIDGE=br0NM_CONTROLLED=yesBOOTPROTO=static[root@localhost network-scripts]# vi ifcfg-br0//改成这样DEVICE=br0TYPE=BridgeONBOOT=yesBOOTPROTO=staticIPADDR=192.168.216.131NETMASK=255.255.255.0GATEWAY=192.168.216.2DNS=8.8.8.8[root@localhost network-scripts]# service network restart正在关闭接口 eth0: bridge br0 does not exist! [确定]关闭环回接口: [确定]弹出环回接口: [确定]弹出界面 eth0: [确定]弹出界面 br0: Determining if ip address 192.168.216.131 is already in use for device br0... [确定]
操作遇到以下问题:!!!!
[root@localhost network-scripts]# service network restart/* 这里如果10秒以上没有反应,那就需要去虚拟机检查。 登陆--〉 ifconfig 查看eth0是否存在 --〉 ping www.baidu.com (是否通) --〉 ping 网关 (不通,则配置有问题) --〉 (通) 检查ifcfg-eth0 ifcfg-br0是否写对*/
[root@localhost network-scripts]# yum install -y git[root@localhost network-scripts]# git clone https://github.com/jpetazzo/pipework[root@localhost network-scripts]# cp pipework/pipework /usr/local/bin/[root@localhost network-scripts]# cd//用centos6来弄一个容器[root@localhost ~]# docker run -itd --net=none --name=ff centos-6-x86 bash4278a68ee82a.....//没有网络[root@4278a68ee82a /]# ifconfiglo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)[root@4278a68ee82a /]# exit//再次进入宿主机 [root@localhost ~]# rpm -Uvh https://repos.fedorapeople.org/openstack/EOL/openstack-grizzly/epel-6/iproute-2.6.32-130.el6ost.netns.2.x86_64.rpmRetrieving https://repos.fedorapeople.org/openstack/EOL/openstack-grizzly/epel-6/iproute-2.6.32-130.el6ost.netns.2.x86_64.rpmwarning: /var/tmp/rpm-tmp.QuEQJe: Header V4 RSA/SHA1 Signature, key ID d97b3247: NOKEYPreparing... ########################################### [100%] 1:iproute ########################################### [100%]//配置一个新的ip,只要是和br0同网段,且没有被用过[root@localhost ~]# pipework br0 fl 192.168.216.135/24[root@localhost ~]# docker exec -it fl bash[root@4278a68ee82a /]# ifconfigeth1 Link encap:Ethernet HWaddr E2:9B:98:70:C2:05 inet addr:192.168.216.135 Bcast:192.168.216.255 Mask:255.255.255.0 inet6 addr: fe80::e09b:98ff:fe70:c205/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6 errors:0 dropped:0 overruns:0 frame:0 TX packets:7 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:468 (468.0 b) TX bytes:510 (510.0 b)lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)/* 这一步不是特别重要,知道就好 *///ping的通网关,但是还是不能上网,因为还没有配置网关和上网的路由 [root@4278a68ee82a /]# ping 192.168.216.2PING 192.168.216.2 (192.168.216.2) 56(84) bytes of data.64 bytes from 192.168.216.2: icmp_seq=1 ttl=128 time=2.07 ms64 bytes from 192.168.216.2: icmp_seq=2 ttl=128 time=0.563 ms^C--- 192.168.216.2 ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 1498msrtt min/avg/max/mdev = 0.563/1.319/2.075/0.756 ms[root@4278a68ee82a /]# ping www.qq.comconnect: Network is unreachable/* 这就完成了 */
docker配置桥接网络
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。