Introduction | Quagga is an open source routing software suite that turns Linux into a router that supports major routing protocols such as RIP, OSPF, BGP and IS-IS. It has full support for IPv4 and IPv6 and supports route/prefix filtering. Quagga can be a lifesaver in case your production router ever goes down and you don't have a spare but are waiting for a replacement. With proper configuration, Quagga can even function as a production router. |
In this tutorial, we will connect two branch office networks assuming there is a dedicated line connection between them (for example, 192.168.1.0/24 and 172.17.1.0/24).
Our CentOS is on both ends of said private link. The two host names are set to "site-A-RTR" and "site-B-RTR' respectively. The following are the details of the IP addresses.
•Site-A: 192.168.1.0/24
•Site-B: 172.16.1.0/24
•Peer-to-peer network between two Linux routers: 10.10.10.0/30
Quagga includes several daemons that work together. In this tutorial, we will focus on setting up the following daemons.
1.Zebra: Core daemon, responsible for kernel interface and static routing.
2.Ospfd: IPv4 OSPF daemon.
We use yum to install Quagga.
# yum install quagga
In CentOS7, SELinux will prevent quagga from writing configuration files to /usr/sbin/zebra by default. This SELinux policy will interfere with the installation process we will introduce next, so we need to disable this policy. For this, either turning off SELinux (not recommended here) or enabling "zebrawriteconfig" as follows will work. If you are using CentOS 6 please skip this step.
# setsebool -P zebra_write_config 1
If this modification is not made, we will see the following error when we try to save the configuration in the Quagga command line.
Can't open configuration file /etc/quagga/zebra.conf.OS1Uu5.
After installing Quagga, we need to configure the necessary peer IP addresses and update OSPF settings. Quagga comes with a command line called vtysh. The Quagga commands used in vtysh are similar to those of major router manufacturers such as Cisco and Juniper.
Step 1: Configure ZebraWe first create the Zebra configuration file and enable the Zebra daemon.
# cp /usr/share/doc/quagga-XXXXX/zebra.conf.sample /etc/quagga/zebra.conf # service zebra start # chkconfig zebra on
Start vtysh command line:
#vtysh
First, we configure the log file for Zebra. Enter the following command to enter the global configuration mode of vtysh:
site-A-RTR# configure terminal
Specify the log file location, then exit the mode:
site-A-RTR(config)# log file /var/log/quagga/quagga.log site-A-RTR(config)# exit
Save configuration permanently:
site-A-RTR# write
Next, we need to identify the available interfaces and configure their IP addresses as needed.
site-A-RTR# show interface
Interface eth0 is up, line protocol detection is disabled . . . . . Interface eth1 is up, line protocol detection is disabled . . . . .
Configure eth0 parameters:
site-A-RTR# configure terminal site-A-RTR(config)# interface eth0 site-A-RTR(config-if)# ip address 10.10.10.1/30 site-A-RTR(config-if)# description to-site-B site-A-RTR(config-if)# no shutdown
Continue to configure eth1 parameters:
site-A-RTR(config)# interface eth1 site-A-RTR(config-if)# ip address 192.168.1.1/24 site-A-RTR(config-if)# description to-site-A-LAN site-A-RTR(config-if)# no shutdown
Now verify the configuration:
site-A-RTR(config-if)# do show interface
Interface eth0 is up, line protocol detection is disabled . . . . . inet 10.10.10.1/30 broadcast 10.10.10.3 . . . . . Interface eth1 is up, line protocol detection is disabled . . . . . inet 192.168.1.1/24 broadcast 192.168.1.255 . . . . .
site-A-RTR(config-if)# do show interface description
Interface Status Protocol Description eth0 up unknown to-site-B eth1 up unknown to-site-A-LAN
Save configuration permanently:
site-A-RTR(config-if)# do write
Repeat the above steps to configure the IP address on site-B.
If all goes well, you should be able to ping the peer IP address 10.10.10.2 on site-B from site-A's server.
Note: Once the Zebra daemon is started, any changes in the vtysh command line will take effect immediately. Therefore there is no need to restart the Zebra daemon after changing the configuration.
Step 2: Configure OSPFWe first create the OSPF configuration file and start the OSPF daemon:
# cp /usr/share/doc/quagga-XXXXX/ospfd.conf.sample /etc/quagga/ospfd.conf # service ospfd start # chkconfig ospfd on
Now start the vtysh command line to continue OSPF configuration:
# vtysh
Enter routing configuration mode:
site-A-RTR# configure terminal site-A-RTR(config)# router ospf
Optional configuration routing id:
site-A-RTR(config-router)# router-id 10.10.10.1
Network added in OSPF:
site-A-RTR(config-router)# network 10.10.10.0/30 area 0 site-A-RTR(config-router)# network 192.168.1.0/24 area 0
Save configuration permanently:
site-A-RTR(config-router)# do write
Repeat OSPF configuration similar to above on site-B:
site-B-RTR(config-router)# network 10.10.10.0/30 area 0 site-B-RTR(config-router)# network 172.16.1.0/24 area 0 site-B-RTR(config-router)# do write
The OSPF neighbor should now be started. As long as ospfd is running, any OSPF-related configuration changes made through vtysh will take effect immediately without restarting ospfd.
verify1. Pass ping test
First you should be able to ping the same LAN subnet as site-B from site-A. Make sure your firewall is not blocking ping traffic.
[root@site-A-RTR ~]# ping 172.16.1.1 -c 2
2. Check routing table
The necessary routes should appear in both the kernel and Quagga reason tables.
[root@site-A-RTR ~]# ip route
10.10.10.0/30 dev eth0 proto kernel scope link src 10.10.10.1 172.16.1.0/30 via 10.10.10.2 dev eth0 proto zebra metric 20 192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.1
[root@site-A-RTR ~]# vtysh site-A-RTR# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - ISIS, B - BGP, > - selected route, * - FIB route O>* 10.10.10.0/30 [110/10] is directly connected, eth0, 00:14:29 C>* 10.10.10.0/30 is directly connected, eth0 C>* 127.0.0.0/8 is directly connected, lo O>* 172.16.1.0/30 [110/20] via 10.10.10.2, eth0, 00:14:14 C>* 192.168.1.0/24 is directly connected, eth1
3. Verify OSPF neighbors and routes
In the vtysh command line, you can check whether the necessary neighbors are online and whether appropriate routes have been learned.
[root@site-A-RTR ~]# vtysh site-A-RTR# show ip ospf neighbor
In this tutorial, we will focus on configuring basic OSPF using Quagga. In general, Quagga allows us to easily configure dynamic routing protocols such as OSPF, RIP or BGP on an ordinary Linux machine. Quagga-enabled machines can communicate and exchange routing information with other routers on your network. Because it supports the major open standard routing protocols, it may be the first choice in many situations. What's more, Quagga's command line interface is nearly identical to that of major router vendors such as Cisco and Juniper, which makes deploying and maintaining Quagga machines very easy.
The above is the detailed content of Turn your CentOS into an OSPF router. For more information, please follow other related articles on the PHP Chinese website!