4.1 优选Prefval值更高路由
Prefval值缺省为0,仅本地有效,不传递,Prefval值越大越优先。
1.R1配置OSPF
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]network 12.1.1.0 0.255.255.255
2.R2配置OSPF
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[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]network 12.1.1.0 0.255.255.255
3.R1配置IBGP、EBGP
[R1]bgp 12
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 2.2.2.2 as-number 12
[R1-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[R1-bgp]peer 2.2.2.2 next-hop-local
[R1-bgp]peer 13.1.1.3 as-number 300
4.R2配置IBGP、EBGP
[R2]bgp 12
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 1.1.1.1 as-number 12
[R2-bgp]peer 1.1.1.1 connect-interface LoopBack 0
[R2-bgp]peer 1.1.1.1 next-hop-local
[R2-bgp]peer 23.1.1.3 as-number 300
5.R3配置EBGP,宣告3.3.3.3/32到BGP
[R3]bgp 300
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 13.1.1.1 as-number 12
[R3-bgp]peer 23.1.1.2 as-number 12
[R3-bgp]network 3.3.3.3 32
6.R3查看BGP路由表,PrefVal=0
[R3]display bgp routing-table
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 3.3.3.3/32 0.0.0.0 0 0 i
7.R1查看BGP路由表,均为PrefVal=0
[R1]display bgp routing-table
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 3.3.3.3/32 13.1.1.3 0 0 300i
* i 2.2.2.2 0 100 0 300i
8.修改PrefVal值,查看BGP路由表,根据PrefVal值更大原则选择R2路由
[R1]bgp 12
[R1-bgp]peer 2.2.2.2 preferred-value 1000
[R1]display bgp routing-table
*>i 3.3.3.3/32 2.2.2.2 0 100 1000 300i
* 13.1.1.3 0 0 300i
[R1]display bgp routing-table 3.3.3.3
BGP local router ID : 1.1.1.1
Local AS number : 12
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 3.3.3.3/32:
From: 2.2.2.2 (2.2.2.2)
Route Duration: 00h01m13s
Relay IP Nexthop: 12.1.1.2
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 2.2.2.2
Qos information : 0x0
AS-path 300, origin igp, MED 0, localpref 100, pref-val 1000, valid, internal, best, select, active, pre 255, IGP cost 1
Advertised to such 1 peers:
13.1.1.3
BGP routing table entry information of 3.3.3.3/32:
From: 13.1.1.3 (3.3.3.3)
Route Duration: 00h05m15s
Direct Out-interface: GigabitEthernet0/0/2
Original nexthop: 13.1.1.3
Qos information : 0x0
AS-path 300, origin igp, MED 0, pref-val 0, valid, external, pre 255, not preferred for PreVal
Not advertised to any peer yet
9.针对邻居学来的某些路由,根据策略修改PrefVal
(直接修改PrefVal值会使得所有学习过来的路由值均为修改值(1000),不精确)
[R1]ip ip-prefix dsrw.com permit 3.3.3.3 32
[R1]route-policy dsrw permit node 10
[R1-route-policy]if-match ip-prefix dsrw.com
[R1-route-policy]apply preferred-value 200
[R1]route-policy dsrw permit node 20
[R1]bgp 12
[R1-bgp]peer 2.2.2.2 route-policy dsrw import
[R1-bgp]quit
[R1]quit
<R1>refresh bgp all import
<R1>display bgp routing-table
*>i 3.3.3.3/32 2.2.2.2 0 100 200 300i
* 13.1.1.3 0 0 300i
<R1>display bgp routing-table 3.3.3.3
BGP local router ID : 1.1.1.1
Local AS number : 12
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 3.3.3.3/32:
From: 2.2.2.2 (2.2.2.2)
Route Duration: 00h02m38s
Relay IP Nexthop: 12.1.1.2
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 2.2.2.2
Qos information : 0x0
AS-path 300, origin igp, MED 0, localpref 100, pref-val 200, valid, internal, best, select, active, pre 255, IGP cost 1
Advertised to such 1 peers:
13.1.1.3
BGP routing table entry information of 3.3.3.3/32:
From: 13.1.1.3 (3.3.3.3)
Route Duration: 00h02m38s
Direct Out-interface: GigabitEthernet0/0/2
Original nexthop: 13.1.1.3
Qos information : 0x0
AS-path 300, origin igp, MED 0, pref-val 0, valid, external, pre 255, not preferred for PreVal
Not advertised to any peer yet
10.R3新增环回口IP地址,宣告进BGP,R1观察BGP路由
[R3]interface LoopBack 1
[R3-LoopBack1]ip address 3.3.1.1 32
[R3]bgp 300
[R3-bgp]network 3.3.1.1 32
<R1>display bgp routing-table
*>i 3.3.1.1/32 2.2.2.2 0 100 1000 300i
* 13.1.1.3 0 0 300i
*>i 3.3.3.3/32 2.2.2.2 0 100 200 300i
* 13.1.1.3 0 0 300i
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
请登录后查看评论内容