Do you want to use a BGP router? You don't have to spend money to buy it. In this tutorial, you use CentOS as one (1)
Before we enter the details, some background knowledge about BGP is necessary. Border Gateway Protocol (BGP) is the actual standard of the Inter-Domain Routing Protocol of the Internet. In BGP terms, the global Internet is composed of thousands of associated Autonomous Systems (AS), each of which represents a network management domain provided by each specific operator. It is said that the former US president George. both have their own AS numbers ).
In order to make its network accessible on a global scale, each AS needs to know how to reach other AS in the Internet. At this time, BGP is required to assume this role. BGP is a language for AS to exchange routing information with adjacent. These routing information is usually called a BGP line or a BGP prefix. Including the AS number (ASN; a globally unique number) and related IP address blocks. Once all BGP lines are learned and recorded by the local BGP Route table, each AS will know how to reach any public IP address on the Internet.
The routing capability between different domains (AS) is the main reason why BGP is called the external Gateway Protocol (EGP) or the Inter-Domain protocol. For example, some routing protocols, such as OSPF, IS-IS, RIP, and OSPF, are both internal gateway protocols (IGPs) or intra-domain routing protocols used to process routes in one domain.
Test Plan
In this tutorial, let's use the following topology.
Assume that carrier A wants to establish a bgp peer-to-peer exchange route with carrier B. The details of their AS numbers and IP address space are AS follows:
-
Carrier: ASN (100), IP address space (100.100.0.0/22), IP address allocated to the BGP router eth1 NIC (100.100.1.1)
-
Carrier B: ASN (200), IP address space (200.200.0.0/22), IP address allocated to the BGP router eth1 NIC (200.200.1.1)
Vroa A and vrob B use the 100.100.0.0/30 subnet to connect to each other. Theoretically, any subnet is reachable and connectable from the operator. In real scenarios, we recommend that you use A public IP address space with A 30-bit mask to connect carrier A and carrier 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 CentOS7, you need to apply a policy to set SELinux. Otherwise, SElinux will prevent the Zebra daemon from writing to its configuration directory. If you are using CentOS6, skip this step.
- # setsebool -P zebra_write_config 1
The Quagga software kit contains several daemon processes that can work together. For BGP routing, we will focus on establishing the following two daemon processes.
- Zebra: A core daemon is used for Kernel interfaces and Static Routing.
- BGPd: A bgp daemon.
Configuration Logging
After Quagga is installed, configure Zebra to manage the network interfaces of the BGP router. We start 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:
- # service zebra start
- # chkconfig zebra on
In CentOS7:
- # systemctl start zebra
- # systemctl enable zebra
Quagga provides a command line tool unique to vtysh. You can enter commands that are compatible with and supported by vro vendors (such as Cisco and Juniper. We will use 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 this host name, which indicates that you are in 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
Permanently Save the Zebra Configuration:
- Router-A# write
Perform the same steps on vrob B.
Configure peer IP addresses
Next, we will configure the peer IP address on the available interface.
- 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 # display 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, do not forget to save the configuration.
- Router-A# write
Similarly, repeat the configuration in vrob B.
Before proceeding to the next step, make sure that the IP addresses of each other 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 peer and prefix settings.