Skip to content

Quagga with Docker and Open vSwitch

Hyunsun Moon edited this page Jul 12, 2016 · 31 revisions

Prerequisite

  • Two hosts with network connectivity, one is external router and the other is gateway
  • Docker (1.11.1) and Open vSwitch(2.3.2) installed in the compute hosts

Step 1

Clone run script and download Docker image in each node.

$ git clone https://github.com/hyunsun/docker-quagga
$ sudo docker pull hyunsun/quagga-fpm

Step 2

Create a OVS bridge in all hosts and make a tunnel between them. If the hosts are in the same broadcast domain, you can simply add the physical interface to the OVS bridge.

$ sudo ovs-vsctl add-br br-ex
$ sudo ovs-vsctl add-port br-ex vxlan -- set interface vxlan type=vxlan options:remote_ip=x.x.x.x
$ sudo ip link set br-ex up

Pick any subnet range to use for the connection between containers and add one of the IP to the br-ex. The IP should be unique across the compute hosts.

hyunsun@router$ sudo ip addr add 172.18.0.100/24 dev br-ex

hyunsun@gateway$ sudo ip addr add 172.18.0.101/24 dev br-ex
hyunsun@gateway$ ping 172.18.0.100
PING 172.18.0.100 (172.18.0.100) 56(84) bytes of data.
64 bytes from 172.18.0.100: icmp_seq=1 ttl=64 time=1.92 ms
64 bytes from 172.18.0.100: icmp_seq=2 ttl=64 time=0.733 ms

Now the router and the gateway in this example should be able to ping to each other withe the assigned IP address.

Step 3

Create BGP and zebra config files as you want under docker-quagga/volumes/quagga with the name of bgpd.conf and zebra.conf. You can find lots of information about how to configure BGP or Quagga from Google but I'm adding a simple BGP configuration here to advert default route. You may use it for router node Quagga.

! -*- bgp -*-
!
! BGPd sample configuration file
!
!
hostname router
password zebra
!
router bgp 65100
  bgp router-id 172.18.0.1
  timers bgp 3 9
  neighbor 172.18.0.254 remote-as 65101
  neighbor 172.18.0.254 ebgp-multihop
  neighbor 172.18.0.254 timers connect 5
  neighbor 172.18.0.254 advertisement-interval 5
  neighbor 172.18.0.254 default-originate
!
log file /var/log/quagga/bgpd.log

Run run.sh to create a quagga container. The script helps to create a container with two interfaces, one is attached to the docker0 and the other is to br-ex. The IP address of the container must be the range you picked.

hyunsun@router$ ./run.sh router 172.18.0.1/24 00:00:00:00:01:00
4a3dfae4e0179820698074fc2b38d101f29cb6cd60153b052017ac4dd32a627e
hyunsun@router$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
6690e272334e        quagga              "/usr/bin/supervisord"   2 minutes ago       Up About a minute                       router

hyunsun@gateway$ ./run.sh gateway 172.18.0.254/24 00:00:00:00:01:01
6690e272334e197da19da27205fbff449f60ddf1c75dec0e4efd44cf2bb67d41

Check if the containers can ping to each other.

root@gateway:/# ping 172.18.0.1
PING 172.18.0.1 (172.18.0.1) 56(84) bytes of data.
64 bytes from 172.18.0.1: icmp_seq=1 ttl=64 time=0.561 ms
64 bytes from 172.18.0.1: icmp_seq=2 ttl=64 time=0.075 ms

Step 4

Now you can also access to the Quagga from the compute host with telnet [container IP] 2601.

hyunsun@gateway$ telnet 172.18.0.254 2601
Trying 172.18.0.254...
Connected to 172.18.0.254.
Escape character is '^]'.

Hello, this is Quagga (version 0.99.22.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

Password:
router-gateway>
router-gateway> show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, A - Babel,
       > - selected route, * - FIB route

B   0.0.0.0/0 [20/0] via 172.18.0.1, eth1, 00:01:59
C>* 127.0.0.0/8 is directly connected, lo
C>* 172.17.0.0/16 is directly connected, eth0
C>* 172.18.0.0/24 is directly connected, eth1