Docker——桥接网络配置


    
    
  1. [ root @localhost ~]# cd /etc/sysconfig/network-scripts/
  2. [ root @localhost network-scripts]# ls
  3. ifcfg-eth0 ifdown-ib ifdown-ppp ifup-aliases ifup-ipv6 ifup-ppp init.ipv6- global
  4. ifcfg-lo ifdown-ippp ifdown-routes ifup-bnep ifup-isdn ifup-routes net.hotplug
  5. ifdown ifdown-ipv6 ifdown-sit ifup-eth ifup-plip ifup-sit network-functions
  6. ifdown-bnep ifdown-isdn ifdown-tunnel ifup-ib ifup-plusb ifup-tunnel network-functions-ipv6
  7. ifdown-eth ifdown-post ifup ifup-ippp ifup-post ifup-wireless
  8. [root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-br0

 


    
    
  1. [root@localhost network-scripts] # vi ifcfg-eth0
  2. DEVICE=eth0
  3. HWADDR=00:0C:29:DB:B2:28
  4. TYPE=Ethernet
  5. UUID=b2268aab-fa2e-49e9-bd67-2572f29e5790
  6. ONBOOT=yes
  7. NM_CONTROLLED=yes
  8. BOOTPROTO=static
  9. IPADDR=192.168.1.179
  10. NETMASK=255.255.255.0
  11. GATEWAY=192.168.1.1
  12. DNS1=114.114.114.114
  13. DNS2=8.8.4.4

 

增加BRIDGE=br0,删除IPADDR、NETMASK、GATEWAY、DNS


    
    
  1. DEVICE=eth0
  2. HWADDR=00:0C:29:DB:B2:28
  3. TYPE=Ethernet
  4. UUID=b2268aab-fa2e-49e9-bd67-2572f29e5790
  5. ONBOOT=yes
  6. BRIDGE=br0
  7. BOOTPROTO=none
  8. #IPADDR=192.168.1.179
  9. #NETMASK=255.255.255.0
  10. #GATEWAY=192.168.1.1
  11. #DNS1=114.114.114.114
  12. #DNS2=8.8.4.4

 

保存退出


    
    
  1. [root@localhost network-scripts] # vi ifcfg-br0
  2. DEVICE=eth0
  3. HWADDR=00:0C:29:DB:B2:28
  4. TYPE=Ethernet
  5. UUID=b2268aab-fa2e-49e9-bd67-2572f29e5790
  6. ONBOOT=yes
  7. NM_CONTROLLED=yes
  8. BOOTPROTO=static
  9. IPADDR=192.168.1.179
  10. NETMASK=255.255.255.0
  11. GATEWAY=192.168.1.1
  12. DNS1=114.114.114.114
  13. DNS2=8.8.4.4

 

修改DEVICE为br0,Type为Bridge,把eth0的网络设置设置到这里来


    
    
  1. DEVICE=br0
  2. TYPE=Bridge
  3. ONBOOT=yes
  4. BOOTPROTO=static
  5. IPADDR=192.168.1.179
  6. NETMASK=255.255.255.0
  7. GATEWAY=192.168.1.1
  8. DNS1=114.114.114.114
  9. DNS2=8.8.4.4

 

保存退出

[root@localhost network-scripts]# service network restart
    
    

 

这一步我出现了问题,不过重启宿主机后就OK了。


    
    
  1. [root @localhost ~]# ifconfig
  2. br 0 Link encap:Ethernet HWaddr 00:0C:29:DB:B2:28
  3. inet addr:192.168.1.179 Bcast:192.168.1.255 Mask:255.255.255.0
  4. inet6 addr: fe80::20c:29ff:fedb:b228/64 Scope:Link
  5. UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  6. RX packets:137 errors:0 dropped:0 overruns:0 frame:0
  7. TX packets:93 errors:0 dropped:0 overruns:0 carrier:0
  8. collisions:0 txqueuelen:0
  9. RX bytes:13745 (13.4 KiB) TX bytes:11095 (10.8 KiB)
  10. docker0 Link encap:Ethernet HWaddr C6:01:70:AF:C6:E4
  11. inet addr:172.17.42.1 Bcast:0.0.0.0 Mask:255.255.0.0
  12. inet6 addr: fe80::c401:70ff:feaf:c6e4/64 Scope:Link
  13. UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  14. RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  15. TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
  16. collisions:0 txqueuelen:0
  17. RX bytes:0 (0.0 b) TX bytes:468 (468.0 b)
  18. eth0 Link encap:Ethernet HWaddr 00:0C:29:DB:B2:28
  19. inet6 addr: fe80::20c:29ff:fedb:b228/64 Scope:Link
  20. UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  21. RX packets:137 errors:0 dropped:0 overruns:0 frame:0
  22. TX packets:101 errors:0 dropped:0 overruns:0 carrier:0
  23. collisions:0 txqueuelen:1000
  24. RX bytes:15663 (15.2 KiB) TX bytes:11959 (11.6 KiB)
  25. lo Link encap:Local Loopback
  26. inet addr:127.0.0.1

转载于:https://www.cnblogs.com/fuyuteng/p/8857755.html

        <div class="person-messagebox">
            <div class="left-message"><a href="https://blog.csdn.net/weixin_34237596">
                <img src="https://profile.csdnimg.cn/9/6/7/3_weixin_34237596" class="avatar_pic" username="weixin_34237596">
            </a></div>
            <div class="middle-message">
                                    <div class="title"><span class="tit "><a href="https://blog.csdn.net/weixin_34237596" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;,&quot;ab&quot;:&quot;new&quot;}" target="_blank">weixin_34237596</a></span>
                    <!-- 等级,level -->
                                            <img class="identity-icon" src="https://csdnimg.cn/identity/blog4.png">                                            </div>
                <div class="text"><span>原创文章 158</span><span>获赞 52</span><span>访问量 26万+</span></div>
            </div>
                            <div class="right-message">
                                        <a class="btn btn-sm  bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;,&quot;ab&quot;:&quot;new&quot;}">关注</a>
                                                            <a href="https://im.csdn.net/im/main.html?userName=weixin_34237596" target="_blank" class="btn btn-sm bt-button personal-letter">私信
                    </a>
                                </div>
                        </div>
                    
    </div>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值