BGP basic experiment

Experimental requirements

insert image description here

Experimental procedure

1. IP Planning

Because there is no IP allocation plan in this experiment, we allocate and divide IP by ourselves, as shown in the figure.
insert image description here

2. Configure the IGP protocol

The entire intranet is reachable by configuring the IGP protocol, and the ospf protocol is used in the AS2 area
on the AR2

[r2]ospf 1 router-id 2.2.2.2
[r2]area 0
[r2-ospf-1-area-0.0.0.0] network 2.2.2.0 0.0.0.255 
[r2-ospf-1-area-0.0.0.0] network 23.1.1.0 0.0.0.255 
[r2-ospf-1-area-0.0.0.0] network 192.168.3.0 0.0.0.255 

on AR3

[r3]ospf 1 router-id 3.3.3.3
[r3]area 0
[r3-ospf-1-area-0.0.0.0] network 3.3.3.0 0.0.0.255 
[r3-ospf-1-area-0.0.0.0] network 23.1.1.0 0.0.0.255 
[r3-ospf-1-area-0.0.0.0] network 34.1.1.0 0.0.0.255 
[r3-ospf-1-area-0.0.0.0] network 192.168.2.0 0.0.0.255 

on AR4

[r4]ospf 1 router-id 4.4.4.4
[r4]area 0
[r4-ospf-1-area-0.0.0.0] network 4.4.4.0 0.0.0.255 
[r4-ospf-1-area-0.0.0.0] network 34.1.1.0 0.0.0.255 
[r4-ospf-1-area-0.0.0.0] network 192.168.4.0 0.0.0.255 

Test whether the entire network is reachable on the AR2
insert image description here

3. Configure EGP protocol

Since AR1 and AR2 are two directly connected AS areas, establish a directly connected EBGP neighbor.
Take AR1 as an example

[r1]bgp 1  启动时需要定义其所在的AS号 没有多进程的概念

[r1-bgp]router-id 1.1.1.1     建议配置RID,与OSPF的RID配置规则一致

[r1-bgp]peer 12.1.1.2 as-number 2 建立邻居关系,定义对端设备的ip地址,及所在AS编号

AR2-4 are in the same area of ​​AS2, so IBGP neighbors need to be configured.
Take AR2 as an example

[r2]bgp 2 

 [r2-bgp]peer 3.3.3.3 as-number 2 

 [r2-bgp]peer 3.3.3.3 connect-interface LoopBack 0

切记:一旦使用环回地址做为建邻地址,同时需要修改源ip地址,为本地的环回地址;

Because there are multiple links between AR4 and AR5 neighbors, when establishing EBGP neighbors, you need to select loopback to establish
neighbors.
Here the method of handwritten static routing is used to achieve mutual communication

[r4]ip route-static 5.5.5.0 255.255.255.0 45.1.1.2
[r4]ip route-static 5.5.5.0 255.255.255.0 54.1.1.2

[r5]ip route-static 5.5.5.0 255.255.255.0 45.1.1.1
[r5]ip route-static 5.5.5.0 255.255.255.0 54.1.1.1
[r5]bgp 3 

[r5-bgp]peer 4.4.4.4 as-number 2 

[r5-bgp]peer 4.4.4.4 connect-interface LoopBack 0

Because between EBGP neighbors, the default TTL value is 1, and IBGP is 255; theoretically, there is no third router between EBGP neighbors, so if the TTL value is set to 1, it can only establish neighbors with directly connected physical interfaces; if loopback is used To build a neighbor, you must modify the TTL value

[r4-bgp]peer 5.5.5.5 ebgp-max-hop 2 修改EBGP邻居间的TTL值

[r5-bgp]peer 4.4.4.4 ebgp-max-hop 2 修改EBGP邻居间的TTL值

After the configuration, you can view the neighbor relationship of bgp with the following command

display bgp peer			

Take AR3 as an example
insert image description here

4. BGP route announcement

BGP route advertisement is used to let the routes between AS areas learn from each other
In AS1

[r1]bgp 1
[r1-bgp]network 12.1.1.0 24
[r1-bgp]network 192.168.1.0 24 

Take AR2 as an example in AS2

[r2]bgp 2
[r2-bgp]network 12.1.1.0 24
[r2-bgp]network 23.1.1.0 24
[r2-bgp]network 192.168.2.0 24 

in AS3

[r5]bgp 3
[r5-bgp]network 45.1.1.0 24
[r5-bgp]network 54.1.1.0 24
[r5-bgp]network 192.168.5.0 24 

Note: When advertising, the content of the announced entry must be exactly the same as that in the local routing table;
in BGP, loopback is generally used to establish neighbors, so generally, the loopback address is not announced during route announcement.

5. Solve routing problems

After announcing the route, check the routing table and find that AR4 cannot learn the route of AR2. This is because of the IBGP split horizon.
Therefore, AR2 needs to establish a separate IBGP neighbor for AR4.

[r2]bgp 2
[r2-bgp]peer 4.4.4.4 as-number 2 
[r2-bgp]peer 4.4.4.4 connect-interface LoopBack 0

After the neighbors are established, it is found that the routes learned by AR5 on AR3 are not optimal. Because of AS-BY-AS, when a route information is transmitted by IBGP neighbors, its attributes are not numbered by default; eventually, the next hop is often unreachable;
insert image description here

Therefore, the routing entry is required to be passed to the next neighbor, and the next hop is modified to the local address;

[r2]bgp 2 
[r2-bgp]peer 3.3.3.3 next-hop-local
[r2-bgp]peer 4.4.4.4 next-hop-local

[r4]bgp 2 
[r4-bgp]peer 2.2.2.2 next-hop-local
[r4-bgp]peer 3.3.3.3 next-hop-local

After modification, check the routing table and find that the route of AR5 has been optimized.
insert image description here

6. User Testing

Make all computers automatically obtain ip by using DHCP service
Take AR1 as an example

[r1]dhcp enable
[r1]ip pool a
[r1-ip-pool-a]network 192.168.1.0 mask 24
[r1-ip-pool-a]gateway-list 192.168.1.1 
[r1-ip-pool-a]dns-list 114.114.114.114 8.8.8.8 
[r1-ip-pool-a]q

[r1]int g0/0/1
[r1-GigabitEthernet0/0/1]dhcp select global

Pass the AR1 computer test
insert image description here

Guess you like

Origin blog.csdn.net/m0_46467017/article/details/122629343