Network Requirements
- Set up EBGP neighbors between Device1 and Device2, and set up IBGP neighbors between Device2 and Device3.
- Device1 learns the interface direct route 200.0.0.0/24 of Device3, and Device3 learns the interface direct route 100.0.0.0/24 of Device1.
Network Topology
Figure 12–1 Networking for configuring basic BGP functions
Configuration Steps
Step 1: Configure the VLAN and join the interface to the corresponding VLAN. (Omitted)
Step 2: Configure the IP addresses of the interfaces. (Omitted)
Step 3: Configure OSPF so that loopback routes are reachable between devices.
#Configure Device2.
Device2#configure terminal
Device2(config)#router ospf 100
Device2(config-ospf)#network 10.0.0.1 0.0.0.0 area 0
Device2(config-ospf)#network 2.0.0.0 0.0.0.255 area 0
Device2(config-ospf)#exit
|
#Configure Device3.
Device3#configure terminal
Device3(config)#router ospf 100
Device3(config-ospf)#network 20.0.0.1 0.0.0.0 area 0
Device3(config-ospf)#network 2.0.0.0 0.0.0.255 area 0
Device3(config-ospf)#exit
|
#Query the routing table of Device2.
Device2#show ip route ospf
Codes: C - Connected, L - Local, S - static, R - RIP, B - BGP, i-ISIS
U - Per-user Static route
O - OSPF, OE-OSPF External, M - Management, E - IRMP, EX - IRMP external
O 20.0.0.1/32 [110/2] via 2.0.0.2, 00:27:09, vlan3
#Query the routing table of Device3.
Device3#show ip route ospf
Codes: C - Connected, L - Local, S - static, R - RIP, B - BGP, i-ISIS
U - Per-user Static route
O - OSPF, OE-OSPF External, M - Management, E - IRMP, EX - IRMP external
O 10.0.0.1/32 [110/2] via 2.0.0.1, 00:28:13, vlan2
According to the queried information, Device2 and Device3 have learnt the routes of the peer loopback interfaces by running OSPF, preparing for setting up IBGP neighbors on the loopback interfaces of Device2 and Device3.
Step 4: Configure BGP.
#Configure Device1.
Set up a direct-connect EBGP peer relation with Device2. Introduce 100.0.0.0/24 to BGP in network mode.
Device1#configure terminal
Device1(config)#router bgp 200
Device1(config-bgp)#neighbor 1.0.0.2 remote-as 100
Device1(config-bgp)#network 100.0.0.0 255.255.255.0
Device1(config-bgp)#exit
|
#Configure Device2.
Set up a non-direct-connect IBGP peer relation with Device3 through Loopback0, and set the next hop of the advertised route to the local device, and set up a direct-connect EBGP peer relation with Device1.
Device2(config)#router bgp 100
Device2(config-bgp)#neighbor 20.0.0.1 remote-as 100
Device2(config-bgp)#neighbor 20.0.0.1 update-source loopback0
Device2(config-bgp)#neighbor 1.0.0.1 remote-as 200
Device2(config-bgp)#neighbor 20.0.0.1 next-hop-self
Device2(config-bgp)#exit
|
#Configure Device3.
Set up a non-direct-connect IBGP peer relation with Device2 through Loopback0. Introduce 200.0.0.0/24 to BGP in network mode.
Device3(config)#router bgp 100
Device3(config-bgp)#neighbor 10.0.0.1 remote-as 100
Device3(config-bgp)#neighbor 10.0.0.1 update-source loopback0
Device3(config-bgp)#network 200.0.0.0 255.255.255.0
Device3(config-bgp)#exit
|
-
To prevent route flapping, IBGP neighbors are set up through the loopback interfaces, and OSPF need to synchronize the routing information of loopback interfaces between IBGP neighbors.
Step 5: Check the result.
#On Device2, check the BGP neighbor status.
Device2#show ip bgp summary
BGP router identifier 10.0.0.1, local AS number 100 BGP table version is 2
2 BGP AS-PATH entries 0 BGP community entries
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
1.0.0.1 4 200 3 3 1 0 0 00:00:29 1
20.0.0.1 4 100 5 4 2 0 0 00:02:13 1
According to the numbers (Number of route prefixes received from neighbors) that are displayed in the State/PfxRcd column, BGP neighbors have been successfully set up between Device 2 and Device 1 and Device2 and Device 3.
#Query the routing table of Device1.
Device1#show ip route bgp
Codes: C - Connected, L - Local, S - static, R - RIP, B - BGP, i-ISIS
U - Per-user Static route
O - OSPF, OE-OSPF External, M - Management, E - IRMP, EX - IRMP external
B 200.0.0.0/24 [20/0] via 1.0.0.2, 00:15:52, vlan3
#Query the routing table of Device2.
Device2#show ip route bgp
Codes: C - Connected, L - Local, S - static, R - RIP, B BGP, i-ISIS
U Per-user Static route
O - OSPF, OE-OSPF External, M - Management, E - IRMP, EX IRMP external
B 100.0.0.0/24 [20/0] via 1.0.0.1, 00:14:11, vlan2
B 200.0.0.0/24 [200/0] via 20.0.0.1, 00:17:12, vlan3
#Query the routing table of Device3.
Device3#show ip route bgp
Codes: C - Connected, L - Local, S - static, R - RIP, B BGP, i-ISIS
U Per-user Static route
O - OSPF, OE-OSPF External, M - Management, E - IRMP, EX IRMP external
B 100.0.0.0/24 [200/0] via 10.0.0.1, 00:14:50, vlan2
Device1 has learnt the interface direct route 200.0.0.0/24 of Device3, and Device3 has learnt the interface direct route 100.0.0.0/24 of Device1.