Local-pre属性(默认100)
BGP路由器通过不同的IBGP得到达到目的地址的多条路径,通过Local-pre属性的调整控制流量方向。(环路可能产生AS—Path可避免)
全局调整—调整全部经过的流量
Default local-preference 200(BGP进程中)
局部调整—调整特定的流量
拓扑:
实验目的:局部调整,r1到192.168.1.100的路由路径的改变.
配置:
r1
dis current-configuration
#
sysname r1
#
interface Serial0/0/1
link-protocol ppp
undo shutdown
ip address 202.1.1.1 255.255.255.252
#
interface Serial0/0/2
link-protocol ppp
undo shutdown
ip address 202.1.1.5 255.255.255.252
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
interface LoopBack100
#
bgp 100
router-id 1.1.1.1
peer 2.2.2.2 as-number 100
peer 2.2.2.2 connect-interface LoopBack0
peer 3.3.3.3 as-number 100
peer 3.3.3.3 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
import-route ospf 1
peer 2.2.2.2 enable
peer 2.2.2.2 route-policy loca-pre import
peer 3.3.3.3 enable
#
ospf 1
import-route bgp
area 0.0.0.0
network 1.1.1.1 0.0.0.0
network 202.1.1.0 0.0.0.3
network 202.1.1.4 0.0.0.3
#
route-policy loca-pre permit node 10
if-match ip-prefix loca-pre
apply local-preference 200
#
route-policy loca-pre permit node 20
#
ip ip-prefix loca-pre index 10 permit 192.168.1.100 32
#
user-interface con 0
user-interface vty 0 4
user-interface vty 16 20
#
r2
dis current-configuration
#
sysname r2
#
interface Serial0/0/0
link-protocol ppp
undo shutdown
ip address 202.1.1.9 255.255.255.252
#
interface Serial0/0/1
link-protocol ppp
undo shutdown
ip address 202.1.1.2 255.255.255.252
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
interface LoopBack100
#
bgp 100
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
peer 3.3.3.3 as-number 100
peer 3.3.3.3 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
import-route ospf 1
peer 1.1.1.1 enable
peer 3.3.3.3 enable
#
ospf 1
import-route bgp
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 202.1.1.0 0.0.0.3
network 202.1.1.8 0.0.0.3
network 192.168.1.1 0.0.0.0
network 192.168.1.100 0.0.0.0
#
r3
dis current-configuration
#
sysname r3
#
interface Serial0/0/0
link-protocol ppp
undo shutdown
ip address 202.1.1.10 255.255.255.252
#
interface Serial0/0/2
link-protocol ppp
undo shutdown
ip address 202.1.1.6 255.255.255.252
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
interface LoopBack100
ip address 192.168.1.100 255.255.255.255
#
bgp 100
router-id 3.3.3.3
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
peer 2.2.2.2 as-number 100
peer 2.2.2.2 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
import-route ospf 1
peer 1.1.1.1 enable
peer 2.2.2.2 enable
#
ospf 1
import-route bgp
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 202.1.1.4 0.0.0.3
network 202.1.1.8 0.0.0.3
network 192.168.1.100 0.0.0.0
#
R1查看
开始前
[r1-bgp]dis bgp routing-table
BGP 本地路由器标识符: 1.1.1.1
路由状态代码: * 有效路由, > 最佳路由, d 振荡抑制,
h 历史路由, i 内部路由, s 聚合抑制, S 过时路由
Origin 类型代码: i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 21
Network Next Hop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.1/32 0.0.0.0 0 0 ?
* i 2.2.2.2 1562 100 0 ?
* i 3.3.3.3 1562 100 0 ?
*> 2.2.2.2/32 0.0.0.0 1562 0 ?
* i 3.3.3.3 1562 100 0 ?
i 2.2.2.2 0 100 0 ?
*> 3.3.3.3/32 0.0.0.0 1562 0 ?
* i 2.2.2.2 1562 100 0 ?
i 3.3.3.3 0 100 0 ?
*> 192.168.1.100/32 0.0.0.0 1562 0 ?
* i 3.3.3.3 0 100 0 ?
* i 2.2.2.2 1562 100 0 ?
*> 202.1.1.0/30 0.0.0.0 0 0 ?
* i 2.2.2.2 0 100 0 ?
* i 3.3.3.3 3124 100 0 ?
*> 202.1.1.4/30 0.0.0.0 0 0 ?
* i 3.3.3.3 0 100 0 ?
* i 2.2.2.2 3124 100 0 ?
*> 202.1.1.8/30 0.0.0.0 3124 0 ?
* i 2.2.2.2 0 100 0 ?
* i 3.3.3.3 0 100 0 ?
[r1-bgp]
调整Local-pre
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-Stale
Origin : i -IGP, e-EGP, ? -incomplete
Total Number of Routes: 21
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.1/32 0.0.0.0 0 0 ?
* i 2.2.2.2 1562 100 0 ?
* i 3.3.3.3 1562 100 0 ?
*> 2.2.2.2/32 0.0.0.0 1562 0 ?
* i 3.3.3.3 1562 100 0 ?
i 2.2.2.2 0 100 0 ?
*> 3.3.3.3/32 0.0.0.0 1562 0 ?
* i 2.2.2.2 1562 100 0 ?
i 3.3.3.3 0 100 0 ?
*>i 192.168.1.100/32 2.2.2.2 1562 200 0 ?
* 0.0.0.0 1562 0 ?
* i 3.3.3.3 0 100 0 ?
*> 202.1.1.0/30 0.0.0.0 0 0 ?
* i 2.2.2.2 0 100 0 ?
* i 3.3.3.3 3124 100 0 ?
*> 202.1.1.4/30 0.0.0.0 0 0 ?
* i 3.3.3.3 0 100 0 ?
* i 2.2.2.2 3124 100 0 ?
*> 202.1.1.8/30 0.0.0.0 3124 0 ?
* i 2.2.2.2 0 100 0 ?
* i 3.3.3.3 0 100 0 ?
R1路由器略配置命令
[r1]ip ip-prefix loca-pre permit 192.168.1.100 32
[r1]route-policy loca-pre permit node 10
[r1-route-policy]if-match ip-prefix loac-pre
[r1-route-policy]apply local-preference 200
[r1]route-policy loca-pre permit node 20
[r1-bgp]peer 2.2.2.2 route-policy loca-pre import