Configuring OSPF in Quagga

I will give a simple example of setting up OSPF in Quagga, for the test I will use Hyper-V with a virtual switch and virtual machines running Ubuntu Server 18.04.

If the server is used as a router or for NAT, then we will allow traffic to go between network interfaces, enable proxy_arp if necessary and disable rp_filter:

nano /etc/sysctl.conf
net.ipv4.conf.all.forwarding=1
net.ipv4.conf.all.proxy_arp=1
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0
sysctl -p

FIRST SERVER

I created two network interfaces on both test servers, the first external one receives an IP address via DHCP with the Internet, the second one is internal and connected to a virtual local switch. Let’s manually assign an IP address to the local network interface:

ip a
cd /etc/netplan/
ls
nano 50-cloud-init.yaml
network:
    ethernets:
      eth0:
        dhcp4: true
      eth1:
       addresses:
        - 192.168.55.1/24
    version: 2
netplan try

Let’s see the current routes:

ip route

We install Quagga on all machines, I left the installation instructions at the end of the article.

Example configuration /etc/quagga/zebra.conf on the first machine:

hostname TEST1
password ixnfo.com
enable password ixnfo.com
log file /var/log/quagga/zebra.log
!
line vty
!

Example /etc/quagga/ospfd.conf on the first machine:

log file /var/log/quagga/ospfd.log
router ospf
!router identifier, must be unique for each router (obtained via DHCP on the external interface)
 ospf router-id 192.168.24.73
 log-adjacency-changes
!Advertise routes lifted automatically
 redistribute kernel
!Advertise routes to connected networks
 redistribute connected
!Advertise static routes
 redistribute static
!Network and zone number with neighboring routers
 network 192.168.24.0/24 area 1
!
!the network to be announced, for example 192.168.55.0/24
access-list 20 permit 192.168.55.0 0.0.0.255
access-list 20 deny any
!
line vty
!

SECOND SERVER

network:
    ethernets:
      eth0:
        dhcp4: true
      eth1:
       addresses:
        - 192.168.55.2/24
    version: 2

Example /etc/quagga/zebra.conf on a second machine:

hostname TEST2
password ixnfo.com
enable password ixnfo.com
log file /var/log/quagga/zebra.log
!
line vty
!

Example /etc/quagga/ospfd.conf on a second machine:

log file /var/log/quagga/ospfd.log
router ospf
 ospf router-id 192.168.24.78
 log-adjacency-changes
 redistribute kernel
 redistribute connected
 redistribute static
 network 192.168.24.0/24 area 1
!
access-list 20 permit 192.168.55.0 0.0.0.255
access-list 20 deny any
!
line vty
!

Specify the correct owner and group for the generated configuration files, and also run zebra and ospfd:

sudo chown quagga:quagga /etc/quagga/*.conf
mkdir /var/log/quagga/
chown quagga:quagga /var/log/quagga/
sudo service zebra status
sudo service zebra restart
sudo service ospfd status
sudo service ospfd restart

Let’s check:

tcpdump -nvi any proto ospf

I got it displayed:

tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
07:31:26.898583 IP (tos 0xc0, ttl 1, id 4243, offset 0, flags [none], proto OSPF (89), length 68)
    192.168.24.78 > 224.0.0.5: OSPFv2, Hello, length 48
        Router-ID 192.168.24.78, Area 0.0.0.1, Authentication Type: none (0)
        Options [External]
          Hello Timer 10s, Dead Timer 40s, Mask 255.255.255.0, Priority 1
          Designated Router 192.168.24.73, Backup Designated Router 192.168.24.78
          Neighbor List:
            192.168.24.73

For the test on the second server, let’s add a route and make sure that the route is automatically added on the first server:

ip route add 192.168.5.3 dev eth1
ip route
route -n

I will give examples of viewing a list of routes, neighbors and other information:

telnet localhost 2601
show ip route
show ip route connected
show ip route static
show ip route kernel
show ip route ospf
show ip route summary
exit

vtysh
show ip ospf
show ip ospf neighbor
show ip ospf neighbor detail
show ip ospf interface
show ip ospf border-routers
show ip ospf database
show ip access-list
show ip route
show ip route ospf
exit

See also my articles:
How to configure networking with Netplan
Configuring OSPF in BIRD
Installing Quagga on Ubuntu Server 18
Ubuntu IP Masquerading (NAT)
Configuring the Network in Linux

Leave a comment

Leave a Reply

Discover more from IT Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading