BGP小实验

分配ip

172.16.0.0/16

172.16.0.0/19
172.16.32.0/19
172.16.64.0/19
172.16.96.0/19
172.16.128.0/19
172.16.160.0/19
172.16.192.0/19
172.16.224.0/19

配置ip

R1
Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              unassigned           down       down      
GigabitEthernet0/0/1              12.1.1.1/24          up         up            
LoopBack0                         1.1.1.1/24           up         up(s)     
NULL0                             unassigned           up         up(s)    
 
R2
Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              12.1.1.2/24          up         up        
GigabitEthernet0/0/1              23.1.1.1/24          up         up        
GigabitEthernet0/0/2              25.1.1.1/24          up         up        
LoopBack0                         2.2.2.2/24           up         up(s)     
LoopBack1                         172.16.0.1/19        up         up(s)     

R3
Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              23.1.1.2/24          up         up        
GigabitEthernet0/0/1              34.1.1.1/24          up         up           
LoopBack0                         3.3.3.3/24           up         up(s)     
LoopBack1                         172.16.32.1/19       up         up(s)     


R4
Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              34.1.1.2/24          up         up        
GigabitEthernet0/0/1              47.1.1.1/24          up         up            
LoopBack0                         4.4.4.4/24           up         up(s)     
LoopBack1                         172.16.64.1/19       up         up(s)     


R5
GigabitEthernet0/0/0              25.1.1.2/24          up         up        
GigabitEthernet0/0/1              56.1.1.1/24          up         up           
LoopBack0                         5.5.5.5/24           up         up(s)     
LoopBack1                         172.16.96.1/19       up         up(s)     


R6
GigabitEthernet0/0/0              56.1.1.2/24          up         up        
GigabitEthernet0/0/1              67.1.1.1/24          up         up        
LoopBack0                         6.6.6.6/24           up         up(s)     
LoopBack1                         172.16.128.1/19      up         up(s)     


R7
GigabitEthernet0/0/0              67.1.1.2/24          up         up        
GigabitEthernet0/0/1              78.1.1.1/24          up         up        
GigabitEthernet0/0/2              47.1.1.2/24          up         up        
LoopBack0                         7.7.7.7/24           up         up(s)     
LoopBack1                         172.16.160.1/19      up         up(s)     


R8
GigabitEthernet0/0/0              78.1.1.2/24          up         up           
LoopBack0                         8.8.8.8/24           up         up(s)     

启动OSPF

r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]a 0
[r2-ospf-1-area-0.0.0.0]net	
[r2-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255

[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]a 0
[r3-ospf-1-area-0.0.0.0]net	
[r3-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255

[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]a 0
[r4-ospf-1-area-0.0.0.0]net	
[r4-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255

[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]a 0
[r5-ospf-1-area-0.0.0.0]net	
[r5-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255

[r6]ospf 1 router-id 6.6.6.6
[r6-ospf-1]a 0
[r6-ospf-1-area-0.0.0.0]net	
[r6-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255

[r7]ospf 1 router-id 7.7.7.7
[r7-ospf-1]a 0
[r7-ospf-1-area-0.0.0.0]net	
[r7-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255


建立联邦

R2
bgp 64512
 router-id 2.2.2.2
 confederation id 2
 confederation peer-as 64513
 peer 3.3.3.3 as-number 64512 
 peer 3.3.3.3 connect-interface LoopBack0
 peer 5.5.5.5 as-number 64513  
 peer 5.5.5.5 connect-interface LoopBack0
 peer 12.1.1.1 as-number 1 
 peer 3.3.3.3 next-hop-local

R3:建立RR
bgp 64512
 router-id 3.3.3.3
 confederation id 2
 peer 2.2.2.2 as-number 64512 
 peer 2.2.2.2 connect-interface LoopBack0
 peer 4.4.4.4 as-number 64512 
 peer 4.4.4.4 connect-interface LoopBack0
 peer 2.2.2.2 reflect-client
 //让R2成为自己的客户

R4
bgp 64512
 router-id 4.4.4.4
 confederation id 2
 confederation peer-as 64513
 peer 3.3.3.3 as-number 64512 
 peer 3.3.3.3 connect-interface LoopBack0
 peer 7.7.7.7 as-number 64513 
 peer 7.7.7.7 ebgp-max-hop 255 
 peer 7.7.7.7 connect-interface LoopBack0
peer 3.3.3.3 next-hop-local 
peer 3.3.3.3 next-hop-local 

R5
bgp 64513
 router-id 5.5.5.5
 confederation id 2
 confederation peer-as 64512
 peer 2.2.2.2 as-number 64512 
 peer 2.2.2.2 ebgp-max-hop 255 
 peer 2.2.2.2 connect-interface LoopBack0
 peer 6.6.6.6 as-number 64513 
 peer 6.6.6.6 connect-interface LoopBack0

R6为RR
bgp 64513
 router-id 6.6.6.6
 confederation id 2
 peer 5.5.5.5 as-number 64513 
 peer 5.5.5.5 connect-interface LoopBack0
 peer 6.6.6.6 as-number 64513 
 peer 7.7.7.7 as-number 64513 
 peer 7.7.7.7 connect-interface LoopBack0
 peer 5.5.5.5 reflect-client 	//R5为R6客户



R7
bgp 64513
 router-id 7.7.7.7
 confederation id 2
 confederation peer-as 64512
 peer 4.4.4.4 as-number 64512 
 peer 4.4.4.4 ebgp-max-hop 255 
 peer 4.4.4.4 connect-interface LoopBack0
 peer 6.6.6.6 as-number 64513 
 peer 6.6.6.6 connect-interface LoopBack0
 peer 78.1.1.2 as-number 3 


[rx-bgp]peer x.x.x.x next-hop-local
## 因为IBGP的水平分割原理导致IBGP对等体关系内部只能传递一跳所以需要这个命令将下一跳修改为本地来打破水平分割原理

宣告环回


R1
network 1.1.1.0 255.255.255.0 
R2
network 172.16.0.0 255.255.224.0 
R3
network 172.16.32.0 255.255.224.0
R4
network 172.16.64.0 255.255.224.0 
R5
network 172.16.96.0 255.255.224.0
R6
network 172.16.128.0 255.255.224.0 
R7
network 172.16.160.0 255.255.224.0
R8
network 8.8.8.0 255.255.255.0 

路由汇总

R2-R6都得汇总
aggregate 172.16.0.0 255.255.0.0 detail-suppressed 

R2的邻居

[Huawei-bgp]display bgp peer 

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

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State Pre
fRcv

  3.3.3.3         4       64512       39       40     0 00:34:05 Established    
   1
  5.5.5.5         4       64513       41       42     0 00:34:03 Established    
   2
  12.1.1.1        4           1       37       40     0 00:34:30 Established    
   1

R2的BGP路由表

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   1.1.1.0/24         12.1.1.1        0                     0      1i
 *>   2.2.2.0/24         0.0.0.0         0                     0      i
 *>i  8.8.8.0/24         7.7.7.7         0          100        0      (64513) 3i
 *>   172.16.0.0         127.0.0.1                             0      i
 * i                     3.3.3.3                    100        0      i
 * i                     5.5.5.5                    100        0      (64513)i
 s>   172.16.0.0/19      0.0.0.0         0                     0      i

测试

R1-R8
<Huawei>ping -a	
<Huawei>ping -a 1.1.1.1 8.8.8.8
  PING 8.8.8.8: 56  data bytes, press CTRL_C to break
    Reply from 8.8.8.8: bytes=56 Sequence=1 ttl=251 time=70 ms
    Reply from 8.8.8.8: bytes=56 Sequence=2 ttl=251 time=30 ms
    Reply from 8.8.8.8: bytes=56 Sequence=3 ttl=251 time=40 ms
    Reply from 8.8.8.8: bytes=56 Sequence=4 ttl=251 time=40 ms
    Reply from 8.8.8.8: bytes=56 Sequence=5 ttl=251 time=40 ms

  --- 8.8.8.8 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/44/70 ms

R1-R4
<Huawei>ping -a 1.1.1.1 172.16.64.1
  PING 172.16.64.1: 56  data bytes, press CTRL_C to break
    Reply from 172.16.64.1: bytes=56 Sequence=1 ttl=253 time=40 ms
    Reply from 172.16.64.1: bytes=56 Sequence=2 ttl=253 time=30 ms
    Reply from 172.16.64.1: bytes=56 Sequence=3 ttl=253 time=30 ms
    Reply from 172.16.64.1: bytes=56 Sequence=4 ttl=253 time=20 ms
    Reply from 172.16.64.1: bytes=56 Sequence=5 ttl=253 time=30 ms

  --- 172.16.64.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/30/40 ms

R1-R7
<Huawei>ping -a 1.1.1.1 172.16.160.1
  PING 172.16.160.1: 56  data bytes, press CTRL_C to break
    Reply from 172.16.160.1: bytes=56 Sequence=1 ttl=252 time=50 ms
    Reply from 172.16.160.1: bytes=56 Sequence=2 ttl=252 time=30 ms
    Reply from 172.16.160.1: bytes=56 Sequence=3 ttl=252 time=40 ms
    Reply from 172.16.160.1: bytes=56 Sequence=4 ttl=252 time=50 ms
    Reply from 172.16.160.1: bytes=56 Sequence=5 ttl=252 time=40 ms

  --- 172.16.160.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/42/50 ms


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值