BGP实验
1、给路由器配置IP地址和环回地址,给主机配置IP地址
2、对AR2——AR4进行ospf宣告
AR2:
[V200R003C00]
#
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 23.0.0.1 0.0.0.0
#
return
AR3:
[V200R003C00]
#
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 23.0.0.2 0.0.0.0
network 34.0.0.1 0.0.0.0
#
return
AR4:
[V200R003C00]
#
ospf 1
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 34.0.0.2 0.0.0.0
#
return
3、在各个路由器上启动BGP协议
AR1:
[V200R003C00]
#
bgp 1
router-id 1.1.1.1————————本路由器的router-id
peer 12.0.0.2 as-number 2——————————对端(邻居)的接口IP和as号——对端的范围
#
ipv4-family unicast
undo synchronization
peer 12.0.0.2 enable
#
return
AR2:
[V200R003C00]
#
bgp 2
router-id 2.2.2.2
peer 12.0.0.1 as-number 1
#
ipv4-family unicast
undo synchronization
peer 12.0.0.1 enable
#
return
*将R2上BGP的源地址改为环回接口:
V200R003C00]
#
bgp 2
router-id 2.2.2.2
peer 3.3.3.3 as-number 2
peer 3.3.3.3 connect-interface LoopBack0------改为了环回接口
peer 12.0.0.1 as-number 1
#
ipv4-family unicast
undo synchronization
peer 3.3.3.3 enable
peer 12.0.0.1 enable
#
return
AR3:——两个邻居(2.2.2.2、3.3.3.3用环回接口建立邻居关系)
[V200R003C00]
#
bgp 2
router-id 3.3.3.3
peer 2.2.2.2 as-number 2
peer 2.2.2.2 connect-interface LoopBack0
peer 4.4.4.4 as-number 2
peer 4.4.4.4 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 2.2.2.2 enable
peer 4.4.4.4 enable
#
return
AR4:——两个邻居(3.3.3.3/5.5.5.5,用环回接口建立邻居关系)
[V200R003C00]
#
bgp 2
router-id 4.4.4.4
peer 3.3.3.3 as-number 2
peer 3.3.3.3 connect-interface LoopBack0
peer 5.5.5.5 as-number 3
peer 5.5.5.5 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 3.3.3.3 enable
peer 5.5.5.5 enable
#
return
*此时需要AR4用静态路由指向AR5
ip route-static 5.5.5.0 255.255.255.0 45.0.0.2
ip route-static 5.5.5.0 255.255.255.0 54.0.0.2
*AR5用静态路由指向AR4
ip route-static 4.4.4.0 255.255.255.0 45.0.0.1
ip route-static 4.4.4.0 255.255.255.0 54.0.0.1
*建立EBGP邻居关系
AR4:
[V200R003C00]
#
bgp 3
router-id 5.5.5.5
peer 4.4.4.4 as-number 2
peer 4.4.4.4 ebgp-max-hop 255
peer 4.4.4.4 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 4.4.4.4 enable
#
return
AR5:
[V200R003C00]
#
bgp 2
router-id 4.4.4.4
peer 3.3.3.3 as-number 2
peer 3.3.3.3 connect-interface LoopBack0
peer 5.5.5.5 as-number 3
peer 5.5.5.5 ebgp-max-hop 255
peer 5.5.5.5 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 3.3.3.3 enable
peer 5.5.5.5 enable
#
return
4、对各路由器的BGP协议进行宣告
AR1:
[AR1]bgp 1
[AR1-bgp]network 192.168.1.0 24
AR2:
[AR2]bgp 2
[AR2-bgp]network 192.168.2.0 24
AR3:
[AR3]bgp 2
[AR3-bgp]network 192.168.3.0 24
AR4:
[AR4]bgp 2
[AR4-bgp]network 192.168.4.0 24
AR5:
[AR5]bgp 3
[AR5-bgp]network 192.168.5.0 24
5、验证各个主机是否拼通
1.PC1pingPC2:
PC>ping 192.168.2.1
Ping 192.168.2.1: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.2.1: bytes=32 seq=2 ttl=126 time=15 ms
From 192.168.2.1: bytes=32 seq=3 ttl=126 time=16 ms
From 192.168.2.1: bytes=32 seq=4 ttl=126 time=31 ms
From 192.168.2.1: bytes=32 seq=5 ttl=126 time=16 ms
--- 192.168.2.1 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 0/19/31 ms