How-To: Setting up BGP on Vyatta — page 3 — Setting BGP
We have set up our network, now let’s get BGP rolling.
3. Setting BGP
As told earlier on, vyatta-bgp1 will advertise AS 1 with network 1.1.1.0/24 to its neighbor vyatta-bgp2 handling AS 2
and
vyatta-bgp2 will advertise AS 2 with network 2.2.2.0/24 to its neighbor vyatta-bgp1 handling AS 1
They will use a common password for this communication, which is BGPtutorial.
The syntax used in configuration mode is the following:
# set protocols bgp <my AS> neighbor <peer IP address> remote-as <peer AS>
# set protocols bgp <my AS> network <advertise network1>
# set protocols bgp <my AS> network <advertise network2>
....
# set protocols bgp <my AS> neighbor <peer IP address> password <bgp password>
Which on each host will give:
3.1. vyatta-bgp1
[edit]
vyatta@vyatta-bgp1# set protocols bgp 1 neighbor 172.16.163.2 remote-as 2
[edit]
vyatta@vyatta-bgp1# set protocols bgp 1 network 1.1.1.0/24
[edit]
vyatta@vyatta-bgp1# set protocols bgp 1 neighbor 172.16.163.2 password BGPtutorial
[edit]
vyatta@vyatta-bgp1# commit
[edit]
vyatta@vyatta-bgp1# save
Saving configuration to '/opt/vyatta/etc/config/config.boot'...
Done
At this stage, within a root shell on vyatta-bgp1, you should get the following result:
vyatta-bgp1:~# show ip bgp
BGP table version is 0, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 0.0.0.0 1 32768 i
Total number of prefixes 1
While vyatta-bgp2, which is not yet configured will display:
vyatta-bgp2:~# show ip bgp
No BGP process is configured
and the route tables will not yet be modified.
3.2. vyatta-bgp2
Similarly on vyatta-bgp2
[edit]
vyatta@vyatta-bgp2# set protocols bgp 2 neighbor 172.16.163.1 remote-as 1
[edit]
vyatta@vyatta-bgp2# set protocols bgp 2 network 2.2.2.0/24
[edit]
vyatta@vyatta-bgp2# set protocols bgp 2 neighbor 172.16.163.1 password BGPtutorial
[edit]
vyatta@vyatta-bgp2# commit
[edit]
vyatta@vyatta-bgp2# save
Saving configuration to '/opt/vyatta/etc/config/config.boot'...
Done
3.3. Confirming the settings
From there, everything should be configured, vyatta-bgp1 will show:
vyatta@vyatta-bgp1:~$ show ip bgp
BGP table version is 0, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 0.0.0.0 1 32768 i
*> 2.2.2.0/24 172.16.163.2 1 0 2 i
Total number of prefixes 2
vyatta@vyatta-bgp1:~$ show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
I - ISIS, B - BGP, > - selected route, * - FIB route
S>* 0.0.0.0/0 [1/0] via 192.168.2.1, eth0
C>* 1.1.1.0/24 is directly connected, eth2
B>* 2.2.2.0/24 [20/1] via 172.16.163.2, eth1, 00:03:15
C>* 127.0.0.0/8 is directly connected, lo
C>* 172.16.163.0/24 is directly connected, eth1
C>* 192.168.2.0/24 is directly connected, eth0
vyatta@vyatta-bgp1:~$ /sbin/route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 eth0
1.1.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
2.2.2.0 172.16.163.2 255.255.255.0 UG 1 0 0 eth1
172.16.163.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
vyatta@vyatta-bgp1:~$
and on the other side vyatta-bgp2 will show:
vyatta@vyatta-bgp2:~$ show ip bgp
BGP table version is 0, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 172.16.163.1 1 0 1 i
*> 2.2.2.0/24 0.0.0.0 1 32768 i
Total number of prefixes 2
vyatta@vyatta-bgp2:~$ show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
I - ISIS, B - BGP, > - selected route, * - FIB route
S>* 0.0.0.0/0 [1/0] via 192.168.2.1, eth0
B>* 1.1.1.0/24 [20/1] via 172.16.163.1, eth1, 00:04:02
C>* 2.2.2.0/24 is directly connected, eth2
C>* 127.0.0.0/8 is directly connected, lo
C>* 172.16.163.0/24 is directly connected, eth1
C>* 192.168.2.0/24 is directly connected, eth0
vyatta@vyatta-bgp2:~$ /sbin/route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 eth0
1.1.1.0 172.16.163.1 255.255.255.0 UG 1 0 0 eth1
2.2.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
172.16.163.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
vyatta@vyatta-bgp2:~$
Mind the more verbose output given by show ip route compare to route. There you can see that there is one static route (the one we created with set system gateway-address 192.168.2.1), one BGP route and 4 connected routes (the ones for each interfaces: eth{0,1,2} and lo).