BGP小实验——选路不困难,只要有方法
生活随笔
收集整理的這篇文章主要介紹了
BGP小实验——选路不困难,只要有方法
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
BGP小實驗——選路不困難,只要有方法
- 前言
- 一、需求
- 二、命令
- 1、先配置基礎命令,完成全網(wǎng)通
- R1
- R2
- R3
- R4
- R5
- 2、查看BGP路由表
- R1
- R4
- 3、擇路(我們用兩種方式)
- R1
- R3
- 4、刷新下BGP,再次查看擇路結果
- R1
- R4
- 5、結論
前言
一、需求
- 全網(wǎng)通
- R1到R4走R3
- R4到R1走R3
二、命令
1、先配置基礎命令,完成全網(wǎng)通
R1
<Huawei>u t m Info: Current terminal monitor is off. <Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]int g0/0/0 [Huawei-GigabitEthernet0/0/0]ip add 12.0.0.1 24 [Huawei-GigabitEthernet0/0/0]int g0/0/1 [Huawei-GigabitEthernet0/0/1]ip add 13.0.0.1 24 [Huawei-GigabitEthernet0/0/1]int loop 0 [Huawei-LoopBack0]ip add 1.1.1.1 32 [Huawei-LoopBack0]q [Huawei]ip route-static 2.2.2.2 32 12.0.0.2 [Huawei]ip route-static 3.3.3.3 32 13.0.0.3 [Huawei]bgp 100 [Huawei-bgp]router-id 1.1.1.1 [Huawei-bgp]peer 2.2.2.2 as-number 200 [Huawei-bgp]peer 3.3.3.3 as-number 200 [Huawei-bgp]peer 2.2.2.2 connect-interface LoopBack 0 [Huawei-bgp]peer 3.3.3.3 connect-interface LoopBack 0 [Huawei-bgp]peer 2.2.2.2 ebgp-max-hop 2 [Huawei-bgp]peer 3.3.3.3 ebgp-max-hop 2 [Huawei-bgp]net 1.1.1.1 32 [Huawei-bgp]net 2.2.2.2 32 [Huawei-bgp]net 3.3.3.3 32 [Huawei-bgp]q [Huawei]ping -a 1.1.1.1 5.5.5.5PING 5.5.5.5: 56 data bytes, press CTRL_C to breakReply from 5.5.5.5: bytes=56 Sequence=1 ttl=253 time=30 msReply from 5.5.5.5: bytes=56 Sequence=2 ttl=253 time=20 msReply from 5.5.5.5: bytes=56 Sequence=3 ttl=253 time=30 msReply from 5.5.5.5: bytes=56 Sequence=4 ttl=253 time=40 msReply from 5.5.5.5: bytes=56 Sequence=5 ttl=253 time=30 ms--- 5.5.5.5 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 20/30/40 msR2
<Huawei>u t m Info: Current terminal monitor is off. <Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]int g0/0/0 [Huawei-GigabitEthernet0/0/0]ip add 12.0.0.2 24 [Huawei-GigabitEthernet0/0/0]int g0/0/1 [Huawei-GigabitEthernet0/0/1]ip add 24.0.0.2 24 [Huawei-GigabitEthernet0/0/1]int loop0 [Huawei-LoopBack0]ip add 2.2.2.2 32 [Huawei-LoopBack0]q [Huawei]ip route-static 1.1.1.1 32 12.0.0.1 [Huawei]ospf [Huawei-ospf-1]area 0 [Huawei-ospf-1-area-0.0.0.0]net 2.2.2.2 0.0.0.0 [Huawei-ospf-1-area-0.0.0.0]net 24.0.0.0 0.0.0.255 [Huawei-ospf-1-area-0.0.0.0]q [Huawei-ospf-1]q [Huawei]bgp 200 [Huawei-bgp]router-id 2.2.2.2 [Huawei-bgp]peer 1.1.1.1 as-number 100 [Huawei-bgp]peer 4.4.4.4 as-number 200 [Huawei-bgp]peer 3.3.3.3 as-number 200 [Huawei-bgp]peer 1.1.1.1 connect-interface LoopBack 0 [Huawei-bgp]peer 3.3.3.3 connect-interface LoopBack 0 [Huawei-bgp]peer 4.4.4.4 connect-interface LoopBack 0 [Huawei-bgp]peer 1.1.1.1 ebgp-max-hop 2 [Huawei-bgp]peer 3.3.3.3 next-hop-local [Huawei-bgp]peer 4.4.4.4 next-hop-local [Huawei-bgp]net 1.1.1.1 32 [Huawei-bgp]net 2.2.2.2 32 [Huawei-bgp]net 3.3.3.3 32 [Huawei-bgp]net 4.4.4.4 32R3
<Huawei>u t m Info: Current terminal monitor is off. <Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]int g0/0/1 [Huawei-GigabitEthernet0/0/1]ip add 13.0.0.3 24 [Huawei-GigabitEthernet0/0/1]int g0/0/0 [Huawei-GigabitEthernet0/0/0]ip add 34.0.0.3 24 [Huawei-GigabitEthernet0/0/0]int loop0 [Huawei-LoopBack0]ip add 3.3.3.3 32 [Huawei-LoopBack0]q [Huawei]ip route-static 1.1.1.1 32 13.0.0.1 [Huawei]ospf [Huawei-ospf-1]area 0 [Huawei-ospf-1-area-0.0.0.0]net 3.3.3.3 0.0.0.0 [Huawei-ospf-1-area-0.0.0.0]net 34.0.0.0 0.0.0.255 [Huawei-ospf-1-area-0.0.0.0]q [Huawei-ospf-1]q [Huawei]bgp 200 [Huawei-bgp]router-id 3.3.3.3 [Huawei-bgp]peer 1.1.1.1 as-number 100 [Huawei-bgp]peer 4.4.4.4 as-number 200 [Huawei-bgp]peer 2.2.2.2 as-number 200 [Huawei-bgp]peer 1.1.1.1 connect-interface LoopBack 0 [Huawei-bgp]peer 4.4.4.4 connect-interface LoopBack 0 [Huawei-bgp]peer 2.2.2.2 connect-interface LoopBack 0 [Huawei-bgp]peer 1.1.1.1 ebgp-max-hop 2 [Huawei-bgp]peer 4.4.4.4 next-hop-local [Huawei-bgp]peer 2.2.2.2 next-hop-local [Huawei-bgp]net 1.1.1.1 32 [Huawei-bgp]net 2.2.2.2 32 [Huawei-bgp]net 3.3.3.3 32 [Huawei-bgp]net 4.4.4.4 32R4
<Huawei>u t m Info: Current terminal monitor is off. <Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]int g0/0/0 [Huawei-GigabitEthernet0/0/0]ip add 34.0.0.4 24 [Huawei-GigabitEthernet0/0/0]int g0/0/1 [Huawei-GigabitEthernet0/0/1]ip add 24.0.0.4 24 [Huawei-GigabitEthernet0/0/1]int g0/0/2 [Huawei-GigabitEthernet0/0/2]ip add 45.0.0.4 24 [Huawei-GigabitEthernet0/0/2]int loop0 [Huawei-LoopBack0]ip add 4.4.4.4 32 [Huawei-LoopBack0]q [Huawei]ip route-static 5.5.5.5 32 45.0.0.5 [Huawei]ospf [Huawei-ospf-1]area 0 [Huawei-ospf-1-area-0.0.0.0]net 4.4.4.4 0.0.0.0 [Huawei-ospf-1-area-0.0.0.0]net 34.0.0.0 0.0.0.255 [Huawei-ospf-1-area-0.0.0.0]net 24.0.0.0 0.0.0.255 [Huawei-ospf-1-area-0.0.0.0]q [Huawei-ospf-1]q [Huawei]bgp 200 [Huawei-bgp]router-id 4.4.4.4 [Huawei-bgp]peer 2.2.2.2 as-number 200 [Huawei-bgp]peer 3.3.3.3 as-number 200 [Huawei-bgp]peer 5.5.5.5 as-number 300 [Huawei-bgp]peer 2.2.2.2 connect-interface LoopBack 0 [Huawei-bgp]peer 3.3.3.3 connect-interface LoopBack 0 [Huawei-bgp]peer 5.5.5.5 connect-interface LoopBack 0 [Huawei-bgp]peer 2.2.2.2 next-hop-local [Huawei-bgp]peer 3.3.3.3 next-hop-local [Huawei-bgp]peer 5.5.5.5 ebgp-max-hop 2 [Huawei-bgp]net 2.2.2.2 32 [Huawei-bgp]net 3.3.3.3 32 [Huawei-bgp]net 4.4.4.4 32 [Huawei-bgp]net 5.5.5.5 32R5
<Huawei>u t m Info: Current terminal monitor is off. <Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]int g 0/0/2 [Huawei-GigabitEthernet0/0/2]ip add 45.0.0.5 24 [Huawei-GigabitEthernet0/0/2]int loop0 [Huawei-LoopBack0]ip add 5.5.5.5 32 [Huawei-LoopBack0]q [Huawei]ip route-static 4.4.4.4 32 45.0.0.4 [Huawei]bgp 300 [Huawei-bgp]router-id 5.5.5.5 [Huawei-bgp]peer 4.4.4.4 as-number 200 [Huawei-bgp]peer 4.4.4.4 connect-interface LoopBack 0 [Huawei-bgp]peer 4.4.4.4 ebgp-max-hop 2 [Huawei-bgp]net 4.4.4.4 32 [Huawei-bgp]net 5.5.5.5 322、查看BGP路由表
R1
[Huawei]dis bgp routing-table BGP Local router ID is 1.1.1.1 Status codes: * - valid, > - best, d - damped,h - history, i - internal, s - suppressed, S - StaleOrigin : i - IGP, e - EGP, ? - incompleteTotal Number of Routes: 13Network NextHop MED LocPrf PrefVal Path/Ogn*> 1.1.1.1/32 0.0.0.0 0 0 i* 2.2.2.2 0 0 200i* 3.3.3.3 0 0 200i*> 2.2.2.2/32 0.0.0.0 0 0 i* 3.3.3.3 2 0 200i2.2.2.2 0 0 200i*> 3.3.3.3/32 0.0.0.0 0 0 i* 2.2.2.2 2 0 200i3.3.3.3 0 0 200i*> 4.4.4.4/32 2.2.2.2 1 0 200i* 3.3.3.3 1 0 200i*> 5.5.5.5/32 2.2.2.2 0 200i* 3.3.3.3 0 200iR4
[Huawei]dis bgp routing-table BGP Local router ID is 4.4.4.4 Status codes: * - valid, > - best, d - damped,h - history, i - internal, s - suppressed, S - StaleOrigin : i - IGP, e - EGP, ? - incompleteTotal Number of Routes: 14Network NextHop MED LocPrf PrefVal Path/Ogn*>i 1.1.1.1/32 2.2.2.2 0 100 0 i* i 3.3.3.3 0 100 0 i*> 2.2.2.2/32 0.0.0.0 1 0 i* i 3.3.3.3 2 100 0 ii 2.2.2.2 0 100 0 i*> 3.3.3.3/32 0.0.0.0 1 0 i* i 2.2.2.2 2 100 0 ii 3.3.3.3 0 100 0 i*> 4.4.4.4/32 0.0.0.0 0 0 i* i 2.2.2.2 1 100 0 i* i 3.3.3.3 1 100 0 i* 5.5.5.5 0 0 300i*> 5.5.5.5/32 0.0.0.0 0 0 i5.5.5.5 0 0 300i這時候,我們可以看到,從R1到R4走的是R2,R4到R1走的也是R2,我們需要擇路。
3、擇路(我們用兩種方式)
R1
[Huawei]route-policy as permit node 10 Info: New Sequence of this List. [Huawei-route-policy]apply as-path 123 123 additive [Huawei-route-policy]q [Huawei]bgp 100 [Huawei-bgp]peer 2.2.2.2 route-policy as import [Huawei-bgp]q [Huawei]q <Huawei>refresh bgp all importR3
[Huawei]route-policy lop permit node 10 Info: New Sequence of this List. [Huawei-route-policy]apply local-preference 222 [Huawei-route-policy]q [Huawei]bgp 200 [Huawei-bgp]peer 4.4.4.4 route-policy lop export [Huawei-bgp]q [Huawei]q <Huawei>refresh bgp all export4、刷新下BGP,再次查看擇路結果
R1
<Huawei>dis bgp routing-table BGP Local router ID is 1.1.1.1 Status codes: * - valid, > - best, d - damped,h - history, i - internal, s - suppressed, S - StaleOrigin : i - IGP, e - EGP, ? - incompleteTotal Number of Routes: 13Network NextHop MED LocPrf PrefVal Path/Ogn*> 1.1.1.1/32 0.0.0.0 0 0 i* 3.3.3.3 0 0 200i* 2.2.2.2 0 0 123 123 20 0i*> 2.2.2.2/32 0.0.0.0 0 0 i* 3.3.3.3 2 0 200i2.2.2.2 0 0 123 123 20 0i*> 3.3.3.3/32 0.0.0.0 0 0 i* 2.2.2.2 2 0 123 123 20 0i3.3.3.3 0 0 200i*> 4.4.4.4/32 3.3.3.3 1 0 200i* 2.2.2.2 1 0 123 123 20 0i*> 5.5.5.5/32 3.3.3.3 0 200i* 2.2.2.2 0 123 123 20 0iR4
[Huawei]dis bgp routing-tableBGP Local router ID is 4.4.4.4 Status codes: * - valid, > - best, d - damped,h - history, i - internal, s - suppressed, S - StaleOrigin : i - IGP, e - EGP, ? - incompleteTotal Number of Routes: 14Network NextHop MED LocPrf PrefVal Path/Ogn*>i 1.1.1.1/32 3.3.3.3 0 222 0 i* i 2.2.2.2 0 100 0 i*>i 2.2.2.2/32 3.3.3.3 2 222 0 i* 0.0.0.0 1 0 ii 2.2.2.2 0 100 0 i*> 3.3.3.3/32 0.0.0.0 1 0 i* i 2.2.2.2 2 100 0 ii 3.3.3.3 0 222 0 i*>i 4.4.4.4/32 3.3.3.3 1 222 0 i* 0.0.0.0 0 0 i* i 2.2.2.2 1 100 0 i* 5.5.5.5 0 0 300i*> 5.5.5.5/32 0.0.0.0 0 0 i5.5.5.5 0 0 300i5、結論
- 我們可以看到,我們改變了R3的local-preference為222之后,優(yōu)先級大于R2,然后對D4執(zhí)行了出站export策略,所以R4到R1的時候選擇了R3。
- 我們在R1對R2執(zhí)行了入站import策略,對R2已有的AS-path基礎上追加了123和123,使得優(yōu)先級低于R3,這樣,從R1到R4是,自然而然的選擇了R2這條線。
總結
以上是生活随笔為你收集整理的BGP小实验——选路不困难,只要有方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 双通道内存,性能提升大秘籍
- 下一篇: 内存山寨困扰?这牌子不容易