实验拓扑:
实验要求:
使用BGP,按照真实网络环境的逻辑配置,实现所有PC间能够正常通讯
首先
我们给每一台路由器进行地址的配置
R1:
r1]int lo0
[r1-LoopBack0]ip ad
[r1-LoopBack0]ip address 1.1.1.1 24
[r1-LoopBack0]int g0/0/0
[r1-GigabitEthernet0/0/0]ip ad 12.1.1.1 24
[r1]int g0/0/1
[r1-GigabitEthernet0/0/1]ip ad
[r1-GigabitEthernet0/0/1]ip address 1.1.2.1 24
R2:
[r2]int lo0
[r2-LoopBack0]ip ad
[r2-LoopBack0]ip address 2.2.2.2 24
[r2-LoopBack0]int g0/0/0
[r2-GigabitEthernet0/0/0]ip ad 12.1.1.2 24
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip ad 23.1.1.1 24
[r2-GigabitEthernet0/0/2]ip address 2.2.3.2 24
R4:
[r4]int lo0
[r4-LoopBack0]ip ad
[r4-LoopBack0]ip address 4.4.4.4 24
[r4-GigabitEthernet0/0/0]ip address 34.1.1.2 24
[r4-GigabitEthernet0/0/1]ip ad
[r4-GigabitEthernet0/0/1]ip address 45.1.1.1 24
[r4-GigabitEthernet0/0/2]ip ad
[r4-GigabitEthernet0/0/2]ip address 54.1.1.1 24
[r4-GigabitEthernet0/0/2]int g4/0/0
[r4-GigabitEthernet4/0/0]ip ad
[r4-GigabitEthernet4/0/0]ip address 4.4.5.4 24
其余路由器配置都相同
然后
在R1和R2之间起EBGP
[r1]bgp 1
[r1-bgp]rou
[r1-bgp]route-i
[r1-bgp]router-i
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 12.1.1.2 as
[r1-bgp]peer 12.1.1.2 as-number 2
[r2]bgp 2
[r2-bgp]router
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 12.1.1.1 as
[r2-bgp]peer 12.1.1.1 as-number 1
通过指令:[r1]display bgp peer 查看
BGP local router ID : 1.1.1.1
Local AS number : 1
Total number of peers : 1 Peers in established state : 1
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pre
fRcv
12.1.1.2 4 2 3 4 0 00:01:26 Established
0
然后
在R2和R3,R3与R4进行IBGP,两两之间通过环回路由进行建邻
在所有得IBGP中起一个ospf动态路由协议
R3:
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]net
[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 3.3.4.3 0.0.0.0
[r3-ospf-1-area-0.0.0.0]net
[r3-ospf-1-area-0.0.0.0]network 23.1.1.2 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 34.1.1.1 0.0.0.0
R2和R4动作大致相同。。
R2和R3:
[r2]bgp 2
[r2-bgp]peer 3.3.3.3 as
[r2-bgp]peer 3.3.3.3 as-num
[r2-bgp]peer 3.3.3.3 as-number 2
[r2-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[r3]bgp 2
[r3-bgp]router
[r3-bgp]router-id 3.3.3.3
[r3-bgp]peer 2.2.2.2 as
[r3-bgp]peer 2.2.2.2 as-number 2
[r3-bgp]peer 2.2.2.2 connect-interface LoopBack 0
R3和R4:
[r4]bgp 2
[r4-bgp]router
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 3.3.3.3 as-
[r4-bgp]peer 3.3.3.3 as-number 2
[r4-bgp]peer 3.3.3.3 con
[r4-bgp]peer 3.3.3.3 connect-interface lo
[r4-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[r3-bgp]peer 4.4.4.4 con
[r3-bgp]peer 4.4.4.4 connect-interface lo
[r3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r3-bgp]
R4和R5要建立EBGP,则想要R4的环回能够访问到R5的环回,所有得写相应得路由
[r4]ip rou
[r4]ip route-s
[r4]ip route-static 5.5.5.0 24 45.1.1.2
[r4]ip route-static 5.5.5.0 24 54.1.1.2
[r5]ip route-s
[r5]ip route-static 4.4.4.0 24 45.1.1.1
[r5]ip route-static 4.4.4.0 24 54.1.1.1
然后测试能不能ping通,如果可以
则开始通过环回来建立
[r5]bgp 3
[r5-bgp]router
[r5-bgp]router-id 5.5.5.5
[r5-bgp]peer 4.4.4.4 as
[r5-bgp]peer 4.4.4.4 as-number 2
[r5-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r5-bgp]peer 4.4.4.4 ebgp-max-hop 2
[r4]bgp 2
[r4-bgp]peer 5.5.5.5 as
[r4-bgp]peer 5.5.5.5 as-number 3
[r4-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[r4-bgp]peer 5.5.5.5 ebgp-max-hop 2
然后进行BGP路由得宣告
R1:
[r1]bgp 1
[r1-bgp]net
[r1-bgp]network 1.1.2.0 24
R5:
[r5-bgp]network 5.5.6.0 24
剩余得操作一样。
我会发现R3上获得得R1得宣告得网段不优。
则就需要:[r2-bgp]peer 3.3.3.3 next-hop-local
发现R3获得R5宣告得网段也不优。则操作相同
[r4-bgp]peer 2.2.2.2 next-hop-local
[r4-bgp]peer 3.3.3.3 next-hop-local
然后在R5上查看BGP表
[r4-bgp]peer 3.3.3.3 next-hop-local
Total Number of Routes: 4
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 2.2.3.0/24 4.4.4.4 0 2i
*> 3.3.4.0/24 4.4.4.4 0 2i
*> 4.4.5.0/24 4.4.4.4 0 0 2i
*> 5.5.6.0/24 0.0.0.0 0 0 i
查看R3得BGP表
Total Number of Routes: 5
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.1.2.0/24 2.2.2.2 0 100 0 1i
*>i 2.2.3.0/24 2.2.2.2 0 100 0 i
*> 3.3.4.0/24 0.0.0.0 0 0 i
*>i 4.4.5.0/24 4.4.4.4 0 100 0 i
*>i 5.5.6.0/24 4.4.4.4 0 100 0 3i
最后用R1pingR5:
<r1>ping -a 1.1.2.1 5.5.6.5
PING 5.5.6.5: 56 data bytes, press CTRL_C to break
Reply from 5.5.6.5: bytes=56 Sequence=1 ttl=252 time=60 ms
Reply from 5.5.6.5: bytes=56 Sequence=2 ttl=252 time=30 ms
Reply from 5.5.6.5: bytes=56 Sequence=3 ttl=252 time=40 ms
Reply from 5.5.6.5: bytes=56 Sequence=4 ttl=252 time=40 ms
Reply from 5.5.6.5: bytes=56 Sequence=5 ttl=252 time=50 ms
--- 5.5.6.5 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/44/60 ms
可以通
R3pingR1
<r3>ping -a 3.3.4.3 1.1.2.1
PING 1.1.2.1: 56 data bytes, press CTRL_C to break
Reply from 1.1.2.1: bytes=56 Sequence=1 ttl=254 time=30 ms
Reply from 1.1.2.1: bytes=56 Sequence=2 ttl=254 time=20 ms
Reply from 1.1.2.1: bytes=56 Sequence=3 ttl=254 time=20 ms
Reply from 1.1.2.1: bytes=56 Sequence=4 ttl=254 time=20 ms
Reply from 1.1.2.1: bytes=56 Sequence=5 ttl=254 time=30 ms
--- 1.1.2.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/24/30 ms
其余的大家也可以测试。
实验完成