[docker]使用quaaga实现(rip ospf)实现主机间容器互通

本文介绍如何使用Quagga实现容器间的互通,并通过配置RIP和OSPF路由协议来确保不同网络间的可达性。文章详细展示了创建桥接设备、配置静态地址及启动Quagga服务的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用quaaga实现(rip ospf)实现主机间容器互通

9e792b8fgy1fmnmgvn3wgj20qm07pt98.jpg

- n1设置
brctl addbr br0
ip a a 10.1.1.1/24 br0
ip a a 10.1.1.1/24 dev br0
ip l s dev br0 up
systemctl stop docker
dockerd -b=br0
docker run -itd --name=router --privileged --net=host georce/router


- n2设置
brctl addbr br0
ip a a 20.1.1.1/24 br0
ip a a 20.1.1.1/24 dev br0
ip l s dev br0 up
systemctl stop docker
dockerd -b=br0
docker run -itd --name=router --privileged --net=host georce/router

georce/router的dockerfile

https://hub.docker.com/r/georce/router/~/dockerfile/

FROM debian:jessie
MAINTAINER 谁改谁去死!

RUN apt-get update
RUN apt-get install -y quagga
COPY daemons /etc/quagga/daemons
COPY ospfd.conf /etc/quagga/ospfd.conf
COPY ripd.conf /etc/quagga/ripd.conf
COPY run.sh /opt/run.sh
RUN chmod 755 /opt/run.sh
RUN chown quagga:quagga /etc/quagga/*.conf
CMD ["/opt/run.sh"]

quagga提供了startup-configure

这个镜像同时跑了rip和ospf


root@n2:/# cat /etc/quagga/ripd.conf
!
! Zebra configuration saved from vty
!   2015/05/16 14:07:09
!
hostname ripd
password zebra
log stdout
!
router rip
 version 2
 network 0.0.0.0/0
!
line vty
!
root@n2:/# cat /etc/quagga/ospfd.conf 
!
! Zebra configuration saved from vty
!   2015/05/16 14:03:27
!
hostname ospfd
password zebra
log stdout
!
!
!
interface docker0
!
interface eth0
!
interface lo
!
router ospf
 network 0.0.0.0/0 area 0.0.0.0
!
line vty
!

命令基本和思科的差不多

root@n2:/# vtysh
n2.ma.com# show ip route rip 
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, A - Babel,
       > - selected route, * - FIB route

R   10.1.1.0/24 [120/2] via 192.168.1.11, eth0, 00:07:00
n2.ma.com# show ip route os
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, A - Babel,
       > - selected route, * - FIB route

O>* 10.1.1.0/24 [110/20] via 192.168.1.11, eth0, 00:07:12
O   20.1.1.0/24 [110/10] is directly connected, br0, 00:07:26
O>* 127.0.0.1/32 [110/10] is directly connected, lo, 00:07:26
O   172.17.0.0/16 [110/10] is directly connected, docker0, 00:07:26
O   192.168.1.0/24 [110/10] is directly connected, eth0, 00:07:26


测试docker连通性

docker run -it --rm busybox
/ # ping 10.1.1.1
PING 10.1.1.1 (10.1.1.1): 56 data bytes
64 bytes from 10.1.1.1: seq=387 ttl=63 time=0.568 ms
64 bytes from 10.1.1.1: seq=388 ttl=63 time=0.992 ms
64 bytes from 10.1.1.1: seq=389 ttl=63 time=0.955 ms

支持的路由协议

root@n2:/# vtysh
n2.ma.com# conf t
n2.ma.com(config)# router 
  babel  Babel
  bgp    BGP information
  isis   ISO IS-IS
  ospf   Start OSPF configuration
  ospf6  Open Shortest Path First (OSPF) for IPv6
  rip    RIP
  ripng  RIPng

806469-20171220225559584-1239843186.png

806469-20171220225554053-722128263.png

转载于:https://www.cnblogs.com/iiiiher/p/8076257.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值