华为ensp_BGP_local-prefernce;AS-Path;MeD 实验

3种选路:
1.local——prefernec
2.AS_PAH 
3.MED 在这里插入图片描述

R1:
<Huawei>u t m 
Info: Current terminal monitor is off.
<Huawei>sys 
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sys 
[Huawei]sysname R1
[R1]us 
[R1]user-int 
[R1]user-interface co 
[R1]user-interface console 0
[R1-ui-console0]id 
[R1-ui-console0]idle-timeout 0 0
[R1-ui-console0]q
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 12.0.0.0 24
[R1-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 13.0.0.1 24
[R1-GigabitEthernet0/0/1]int loop 0 
[R1-LoopBack0]ip add 1.1.1.1 32
[R1-LoopBack0]q
[R1]bgp 100
[R1-bgp]peer 
[R1-bgp]peer 1.1.1.1 advertise-community
[R1-bgp]peer 1.1.1.1 advertise-ext-community
[R1-bgp]peer 1.1.1.1 as-number 200
Warning: Local interface is already configured with this address.
[R1-bgp]peer 2.2.2.2 as-number 200
[R1-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[R1-bgp]peer 2.2.2.2 next-hop-invariable
[R1-bgp]peer 2.2.2.2 ebgp-max-hop 2
[R1-bgp]peer 3.3.3.3 as-path-filter
[R1-bgp]peer 3.3.3.3 as-number 200
[R1-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[R1-bgp]peer 3.3.3.3 ebgp-max-hop 2
[R1-bgp]q
[R1]ip route-static 2.2.2.2 32 12.0.0.2
[R1]ip route-static 3.3.3.3 32 13.0.0.3
[R1]bgp 100
[R1-bgp]network 2.2.2.2 32
[R1-bgp]network 1.1.1.1 32
[R1-bgp]network 3.3.3.3 32
R2:
<Huawei>u t m 
Info: Current terminal monitor is off.
<Huawei>sys 
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sys 
[Huawei]sysname R2
[R2]us 
[R2]user-int 
[R2]user-interface co 
[R2]user-interface console 0
[R2-ui-console0]id 
[R2-ui-console0]idle-timeout 0 0
[R2-ui-console0]q
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 24.0.0.2 24
[R2-GigabitEthernet0/0/1]int loop 0
[R2-LoopBack0]ip add 2.2.2.2 32
[R2-LoopBack0]q
[R2]osp 
[R2]ospf 1
R2-ospf-1]are 0
[R2-ospf-1-area-0.0.0.0]net 
[R2-ospf-1-area-0.0.0.0]network 24.0.0.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]ne 
[R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]q
[R2-ospf-1]bgp 200
[R2-bgp]peer 1.1.1.1 as-number 100
R2-bgp]peer 1.1.1.1 connect-interface LoopBack 0
[R2-bgp]peer 1.1.1.1 ebgp-max-hop 2
[R2-bgp]peer 4.4.4.4 as-number 200
[R2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[R2-bgp]peer 4.4.4.4 next-hop-invariable
[R2-bgp]peer 4.4.4.4 next-hop-local
[R2-bgp]peer 3.3.3.3 as-number 200
[R2-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[R2-bgp]peer 3.3.3.3 next-hop-invariable
[R2-bgp]peer 3.3.3.3 next-hop-local
[R2-bgp]q[R2]ip route-static 1.1.1.1 32 12.0.0.1
[R2]bgp 200
[R2-bgp]net 
[R2-bgp]network 1.1.1.1 32
R2-bgp]network 2.2.2.2 32
[R2-bgp]network 4.4.4.4 32
[R2-bgp]network 3.3.3.3 32
R3:
<Huawei>u t m 
Info: Current terminal monitor is off.
<Huawei>sys 
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sys 
[Huawei]sysname R3
[R3]us 
[R3]user-int 
[R3]user-interface co 
[R3]user-interface console 0
[R3-ui-console0]id 
[R3-ui-console0]idle-timeout 0 0
[R3-ui-console0]q
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 13.0.0.3 24
[R3-GigabitEthernet0/0/1]int g0/0/0
R3-GigabitEthernet0/0/0]ip add 34.0.0.3 24
[R3-GigabitEthernet0/0/0]int loop 0
[R3-LoopBack0]ip add 3.3.3.3 32
[R3-LoopBack0]
[R3-LoopBack0]q
[R3]os 
[R3]ospf 1
[R3-ospf-1]are 
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 34.0.0.0 0.0.0.255
[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]bgp 200
[R3-bgp]peer 1.1.1.1 as-number 100
[R3-bgp]peer 1.1.1.1 connect-interface LoopBack  0
[R3-bgp]peer 1.1.1.1 ebgp-max-hop 2
[R3-bgp]peer 2.2.2.2 as-number 200
[R3-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[R3-bgp]peer 2.2.2.2 next-hop-invariable
[R3-bgp]peer 2.2.2.2 next-hop-local
[R3-bgp]peer 4.4.4.4 as-number 200
[R3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[R3-bgp]peer 4.4.4.4 next-hop-local
[R3-bgp]q
[R3]ip route-static 1.1.1.1 32 13.0.0.1
[R3]bgp 200
[R3-bgp]network 1.1.1.1 32
[R3-bgp]network 2.2.2.2 32
[R3-bgp]network 3.3.3.3 32
[R3-bgp]network 4.4.4.4 32
R4:
<Huawei>u t m 
Info: Current terminal monitor is off.
<Huawei>sys 
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sys 
[Huawei]sysname R4
[R4]us 
[R4]user-int 
[R4]user-interface co 
[R4]user-interface console 0
[R4-ui-console0]id 
[R4-ui-console0]idle-timeout 0 0
[R4-ui-console0]q
[R4]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 24.0.0.4 24
[R4-GigabitEthernet0/0/1]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 34.0.0.4 24
[R4-GigabitEthernet0/0/0]int loop 0
[R4-LoopBack0]ip add 4.4.4.4 32
[R4-LoopBack0]
[R4-LoopBack0]q
[R4]os 
[R4]ospf 1
[R4-ospf-1]are 
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 24.0.0.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[R4-ospf-1-area-0.0.0.0]network 34.0.0.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]bgp 200
[R4-bgp]peer 2.2.2.2 as 
[R4-bgp]peer 2.2.2.2 as-number 200
R4-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[R4-bgp]peer 2.2.2.2 next-hop-local
[R4-bgp]peer 3.3.3.3 as-number 200
[R4-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[R4-bgp]peer 3.3.3.3 next-hop-local
[R4-bgp]peer 5.5.5.5 as-number 3004-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[R4-bgp]peer 5.5.5.5 e 
R4-bgp]peer 5.5.5.5 ebgp-max-hop 2
[R4-bgp]
[R4-bgp]q
[R4]ip ro 
[R4]ip route-static
[R4]ip route
[R4]ip route-static 5.5.5.5 32 45.0.0.5
[R4]bgp 200
[R4-bgp]net 
[R4-bgp]network 2.2.2.2 32
[R4-bgp]network 3.3.3.3 32
[R4-bgp]network 4.4.4.4 32
[R4-bgp]network 5.5.5.5 32
Info: The network does not exist.
[R4-bgp]q
[R4]int g0/0/2
[R4-GigabitEthernet0/0/2]ip add 45.0.0.4 24
[R4-GigabitEthernet0/0/2]q
[R4]bgp 200
[R4-bgp]net 
[R4-bgp]network 5.5.5.5 32
R5:
<Huawei>u t m 
Info: Current terminal monitor is off.
<Huawei>sys 
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sys 
[Huawei]sysname R5
[R5]us 
[R5]user-int 
[R5]user-interface co 
[R5]user-interface console 0
[R5-ui-console0]id 
[R5-ui-console0]idle-timeout 0 0
[R5-ui-console0]q
[R5]int g0/0/2
[R5-GigabitEthernet0/0/2]ip add 45.0.0.5 24
[R5-GigabitEthernet0/0/2]int loop 0
[R5-LoopBack0]ip add 5.5.5.5 32
[R5-LoopBack0]
[R5-LoopBack0]q
[R5]bgp 300
[R5-bgp]peer 4.4.4.4 as-number 200
R5-bgp]peer 4.4.4.4 connect-interface LoopBack 0 
[R5-bgp]peer 4.4.4.4 ebgp-max-hop 2
5]ip route-static 4.4.4.4 32 45.0.0.4
[R5]bgp 300
[R5-bgp]network 4.4.4.4 32
[R5-bgp]network 5.5.5.5 32

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

**RPG选路:local——prefernce IBGP之间传递(越大越优先)**
R4从R1路径:从2走到1.现在改为从3走到1:
在R4中设置:
route-policy lop permit node 10
[R4-route-policy]apply local-preference 222
[R4-route-policy]q
[R4]bgp 200
R4-bgp]peer 3.3.3.3 route-policy lop import 
[R4]q
<R4>re 
<R4>refresh bgp all im 
<R4>refresh bgp all import 

因为路径是R4————R3————R1.因为是越大越优先,因为在R4中配置,路径从R3—R4,所以是Import,

再查看dis BGP routing-table:

在这里插入图片描述

AS——PATH 用于IBDG,EBDG长度越少越优

在这里插入图片描述

在R1中查询路径:目前路径为42.想改为43  最后到1.
因为长度是越少越优,指令是添加长度,所以在R2 或者R1中配置
选择R2中配置:
[R2]rou 
[R2]route
[R2]route-policy as 
[R2]route-policy as p 
[R2]route-policy as permit nod 
[R2]route-policy as permit node 10
Info: New Sequence of this List.
[R2-route-policy]app 
[R2-route-policy]apply as 
[R2-route-policy]apply as-path 123 123 add 
[R2-route-policy]apply as-path 123 123 additive 
[R2-route-policy]q
[R2]bgp 200
[R2-bgp]peer 1.1.1.1 p 
[R2-bgp]peer 1.1.1.1 password
[R2-bgp]peer 1.1.1.1 r 
[R2-bgp]peer 1.1.1.1 route-policy as e 
[R2-bgp]peer 1.1.1.1 route-policy as export 
[R2-bgp]q
[R2]q
<R2>re 
<R2>reboot
<R2>refresh bgp all e 
<R2>refresh bgp all export 

配置完,在R1中查表:
在这里插入图片描述
因为路径是R4----R2 ------R1,路径是从R2到R1,从R2出站,R1进站,因在R2中设置所以为出站:export

MED:可选非传递属性,EBGP传递,(越小越优先)
要求R1 从4---3,现在是4---2

在这里插入图片描述

路径是从R4——R2——R1,现在要改为R4——R3——R1,因为路径是从R1---R 2,在R1上配,路径再从R1----R2     就是在R1中配置,R1就是import

R1:
R1]rou 
[R1]route
[R1]route-policy me 
[R1]route-policy med 
[R1]route-policy med per 
[R1]route-policy med permit no 
[R1]route-policy med permit node 10
Info: New Sequence of this List.
-route-policy]apply cost + 500
[R1-route-policy]q
[R1]bgp 100
R1-bgp]peer 2.2.2.2 route-policy med import 
q
<R1>ref 
<R1>refresh bgp all im 
<R1>refresh bgp all import 

因为越小越优先,要求是从3走,所以把R2上的数值加大:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Wsxyi/article/details/112650196
今日推荐