Public Repository

Last pushed: 2 years ago
Short Description
This is a container to run quagga. quagga is a routing program to speak ospf, isis, bgp and etc.
Full Description

Docker file

FROM ubuntu:14.04
MAINTAINER Toru Okatsu

RUN apt-get update

RUN apt-get install -y quagga
RUN apt-get install -y telnet

ADD zebra.conf /etc/quagga/zebra.conf
ADD isisd.conf /etc/quagga/isisd.conf
ADD init_conf.sh /etc/quagga/init_conf.sh

CMD /etc/quagga/init_conf.sh ; /bin/bash

How to run this container

docker.io run -ti --name router1 --hostname router1 --privileged=true tokatsu/quagga:0.1

You need to set privilege.

About init_conf.sh

init_conf.sh set hostname to quagga config files. It also starts zebra and isisd as daemons

#!/bin/bash
sed -ri "s/hostname .+/hostname $HOSTNAME/" /etc/quagga/zebra.conf
sed -ri "s/hostname .+/hostname $HOSTNAME/" /etc/quagga/isisd.conf
chown -R quagga.quagga /etc/quagga
/usr/lib/quagga/zebra -d
/usr/lib/quagga/isisd -d

Sample configuration

This is a sample configuration to run ISIS with the topology below.

host1---leaf1---leaf2----leaf3----host2

leaf1, leaf2 and leaf3 are level1 ISIS routers. host1 and host2 are end IP nodes.

leaf1 configuration

hostname leaf1
password cisco
enable password cisco
log stdout
!
interface A
!
interface eth0
!
interface link1
 ip router isis zebra
 isis circuit-type level-1
!
interface link3
!
interface lo
!
!
router isis zebra
 net 49.0001.0000.0000.0001.00
 metric-style wide
 is-type level-1

leaf2 configuration

hostname leaf2
password cisco
enable password cisco
log stdout
!
interface A
!
interface B
!
interface eth0
!
interface link1
 ip router isis zebra
 isis circuit-type level-1
!
interface link2
 ip router isis zebra
 isis circuit-type level-1
!
interface lo
!
!
router isis zebra
 net 49.0001.0000.0000.0002.00
 metric-style wide
 is-type level-1

leaf3 configuration

hostname leaf3
password cisco
enable password cisco
log stdout
!
interface A
!
interface B
!
interface eth0
!
interface link2
 ip router isis zebra
 isis circuit-type level-1
!
interface link4
 ip router isis zebra
 isis circuit-type level-1
!
interface lo
!
!
router isis zebra
 net 49.0001.0000.0000.0003.00
 metric-style wide
 is-type level-1

Link creation

In this sample, all nodes run on the same host Liunx machine. In order to connect containers, ip netns is used to create virtual links. This is a sample script to create all links.

#!/bin/bash

# Create a link between two nodes
# ARGS: nodeA, nodeB, link_id
create_link() {
    local PIDA=$1
    local PIDB=$2
    local PREFIX="10.32."
    PREFIX=${PREFIX}$3
    PREFIX=${PREFIX}"."
    local IPA=${PREFIX}"1/24"
    local IPB=${PREFIX}"2/24"
    local VETH="link"$3

    echo $PIDA $PIDB $PREFIX $IPA $IPB

    ip link add A type veth peer name B

    # Put an edge of the link to containers network name spaces
    ip link set A netns $PIDA
    ip netns exec $PIDA ip link set dev A name $VETH
    ip netns exec $PIDA ip addr add $IPA dev $VETH
    ip netns exec $PIDA ip link set $VETH up

    ip link set B netns $PIDB
    ip netns exec $PIDB ip link set dev B name $VETH
    ip netns exec $PIDB ip addr add $IPB dev $VETH
    ip netns exec $PIDB ip link set $VETH up
}


# Create a symbolic link to a contrainer nw name spaces
link_ns() {
    local PIDA=$1
    if [ ! -e /var/run/netns/$PIDA ]; then
        ln -s /proc/$PIDA/ns/net /var/run/netns/$PIDA
    fi
}

# Define nodes
nodes=('leaf1' 'leaf2' 'leaf3' 'host1' 'host2')

mkdir -p /var/run/netns
i=0
for node in ${nodes[@]}; do
    # Get the process id of each container
    PID1=`docker.io inspect -f '{{.State.Pid}}' $node`

    # Create a sybolic links to connect containers and netns
    link_ns $PID1 
done

# Define links
# nodeA
# nodeB     => nodeA---link_id----nodeB
# link_id
max_link=4
node_A=(leaf1 leaf2 leaf1 leaf3)
node_B=(leaf2 leaf3 host1 host2)
linkid=(1     2     3     4    )

for (( i=0; i<$max_link; i++ )); do
    echo $i
    # Get PID of each container
    PID1=`docker.io inspect -f '{{.State.Pid}}' ${node_A[$i]}`
    PID2=`docker.io inspect -f '{{.State.Pid}}' ${node_B[$i]}`
    LINK=${linkid[$i]}
    create_link $PID1 $PID2 $LINK
done
Docker Pull Command
Owner
tokatsu