Sunday, April 15, 2012

Quagga OSPF Simulation in CentOS 6

Scenario

This article is actually a modified version of a previous article

IP Details

All the Routers in the diagram are actually CentOS Machines.

Router Alpha:
  • eth0: 192.168.10.254/24
  • eth1: 10.0.0.2/30
Router Beta:
  • eth0: 192.168.20.254/24
  • eth1: 10.0.0.1/30
  • eth2: 10.0.0.5/30
Router Gamma:
  • eth0: 192.168.30.254/24
  • eth1: 10.0.0.6/30

Objective

We would be configuring the Linux boxes with dynamic routing protocol OSPF for total connectivity. This would be done with the help of Quagga.

Router Alpha Configuration

root@alpha:~# yum install quagga


We would be configuring the interface parameters. Keep in mind, there are example configuration files stored in /usr/share/doc/quagga/

root@alpha:~# cd /etc/quagga
root@alpha:/etc/quagga# cat zebra.conf.sample > zebra.conf
root@alpha:/etc/quagga# vim zebra.conf 

hostname AplhaRouter
password zebra
enable password zebra
!
! Interface's description.
!
interface lo
description loopback
ip address 127.0.0.1/8
ip forwarding 

interface eth0
description LAN
ip address 192.168.10.254/24
ip forwarding

interface eth1
description to_beta
ip address 10.0.0.2/30
ip forwarding


log file /var/log/quagga/zebra.log


Now to the OSPF Configuration.

root@alpha:/etc/quagga# cat ospf.conf.sample > ospf.conf


root@alpha:/etc/quagga# vim ospfd.conf
### we define the interfaces that take part in OSPF
interface eth0
interface eth1

router ospf
network 10.0.0.0/30 area 0
network 192.168.10.0/24 area 0

log stdout
log file /var/log/quagga/ospfd.log

Now, it's time to start the Quagga daemon. We do this by-


root@alpha:/etc/quagga# /etc/init.d/zebra restart
root@alpha:/etc/quagga# /etc/init.d/ospfd restart
root@alpha:/etc/quagga# chkconfig zebra on
root@alpha:/etc/quagga# chkconfig ospfd on


vtyshprovides a shell that resembles the CISCO IOS shell. It even supports commands from the CISCO IOS.


root@alpha:~#vtysh
Hello, this is Quagga (version 0.99.17).
Copyright 1996-2005 Kunihiro Ishiguro, et al.


AlphaRouter# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
I - ISIS, B - BGP, > - selected route, * - FIB route

C>* 127.0.0.0/8 is directly connected, lo
C>* 10.0.0.2/30 is directly connected, eth0
C>* 192.168.10.0/24 is directly connected, eth1
AlphaRouter# exit


We can issue commands like show ip route or show ip ospf in vtysh to check the available routes and OSPF status. However, since there are no OSPF neighbors yet, the show ip route should show only directly connected devices.

Here is a sample output of quagga log from one of my Quagga Routers.

[root@firefly ~]# tail -f /var/log/quagga/ospfd.log
 
2012/04/15 15:13:53 OSPF: DR-Election[1st]: DR     192.168.1.2
2012/04/15 15:13:53 OSPF: DR-Election[2nd]: Backup 192.168.1.3
2012/04/15 15:13:53 OSPF: DR-Election[2nd]: DR     192.168.1.2
2012/04/15 15:13:53 OSPF: ospfTrapIfStateChange trap sent: 192.168.1.3 now Backup
2012/04/15 15:13:53 OSPF: interface 192.168.1.3 [3] join AllDRouters Multicast group.
2012/04/15 15:13:53 OSPF: DR-Election[1st]: Backup 192.168.1.3
2012/04/15 15:13:53 OSPF: DR-Election[1st]: DR     192.168.1.2
2012/04/15 15:13:53 OSPF: Packet[DD]: Neighbor 10.0.0.1: Initial DBD from Slave, ignoring.
2012/04/15 15:13:53 OSPF: Packet[DD]: Neighbor 10.0.0.1 Negotiation done (Master).
2012/04/15 15:13:53 OSPF: nsm_change_state(10.0.0.1, Loading -> Full): scheduling new router-LSA origination
 



Router Beta Configuration

Time to configure the next Linux box. The configuration is identical except for the network parameters. Here it goes -
root@beta:/etc/quagga# cat zebra.conf
hostname BetaRouter
password zebra
enable password zebra
!
! Interface's description.
!
interface lo
description loopback
ip address 127.0.0.1/8
ip forwarding

interface eth0
description LAN
ip address 192.168.20.254/24
ip forwarding

interface eth1
description to_alpha
ip address 10.0.0.1/30
ip forwarding

interface eth2
description to_gamma
ip address 10.0.0.5/30
ip forwarding


log file /var/log/quagga/zebra.log

root@beta:/etc/quagga# cat ospfd.conf
### we define the interfaces that take part in OSPF
interface eth0
interface eth1
interface eth2

router ospf
network 10.0.0.0/30 area 0
network 10.0.0.4/30 area 0
network 192.168.20.0/24 area 0

log stdout
log file /var/log/quagga/ospfd.log

Time to start the Quagga daemon again.

root@beta:/etc/quagga# /etc/init.d/zebra restart
root@beta:/etc/quagga# /etc/init.d/ospfd restart
root@beta:/etc/quagga# chkconfig zebra on
root@beta:/etc/quagga# chkconfig ospfd on

root@beta:~#vtysh
Hello, this is Quagga (version 0.99.17).
Copyright 1996-2005 Kunihiro Ishiguro, et al.


BetaRouter# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - ISIS, B - BGP, > - selected route, * - FIB route

C>* 127.0.0.0/8 is directly connected, lo
O 10.0.0.1/30 [110/20] is directly connected, eth1
C>* 10.0.0.1/30 is directly connected, eth1
O 10.0.0.5/30 [110/20] is directly connected, eth2
C>* 10.0.0.5/30 is directly connected, eth2
O>* 192.168.10.0/24 [110/40] via 10.0.0.2, eth1,
O 192.168.20.0/24 [110/20] is directly connected, eth0
C>* 192.168.20.0/24 is directly connected, eth0


BetaRouter# exit

As we can see now, the neighbor relationship has been formed and Alpha and beta have already exchanged routing information.
Now try pinging between the Alpha and Beta networks. Should work. Alternatively, also using the good old route command as well to see whether the routes are already being learnt. 

Router Gamma Configuration

The configuration of Gamma is same as the previous Linux boxes.


root@gamma:/etc/quagga# cat zebra.conf
hostname GammaRouter
password zebra
enable password zebra
!
! Interface's description.
!
interface lo
description loopback
ip address 127.0.0.1/8
ip forwarding

interface eth0
description LAN
ip address 192.168.30.254/24
ip forwarding

interface eth1
description to_beta
ip address 10.0.0.6/30
ip forwarding

log file /var/log/quagga/zebra.log


root@gamma:/etc/quagga# cat ospfd.conf
### we define the interfaces that take part in OSPF
interface eth0
interface eth1

router ospf
network 10.0.0.4/30 area 0
network 192.168.30.0/24 area 0

log stdout
log file /var/log/quagga/ospfd.log

Time to start the Quagga daemon again.

root@gamma:/etc/quagga# /etc/init.d/zebra restart
root@gamma:/etc/quagga# /etc/init.d/ospfd restart
root@gamma:/etc/quagga# chkconfig zebra on
root@gamma:/etc/quagga# chkconfig ospfd on

The system is now ready to rumble. Try viewing the routes by route or ip route or show ip route (vtysh). All the routers should be able to ping each other, and each host from any of the LANs should be able to communicate with host of other LAN. Again, traceroute can also be used to check the path that is being taken by a packet.


Hope it helps.


3 comments:

  1. Mr. Sarmed Rahman
    Recently, I used this manual and works fine. Thanks.

    Can I use It for republish for publish it in an University Course blog?

    ReplyDelete
    Replies
    1. Good to hear that you found the document helpful. Sure you can republish it in the University Course blog. Mentioning the source would be nice though.

      Delete
  2. I had 12 Network and want to add BGP with AS numbers 12 on SAME router is it possible to add more than 1 network on server ?

    Recently using Vyatta and it is only using one at a time.

    ReplyDelete