Quagga is an open source routing software suite. In this tutorial, I will focus on how to turn a Linux system into a BGP router or use Quagga to demonstrate how to establish BGP peering with other BGP routers.
Before we get into the details, some background knowledge of BGP is still necessary. The Border Gateway Protocol (BGP) is the actual standard for the Internet's inter-domain routing protocol. In BGP terminology, the global Internet is composed of thousands of associated autonomous systems (AS), where each AS represents a network management domain provided by each specific operator (it is said that former US President George Bush has Own AS number).
In order to make its network routable on a global scale, each AS needs to know how to reach other ASs in the Internet. At this time, BGP is needed to play this role. BGP is a language for an AS to exchange routing information with neighboring ASs. These routing information are usually called BGP lines or BGP prefixes. Including AS number (ASN; globally unique number) and related IP address block. Once all BGP lines are learned and recorded by the local BGP routing table, each AS will know how to reach any public IP on the Internet.
The ability to route between different domains (AS) is the main reason why BGP is called Exterior Gateway Protocol (EGP) or inter-domain protocol. Just like some routing protocols, such as OSPF, IS-IS, RIP, and EIGRP, are interior gateway protocols (IGPs) or intra-domain routing protocols used to process routing within a domain.
Test program
In this tutorial, let's use the following topology.
We assume that operator A wants to establish a BGP to exchange routes with operator B peer-to-peer. The details of their AS number and IP address space are as follows:
Operator A: ASN (100), IP address space (100.100.0.0/22), IP address (100.100.1.1) assigned to the BGP router eth1 network card
Carrier B: ASN (200), IP address space (200.200.0.0/22), IP address (200.200.1.1) assigned to the BGP router eth1 network card
Router A and Router B use the 100.100.0.0/30 subnet to connect to each other. In theory, any subnet is reachable and interconnectable from the operator. In a real scenario, it is recommended to use a public network IP address space with a mask of 30 bits to realize the connectivity between operator A and operator B.
Install Quagga in CentOS
If Quagga has not been installed, we can use yum to install Quagga.
# yum install quagga
If you are using a CentOS7 system, you need to apply the following strategy to set up SELinux. Otherwise, SElinux will prevent the Zebra daemon from writing to its configuration directory. If you are using CentOS6, you can skip this step.
# setsebool -P zebra_write_config 1
The Quagga software suite contains several daemons that can work together. Regarding BGP routing, we will focus on establishing the following two daemons.
Zebra: A core daemon for kernel interface and static routing.
BGPd: A BGP daemon.
Configure logging
After Quagga is installed, the next step is to configure Zebra to manage the network interface of the BGP router. We started the first step by creating a Zebra configuration file and enabling logging.
# cp /usr/share/doc/quagga-XXXXX/zebra.conf.sample /etc/quagga/zebra.conf
In CentOS6 system:
# service zebra start
# chkconfig zebra on
In CentOS7 system:
# systemctl start zebra
# systemctl enable zebra
Quagga provides a unique command line tool called vtysh. You can enter commands compatible and supported by router vendors (such as Cisco and Juniper). We will use the vtysh shell to configure BGP routing in the rest of the tutorial.
Start the vtysh shell command and enter:
# vtysh
The prompt will be changed to the hostname, which indicates that you are in the vtysh shell.
Router-A#
Now we will use the following command to configure the log file for Zebra:
Router-A# configure terminal
Router-A(config)# log file /var/log/quagga/quagga.log
Router-A(config)# exit
Save Zebra configuration permanently:
Router-A# write
Follow the same steps on Router B.
Configure peer IP address
In the next step, we will configure peer IP addresses on available interfaces.
Router-A# show interface #Display interface information
Interface eth0 is up, line protocol detection is disabled
.....
Interface eth1 is up, line protocol detection is disabled
.....
Configure the parameters of the eth0 interface:
site-A-RTR# configure terminal
site-A-RTR(config)# interface eth0
site-A-RTR(config-if)# ip address 100.100.0.1/30
site-A-RTR(config-if)# description "to Router-B"
site-A-RTR(config-if)# no shutdown
site-A-RTR(config-if)# exit
Continue to configure the parameters of the eth1 interface:
site-A-RTR(config)# interface eth1
site-A-RTR(config-if)# ip address 100.100.1.1/24
site-A-RTR(config-if)# description "test ip from provider A network"
site-A-RTR(config-if)# no shutdown
site-A-RTR(config-if)# exit
Now confirm the configuration:
Router-A# show interface
Interface eth0 is up, line protocol detection is disabled
Description: "to Router-B"
inet 100.100.0.1/30 broadcast 100.100.0.3
Interface eth1 is up, line protocol detection is disabled
Description: "test ip from provider A network"
inet 100.100.1.1/24 broadcast 100.100.1.255
Router-A# show interface description #Show interface description
Interface Status Protocol Description
eth0 up unknown "to Router-B"
eth1 up unknown "test ip from provider A network"
If everything looks normal, don't forget to save the configuration.
Router-A# write
Similarly, repeat the configuration on Router B.
Before we continue to the next step, confirm that each other's IP can be pinged.
Router-A# ping 100.100.0.2
PING 100.100.0.2 (100.100.0.2) 56(84) bytes of data.
64 bytes from 100.100.0.2: icmp_seq=1 ttl=64 time=0.616 ms
Next, we will continue to configure BGP peering and prefix settings.