BGP双平面实验---bgp的选路

实验明细

  • 实验拓扑
  • 实验要求
  • 实验内容

实验拓扑

BGP双平面实验---bgp的选路_第1张图片

实验要求

1.合理的IP地址
2.AS 123 内部使用OSPF协议,AS1 AS 2内部建立全互联的IBGP邻居,AS之间建立全部的EBGP邻居
3.PC 1 3 5 属于电信的路由,通信时必须使用电信AS 1;PC 2 4 6属于联通的路由,通信时必须使用联通的AS 2
4.若R1-R9之间的链路断开,电信的路由依然通过电信AS 1通信

实验内容

实验的IP规划如上图所示
接着 就开始给每台路由器配置ip地址
R1

#                                         
interface GigabitEthernet0/0/0            
 ip address 10.0.8.1 255.255.248.0        
#                                         
interface GigabitEthernet0/0/1            
 ip address 10.0.32.1 255.255.248.0       
#                                         
interface GigabitEthernet0/0/2            
 ip address 10.0.40.1 255.255.248.0       
#                                         
interface GigabitEthernet4/0/0            
 ip address 10.0.104.1 255.255.248.0      
#        

R2

#                                         
interface GigabitEthernet0/0/0            
 ip address 10.0.40.2 255.255.248.0       
#                                         
interface GigabitEthernet0/0/1            
 ip address 10.0.80.1 255.255.248.0       
#                                         
interface GigabitEthernet0/0/2            
 ip address 10.0.48.1 255.255.248.0       
#                                         
interface NULL0                           
#                                         
interface LoopBack0                       
 ip address 2.2.2.2 255.255.255.0                     
# 

R3

#                                         
interface GigabitEthernet0/0/0            
 ip address 10.0.32.2 255.255.248.0       
#                                         
interface GigabitEthernet0/0/1            
 ip address 10.0.24.1 255.255.248.0       
#                                         
interface GigabitEthernet0/0/2            
 ip address 10.0.48.1 255.255.248.0       
#                                         
interface NULL0                           
#                                         
interface LoopBack0                       
 ip address 3.3.3.3 255.255.255.0                     
# 

R4

#                                         
interface GigabitEthernet0/0/0            
 ip address 10.0.80.2 255.255.248.0       
#                                         
interface GigabitEthernet0/0/1            
 ip address 10.0.88.1 255.255.248.0       
#                                         
interface GigabitEthernet0/0/2            
 ip address 10.0.48.2 255.255.248.0       
#                                         
interface GigabitEthernet4/0/0            
 ip address 10.0.112.1 255.255.248.0      
# 

R5

#                                         
interface GigabitEthernet0/0/0            
 ip address 10.0.8.2 255.255.248.0        
#                                         
interface GigabitEthernet0/0/1            
 ip address 10.0.16.1 255.255.248.0       
#                                         
interface GigabitEthernet0/0/2            
 ip address 10.0.56.1 255.255.248.0       
#                                         
interface GigabitEthernet4/0/0            
 ip address 10.0.120.1 255.255.248.0      
# 

R6

#                                         
interface GigabitEthernet0/0/0            
 ip address 10.0.56.2 255.255.248.0       
#                                         
interface GigabitEthernet0/0/1            
 ip address 10.0.48.2 255.255.248.0       
#                                         
interface GigabitEthernet0/0/2            
 ip address 10.0.96.1 255.255.248.0       
#                                         
interface NULL0                           
#                                         
interface LoopBack0                       
 ip address 6.6.6.6 255.255.255.0                  
# 

R7

#                                         
interface GigabitEthernet0/0/0            
 ip address 10.0.16.2 255.255.248.0       
#                                         
interface GigabitEthernet0/0/1            
 ip address 10.0.24.2 255.255.248.0       
#                                         
interface GigabitEthernet0/0/2            
 ip address 10.0.64.1 255.255.248.0       
#                                         
interface NULL0                           
#                                         
interface LoopBack0                       
 ip address 7.7.7.7 255.255.255.0                  
# 

R8

#                                         
interface GigabitEthernet0/0/0            
 ip address 10.0.64.2 255.255.248.0       
#                                         
interface GigabitEthernet0/0/1            
 ip address 10.0.88.2 255.255.248.0       
#                                         
interface GigabitEthernet0/0/2            
 ip address 10.0.96.2 255.255.248.0       
#                                         
interface GigabitEthernet4/0/0            
 ip address 10.0.128.1 255.255.248.0      
#                                         
interface GigabitEthernet4/0/1            
#                                         
interface GigabitEthernet4/0/2            
#                                         
interface GigabitEthernet4/0/3            
#                                         
interface NULL0                           
#                                         
interface LoopBack0                       
 ip address 8.8.8.8 255.255.255.0         
#  

R9

#                                         
interface GigabitEthernet0/0/0            
 ip address 10.0.136.1 255.255.248.0      
#                                         
interface GigabitEthernet0/0/1            
 ip address 10.0.104.2 255.255.248.0      
#                                         
interface GigabitEthernet0/0/2            
#                                         
interface GigabitEthernet4/0/0            
#                                         
interface GigabitEthernet4/0/1            
#                                         
interface GigabitEthernet4/0/2            
#                                         
interface GigabitEthernet4/0/3            
#                                         
interface NULL0                           
#                                         
interface LoopBack0                       
 ip address 9.9.9.9 255.255.255.0         
# 
[r10]int g0/0/2
[r10-GigabitEthernet0/0/2]ip add 10.0.3.1 24
[r10-GigabitEthernet0/0/2]int g4/0/0
[r10-GigabitEthernet4/0/0]ip add 10.0.4.1 24


R10

#                                         
interface GigabitEthernet0/0/0            
 ip address 10.0.136.2 255.255.248.0      
#                                         
interface GigabitEthernet0/0/1            
 ip address 10.0.112.2 255.255.248.0      
#                                         
interface GigabitEthernet0/0/2            
#                                         
interface GigabitEthernet4/0/0            
#                                         
interface GigabitEthernet4/0/1            
#                                         
interface GigabitEthernet4/0/2            
#                                         
interface GigabitEthernet4/0/3            
#                                         
interface NULL0                           
#                                         
interface LoopBack0                       
 ip address 10.10.10.10 255.255.255.0     
 [r10]int g0/0/2
[r10-GigabitEthernet0/0/2]int g4/0/0
[r10-GigabitEthernet4/0/0]ip add 10.0.4.1 24

# 

R11

#                                         
interface GigabitEthernet0/0/0            
 ip address 10.0.120.2 255.255.248.0      
#                                         
interface GigabitEthernet0/0/1            
 ip address 10.0.128.2 255.255.248.0      
#                                         
interface GigabitEthernet0/0/2            
#                                         
interface GigabitEthernet4/0/0            
#                                         
interface GigabitEthernet4/0/1            
#                                         
interface GigabitEthernet4/0/2            
#                                         
interface GigabitEthernet4/0/3            
#                                         
interface NULL0                           
#                                         
interface LoopBack0                       
 ip address 11.11.11.11 255.255.255.0     
#  
[r11]int g0/0/2
[r11-GigabitEthernet0/0/2]ip add 10.0.5.1 24
[r11-GigabitEthernet0/0/2]int g4/0/0
[r11-GigabitEthernet4/0/0]ip add 10.0.6.1 24

地址配置完成,可以简单的测试一下直连是否都通
这里我是测试了的
然后就是起AS1 AS2 AS3 中的OSPF协议,能够学到互相的路由
AS1
R1

[r1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]net
[r1-ospf-1-area-0.0.0.0]network 10.0.8.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]net
[r1-ospf-1-area-0.0.0.0]network 10.0.32.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]net
[r1-ospf-1-area-0.0.0.0]undo network 10.0.40.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]q
[r1-ospf-1]int lo0
[r1-LoopBack0]ospf net
[r1-LoopBack0]ospf network-type b
[r1-LoopBack0]ospf network-type broadcast 

说明: 这里进入环回接口,将接口改为broadcast,这样地址就会变成24位的地址,因为通过OPSF宣告的环回地址,结果为32位。

R3

[r3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[r3-ospf-1-area-0.0.0.0]net
[r3-ospf-1-area-0.0.0.0]network 10.0.32.2 0.0.0.0
[r3-ospf-1-area-0.0.0.0]net
[r3-ospf-1-area-0.0.0.0]network 10.0.24.1 0.0.0.0
[r3-ospf-1-area-0.0.0.0]int lo0
[r3-LoopBack0]ospf net
[r3-LoopBack0]ospf network-type b
[r3-LoopBack0]ospf network-type broadcast 

R5

[r5-ospf-1-area-0.0.0.0]network 5.5.5.5 0.0.0.0
[r5-ospf-1-area-0.0.0.0]net
[r5-ospf-1-area-0.0.0.0]network 10.0.8.2 0.0.0.0
[r5-ospf-1-area-0.0.0.0]net
[r5-ospf-1-area-0.0.0.0]network 10.0.16.1 0.0.0.0
[r5-ospf-1-area-0.0.0.0]int lo0
[r5-LoopBack0]ospf net
[r5-LoopBack0]ospf network-type b
[r5-LoopBack0]ospf network-type broadcast 

R7

[r7-ospf-1-area-0.0.0.0]network 7.7.7.7 0.0.0.0
[r7-ospf-1-area-0.0.0.0]net
[r7-ospf-1-area-0.0.0.0]network 10.0.24.2 0.0.0.0
[r7-ospf-1-area-0.0.0.0]network 10.0.16.2 0.0.0.0
[r7-ospf-1-area-0.0.0.0]int lo0
[r7-LoopBack0]ospf net
[r7-LoopBack0]ospf network-type b
[r7-LoopBack0]ospf network-type broadcast 

AS2 中
R2

[r2-ospf-2-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[r2-ospf-2-area-0.0.0.0]net
[r2-ospf-2-area-0.0.0.0]network 10.0.72.1 0.0.0.0
[r2-ospf-2-area-0.0.0.0]net
[r2-ospf-2-area-0.0.0.0]network 10.0.80.1 0.0.0.0
[r2-ospf-2-area-0.0.0.0]int lo0
[r2-LoopBack0]ospf net
[r2-LoopBack0]ospf network-type b
[r2-LoopBack0]ospf network-type broadcast

R4

[r4-ospf-2-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[r4-ospf-2-area-0.0.0.0]net
[r4-ospf-2-area-0.0.0.0]network 10.0.80.2 0.0.0.0
[r4-ospf-2-area-0.0.0.0]net
[r4-ospf-2-area-0.0.0.0]network 10.0.88.1 0.0.0.0
[r4-ospf-2-area-0.0.0.0]int lo0
[r4-LoopBack0]ospf net
[r4-LoopBack0]ospf network-type b
[r4-LoopBack0]ospf network-type broadcast 

R6

[r6-ospf-2-area-0.0.0.0]network 6.6.6.6 0.0.0.0
[r6-ospf-2-area-0.0.0.0]net
[r6-ospf-2-area-0.0.0.0]network 10.0.72.2 0.0.0.0
[r6-ospf-2-area-0.0.0.0]net
[r6-ospf-2-area-0.0.0.0]network 10.0.96.1 0.0.0.0
[r6-ospf-2-area-0.0.0.0]int lo0
[r6-LoopBack0]ospf net
[r6-LoopBack0]ospf network-type b
[r6-LoopBack0]ospf network-type broadcast

R8

[r8-ospf-2-area-0.0.0.0]network 8.8.8.8 0.0.0.0
[r8-ospf-2-area-0.0.0.0]net
[r8-ospf-2-area-0.0.0.0]network 10.0.88.2 0.0.0.0
[r8-ospf-2-area-0.0.0.0]net
[r8-ospf-2-area-0.0.0.0]network 10.0.96.2 0.0.0.0
[r8]int lo0
[r8-LoopBack0]ospf net
[r8-LoopBack0]ospf network-type b
[r8-LoopBack0]ospf network-type broadcast

AS3中
R9

[r9-ospf-3-area-0.0.0.0]network 9.9.9.9 0.0.0.0
[r9-ospf-3-area-0.0.0.0]net
[r9-ospf-3-area-0.0.0.0]network 10.0.136.1 0.0.0.0
[r9-ospf-3-area-0.0.0.0]network 10.0.1.1 0.0.0.0
[r9-ospf-3-area-0.0.0.0]net	
[r9-ospf-3-area-0.0.0.0]network 10.0.2.1 0.0.0.0
[r9]int lo0
[r9-LoopBack0]ospf net
[r9-LoopBack0]ospf network-type b
[r9-LoopBack0]ospf network-type broadcast 


R10

[r10-ospf-3-area-0.0.0.0]network 10.10.10.10 0.0.0.0
[r10-ospf-3-area-0.0.0.0]net
[r10-ospf-3-area-0.0.0.0]network 10.0.136.2 0.0.0.0
[r10-ospf-3-area-0.0.0.0]network 10.0.4.1 0.0.0.0
[r10-ospf-3-area-0.0.0.0]net	
[r10-ospf-3-area-0.0.0.0]network 10.0.3.1 0.0.0.0
[r10]int lo0
[r10-LoopBack0]ospf net
[r10-LoopBack0]ospf network-type b
[r10-LoopBack0]ospf network-type broadcast 

看一下ospf邻居建立的关系
R1

dis ospf peer brief 

	 OSPF Process 1 with Router ID 1.1.1.1
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             5.5.5.5          Full        
 0.0.0.0          GigabitEthernet0/0/1             3.3.3.3          Full        
 ----------------------------------------------------------------------------

R4

display ospf peer brief 

	 OSPF Process 2 with Router ID 4.4.4.4
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             2.2.2.2          Full        
 0.0.0.0          GigabitEthernet0/0/1             8.8.8.8          Full        
 ----------------------------------------------------------------------------

R9

[r9]display ospf peer brief 

	 OSPF Process 3 with Router ID 9.9.9.9
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             10.10.10.10      Full        
 ----------------------------------------------------------------------------

R6

[r8]display ospf peer brief 

	 OSPF Process 2 with Router ID 8.8.8.8
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/1             4.4.4.4          Full        
 0.0.0.0          GigabitEthernet0/0/2             6.6.6.6          Full        
 ----------------------------------------------------------------------------

ospf邻居建立没有问题。
然后配置BGP的对等体关系
在AS1 中
R1

[r1]bgp 1
[r1-bgp]router
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 10.0.104.2 sd
[r1-bgp]peer 10.0.104.2 as
[r1-bgp]peer 10.0.104.2 as-number 3
[r1-bgp]peer 10.0.40.2 as
[r1-bgp]peer 10.0.40.2 as-path-filter
[r1-bgp]peer 10.0.40.2 as-number 2
[r1-bgp]gr
[r1-bgp]group r1
[r1-bgp]peer r1 as
[r1-bgp]peer r1 con        
[r1-bgp]peer r1 connect-interface lo
[r1-bgp]peer r1 connect-interface LoopBack  0
[r1-bgp]peer r1 ne
[r1-bgp]peer r1 next-hop-invariable
[r1-bgp]peer r1 next-hop-local
[r1-bgp]peer r1 ad
[r1-bgp]peer r1 advertise-community
[r1-bgp]peer 3.3.3.3 g
[r1-bgp]peer 3.3.3.3 group  r1
[r1-bgp]peer 5.5.5.5 g
[r1-bgp]peer 5.5.5.5 group r1
[r1-bgp]peer 7.7.7.7 g
[r1-bgp]peer 7.7.7.7 group r1

R2

[r2]bgp 2
[r2-bgp]router
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 10.0.40.1 as
[r2-bgp]peer 10.0.40.1 as-number 1
[r2-bgp]gr
[r2-bgp]group r2
[r2-bgp]peer r2 con
[r2-bgp]peer r2 connect-interface lo
[r2-bgp]peer r2 connect-interface LoopBack 0
[r2-bgp]peer r2 ne
[r2-bgp]peer r2 next-hop-invariable
[r2-bgp]peer r2 next-hop-local
[r2-bgp]peer r2 ad
[r2-bgp]peer r2 advertise-community
[r2-bgp]peer 4.4.4
Aug  7 2022 20:54:31-08:00 r2 %%01BGP/3/STATE_CHG_UPDOWN(l)[0]:The status of the peer 10.0.40.1 changed from OPENCONFIRM to ESTABLISHED. (InstanceName=Public, StateChangeReason=Up)  
[r2-bgp]peer 4.4.4.4 g
[r2-bgp]peer 4.4.4.4 group r2
[r2-bgp]peer 6.6.6.6 gr
[r2-bgp]peer 6.6.6.6 group r2
[r2-bgp]peer 8.8.8.8 gr
[r2-bgp]peer 8.8.8.8 group r2

R3

[r3]bgp 1
[r3-bgp]rout
[r3-bgp]route-select
[r3-bgp]router-id 3.3.3.3
[r3-bgp]peer 10.0.48.2 as
[r3-bgp]peer 10.0.48.2 as-number 2
[r3-bgp]gt
[r3-bgp]g 
[r3-bgp]group r3
[r3-bgp]peer r3 con
[r3-bgp]peer r3 connect-interface lo
[r3-bgp]peer r3 connect-interface LoopBack  0
[r3-bgp]peer r3 ne
[r3-bgp]peer r3 next-hop-invariable
[r3-bgp]peer r3 next-hop-local
[r3-bgp]peer r3 next-hop-invariable
[r3-bgp]peer r3 next-hop-local
[r3-bgp]peer r3 ad
[r3-bgp]peer r3 advertise-community
[r3-bgp]peer 1.1.1.1 g
[r3-bgp]peer 1.1.1.1 group r3
[r3-bgp]peer 5.5.5.5 g
[r3-bgp]peer 5.5.5.5 group r3
[r3-bgp]peer 7.7.7.7 g
[r3-bgp]peer 7.7.7.7 group r3

R4

[r4]bgp 2
[r4-bgp]router
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 10.0.48.1 as
[r4-bgp]peer 10.0.48.1 as-number 1
[r4-bgp]peer 10.0.112.2 as
[r4-bgp]peer 10.0.112.2 as-path-filter
[r4-bgp]peer 10.0.112.2 as-number 3
[r4-bgp]gr
[r4-bgp]group r4
[r4-bgp]peer r4 con
[r4-bgp]peer r4 connect-interface lo
[r4-bgp]peer r4 connect-interface LoopBack 0
[r4-bgp]peer r4 next-hop-invariable
[r4-bgp]peer r4 next-hop-local
[r4-bgp]peer r4 ad
[r4-bgp]peer r4 advertise-community
[r4-bgp]peer 2.2.2.2 gr
[r4-bgp]peer 2.2.2.2 group r4
[r4-bgp]peer 6.6.6.6 gr
[r4-bgp]peer 6.6.6.6 group r4
[r4-bgp]peer 8.8.8.8 gr
[r4-bgp]peer 8.8.8.8 group r4

R5

[r5]bgp 1
[r5-bgp]router
[r5-bgp]router-id 5.5.5.5
[r5-bgp]peer 10.0.56.2 as
[r5-bgp]peer 10.0.56.2 as-number 2
[r5-bgp]peer 10.0.120.1 as
[r5-bgp]peer 10.0.120.1 as-path-filter
[r5-bgp]peer 10.0.120.2 as-number 4
[r5-bgp]gr
[r5-bgp]group r5
[r5-bgp]peer r5 con
[r5-bgp]peer r5 connect-interface lo
[r5-bgp]peer r5 connect-interface LoopBack 0
[r5-bgp]peer r5 ne
[r5-bgp]peer r5 next-hop-invariable
[r5-bgp]peer r5 next-hop-local
[r5-bgp]peer r5 advertise-community
[r5-bgp]peer 1.1.1.1 g
[r5-bgp]peer 1.1.1.1 group r5
[r5-bgp]peer 3.3.3.3g
[r5-bgp]peer 3.3.3.3 g
[r5-bgp]peer 3.3.3.3 group r5
[r5-bgp]peer 7.7.7.7 g
[r5-bgp]peer 7.7.7.7 group r5

R6

[r6]bgp 2
[r6-bgp]router
[r6-bgp]router-id 6.6.6.6
[r6-bgp]peer 10.0.56.1 as
[r6-bgp]peer 10.0.56.1 as-number 1
[r6-bgp]gr
[r6-bgp]group r6
[r6-bgp]peer r6 con
[r6-bgp]peer r6 connect-interface lo
[r6-bgp]peer r6 connect-interface LoopBack 0
[r6-bgp]peer r6 ne
[r6-bgp]peer r6 next-hop-invariable
[r6-bgp]peer r6 next-hop-local
[r6-bgp]peer r6 ad
[r6-bgp]peer r6 advertise-community
[r6-bgp]peer 2.2.2.2 group r6
[r6-bgp]peer 4.4.4.4 gr
[r6-bgp]peer 4.4.4.4 group r6
[r6-bgp]peer 8.8.8.8 gr
[r6-bgp]peer 8.8.8.8 group r6

R7

[r7]bgp 1
[r7-bgp]router
[r7-bgp]router-id 7.7.7.7
[r7-bgp]peer 10.0.64.2 as
[r7-bgp]peer 10.0.64.2 as-number 2
[r7-bgp]gr
[r7-bgp]group r7
[r7-bgp]peer r7 con
[r7-bgp]peer r7 connect-interface lo
[r7-bgp]peer r7 connect-interface LoopBack 0
[r7-bgp]peer r7 ne
[r7-bgp]peer r7 next-hop-invariable
[r7-bgp]peer r7 next-hop-local
[r7-bgp]peer r7 ad
[r7-bgp]peer r7 advertise-community
[r7-bgp]peer 1.1.1.1 g
[r7-bgp]peer 1.1.1.1 group  r7
[r7-bgp]peer 3.3.3.3 gr
[r7-bgp]peer 3.3.3.3 group r7
[r7-bgp]peer 5.5.5.5 gr
[r7-bgp]peer 5.5.5.5 group r7

R8

[r8]bgp 2
[r8-bgp]router
[r8-bgp]router-id 8.8.8.8
[r8-bgp]peer 10.0.128.2 as
[r8-bgp]peer 10.0.128.2 as-number 4
[r8-bgp]peer 10.0.64.1 as
[r8-bgp]peer 10.0.64.1 as-path-filter 
[r8-bgp]peer 10.0.64.1 as-number
[r8-bgp]peer 10.0.64.1 as-path-filter
[r8-bgp]peer 10.0.64.1 as-number 
[r8-bgp]peer 10.0.64.1 as-path-filter
[r8-bgp]peer 10.0.64.1 as-number 1
[r8-bgp]gr
[r8-bgp]group r8
[r8-bgp]peer r8 con
[r8-bgp]peer r8 connect-interface  lo
[r8-bgp]peer r8 connect-interface  LoopBack 0
[r8-bgp]peer r8 ne
[r8-bgp]peer r8 next-hop-invariable
[r8-bgp]peer r8 next-hop-local
[r8-bgp]peer r8 ad
[r8-bgp]peer r8 advertise-community
[r8-bgp]peer 2.2.2.2 group r8
[r8-bgp]peer 4.4.4.4 gr
[r8-bgp]peer 4.4.4.4 group r8
[r8-bgp]peer 6.6.6.6 gr
[r8-bgp]peer 6.6.6.6 group  r8

R9

[r9]bgp 3
[r9-bgp]router
[r9-bgp]router-id 9.9.9.9
[r9-bgp]peer 10.0.104.1 as
[r9-bgp]peer 10.0.104.1 as-number 1
[r9-bgp]peer 10.0.136.2 as
[r9-bgp]peer 10.0.136.2 as-path-filter
[r9-bgp]peer 10.0.136.2 as-number 3

R10

[r10]bgp 3 
[r10-bgp]router
[r10-bgp]router-id 10.10.10.10
[r10-bgp]peer 10.0.136.1 as
[r10-bgp]peer 10.0.136.1 as-number 3
[r10-bgp]peer 10.0.112.1 as-number 2

R11

[r11]bgp 4
[r11-bgp]router
[r11-bgp]router-id 11.11.11.11
[r11-bgp]peer 10.0.120.1 as
[r11-bgp]peer 10.0.120.1 as-number 1
[r11-bgp]peer 10.0.128.1 as-number 2

这里我们采用组的方式来配置,这样可以减少配置量。
一定要配置社团属性,因为后面需要用社团属性来抓取流量

配置完成后,我们需要检测一下BGP peer的建立情况
R1

display  bgp peer

 BGP local router ID : 1.1.1.1
 Local AS number : 1
 Total number of peers : 5                Peers in established state : 5

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  3.3.3.3         4           1      128      129     0 02:06:42 Established       0
  5.5.5.5         4           1      125      126     0 02:03:20 Established       0
  7.7.7.7         4           1      123      124     0 02:01:52 Established       0
  10.0.40.2       4           2      122      123     0 02:00:40 Established       0
  10.0.104.2      4           3      116      117     0 01:54:28 Established       0

R2

display bgp peer

 BGP local router ID : 2.2.2.2
 Local AS number : 2
 Total number of peers : 4                Peers in established state : 4

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  4.4.4.4         4           2      122      123     0 02:00:04 Established       0
  6.6.6.6         4           2      120      121     0 01:58:45 Established       0
  8.8.8.8         4           2      119      120     0 01:57:13 Established       0
  10.0.40.1       4           1      124      124     0 02:02:25 Established       0

R10

[r10-bgp]display bgp peer

 BGP local router ID : 10.10.10.10
 Local AS number : 3
 Total number of peers : 2                Peers in established state : 2

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State PrefRcv

  10.0.112.1      4           2        2        2     0 00:00:29 Established       0
  10.0.136.1      4           3        2        2     0 00:00:41 Established       0

我们可以发现,建立没有问题。
将路由宣告到BGP路由里面去
R9

[r9]bgp 3
[r9-bgp]net
[r9-bgp]network 10.0.1.0 24
[r9-bgp]net
[r9-bgp]network 10.0.2.0 24

R10

[r10]bgp 3
[r10-bgp]net
[r10-bgp]network 10.0.3.0 24
[r10-bgp]net
[r10-bgp]network 10.0.4.0 24

R11

[r11]bgp 4
[r11-bgp]net
[r11-bgp]network 10.0.5.0 24
[r11-bgp]net
[r11-bgp]network 10.0.6.0 24

查看R9的bgp路由表

[r9-bgp]display bgp routing-table 

 BGP Local router ID is 9.9.9.9 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete


 Total Number of Routes: 8
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   10.0.1.0/24        0.0.0.0         0                     0      i
 *>   10.0.2.0/24        0.0.0.0         0                     0      i
 *>i  10.0.3.0/24        10.0.136.2      0          100        0      i
 *>i  10.0.4.0/24        10.0.136.2      0          100        0      i
 *>   10.0.5.0/24        10.0.104.1                            0      1 4i
   i                     10.0.112.1                 100        0      2 4i
 *>   10.0.6.0/24        10.0.104.1                            0      1 4i
   i                     10.0.112.1                 100        0      2 4i

R10

[r10-bgp]display bgp routing-table 

 BGP Local router ID is 10.10.10.10 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete


 Total Number of Routes: 8
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  10.0.1.0/24        10.0.136.1      0          100        0      i
 *>i  10.0.2.0/24        10.0.136.1      0          100        0      i
 *>   10.0.3.0/24        0.0.0.0         0                     0      i
 *>   10.0.4.0/24        0.0.0.0         0                     0      i
 *>   10.0.5.0/24        10.0.112.1                            0      2 4i
   i                     10.0.104.1                 100        0      1 4i
 *>   10.0.6.0/24        10.0.112.1                            0      2 4i
   i                     10.0.104.1                 100        0      1 4i

R11

[r11-bgp]display bgp routing-table 

 BGP Local router ID is 11.11.11.11 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete


 Total Number of Routes: 10
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   10.0.1.0/24        10.0.120.1                            0      1 3i
 *                       10.0.128.1                            0      2 3i
 *>   10.0.2.0/24        10.0.120.1                            0      1 3i
 *                       10.0.128.1                            0      2 3i
 *>   10.0.3.0/24        10.0.120.1                            0      1 3i
 *                       10.0.128.1                            0      2 3i
 *>   10.0.4.0/24        10.0.120.1                            0      1 3i
 *                       10.0.128.1                            0      2 3i
 *>   10.0.5.0/24        0.0.0.0         0                     0      i
 *>   10.0.6.0/24        0.0.0.0         0                     0      i

接下来 我们需要对路由进行一些控制
利用团体属性
在R9上

[r9]ip ip-
[r9]ip ip-prefix c1 per
[r9]ip ip-prefix c1 permit 10.0.1.0 24
[r9]ip ip-
[r9]ip ip-prefix c2 per
[r9]ip ip-prefix c2 permit 10.0.2.0 24
[r9]ip ip-
[r9]ip ip-prefix c1 per
[r9]ip ip-prefix c1 permit 10.0.3.0 24
[r9]ip ip-
[r9]ip ip-prefix c2 per
[r9]ip ip-prefix c2 permit 10.0.4.0 24
[r9]q
[r9]router
[r9]route-policy com per
[r9]route-policy com permit node 10
Info: New Sequence of this List.
[r9-route-policy]if
[r9-route-policy]if-match ip 
[r9-route-policy]if-match ip
[r9-route-policy]if-match ip-prefix c1
[r9-route-policy]apply com
[r9-route-policy]apply communi    
[r9-route-policy]apply community 100:3
[r9-route-policy]q
[r9]route-policy com
[r9]route-policy com  per
[r9]route-policy com  permit node 20
Info: New Sequence of this List.
[r9-route-policy]if
[r9-route-policy]if-match ip
[r9-route-policy]if-match ip-prefix c2
[r9-route-policy]apply communi
[r9-route-policy]apply community 200:3
[r9-route-policy]q
[r9]route-policy com
[r9]route-policy com per
[r9]route-policy com permit node 30
Info: New Sequence of this List.
[r9-route-policy]q
[r9]bgp 3
[r9-bgp]peer 10.0.120.1 rou
[r9-bgp]peer 10.0.120.1 route-policy com ex
[r9-bgp]peer 10.0.104.1 route-policy com export

在R11上查看bgp表

[r11]dis bgp routing-table 

 BGP Local router ID is 11.11.11.11 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete


 Total Number of Routes: 10
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   10.0.1.0/24        10.0.120.1                            0      1 3i
 *                       10.0.128.1                            0      2 3i
 *>   10.0.2.0/24        10.0.120.1                            0      1 3i
 *                       10.0.128.1                            0      2 3i
 *>   10.0.3.0/24        10.0.120.1                            0      1 3i
 *                       10.0.128.1                            0      2 3i
 *>   10.0.4.0/24        10.0.120.1                            0      1 3i
 *                       10.0.128.1                            0      2 3i
 *>   10.0.5.0/24        0.0.0.0         0                     0      i
 *>   10.0.6.0/24        0.0.0.0         0                     0      i

R10

[r10]ip ip-
[r10]ip ip-prefix c1 per
[r10]ip ip-prefix c1 permit 10.0.1.0 24
[r10]ip ip-prefix c1 permit 10.0.3.0 24
[r10]ip ip
[r10]ip ip-prefix c2 per
[r10]ip ip-prefix c2 permit 10.0.2.0 24
[r10]ip ip-prefix c2 permit 10.0.4.0 24
[r10]route-policy com per
[r10]route-policy com permit node 10
[r10-route-policy]if
[r10-route-policy]if-match ip
[r10-route-policy]if-match ip
[r10-route-policy]if-match ip-prefix c1
[r10-route-policy]app 
[r10-route-policy]apply communi
[r10-route-policy]apply community 100:3
[r10-route-policy]q
[r10]route-policy com per 
[r10]route-policy com permit node 20
Info: New Sequence of this List.
[r10-route-policy]if
[r10-route-policy]if-match ip-
[r10-route-policy]if-match ip-prefix c2
[r10-route-policy]apply community 200:3
[r10-route-policy]route-policy com permit node 30
[r10-route-policy]q
[r10]bgp 3
[r10-bgp]peer 10.0.112.1 route-policy com ex
[r10-bgp]peer 10.0.112.1 route-policy com export 

在R11上

[r11]route
[r11]route-policy com1 per
[r11]route-policy com1 permit node 10
Info: New Sequence of this List.
[r11]route-policy com1 permit node 20
[r11]ip community-filter  ad
[r11]ip community-filter  advanced  com1 per
[r11]ip community-filter  advanced  com1 permit 100:.*
[r11]route-policy com2 per
[r11]route-policy com2 permit node 10
Info: New Sequence of this List.
[r11-route-policy]if   
[r11-route-policy]if-match commu
[r11-route-policy]if-match community-filter com2
[r11-route-policy]apply loc
[r11-route-policy]apply local-preference 110
[r11-route-policy]q
[r11]route-policy com2 per
[r11]route-policy com2 permit node 20
Info: New Sequence of this List.
[r11-route-policy]q
[r11]bgp 4
[r11-bgp]peer 10.0.128.1 rou
[r11-bgp]peer 10.0.128.1 route-limit
[r11-bgp]peer 10.0.128.1 route-policy com2 im
[r11-bgp]peer 10.0.128.1 route-policy com2 import 

再次查看R11的bgp表

[[r11-bgp]display bgp routing-table 

 BGP Local router ID is 11.11.11.11 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete


 Total Number of Routes: 10
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   10.0.1.0/24        10.0.128.1                 110        0      2 3i
 *                       10.0.120.1                            0      1 3i
 *>   10.0.2.0/24        10.0.128.1                 110        0      2 3i
 *                       10.0.120.1                            0      1 3i
 *>   10.0.3.0/24        10.0.128.1                 110        0      2 3i
 *                       10.0.120.1                            0      1 3i
 *>   10.0.4.0/24        10.0.128.1                 110        0      2 3i
 *                       10.0.120.1                            0      1 3i
 *>   10.0.5.0/24        0.0.0.0         0                     0      i
 *>   10.0.6.0/24        0.0.0.0         0                     0      i

实验完成。

你可能感兴趣的:(网络,网络协议,安全)