[docker]使用quaaga實現(rip ospf)實現主機間容器互通
阿新 • • 發佈:2017-12-21
png ner direct ipv6 mon eth0 area stdout get
使用quaaga實現(rip ospf)實現主機間容器互通
- 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
[docker]使用quaaga實現(rip ospf)實現主機間容器互通