设为首页收藏本站language 语言切换
查看: 2746|回复: 2
收起左侧

[原创] 通过as-path属性进行BGP选路原则

[复制链接]
发表于 2015-12-28 11:16:35 | 显示全部楼层 |阅读模式
通过AS-path属性来影响选路原则
实验拓扑:
捕获.PNG


先在R4上查看BGP路由表:
[R4]display bgp routing-table

BGP Local router ID is 10.0.34.4
Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete


Total Number of Routes: 4
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

*>   1.1.1.1/32         10.0.24.2                             0      200   100i
*                            10.0.34.3                             0      200   100i
*>   11.1.1.1/32        10.0.24.2                             0      200   100i
*                             10.0.34.3                             0      200   100i
从上面可以发现,R1上的路由1.1.1.1/32和11.1.1.1/32都是经过R2到达R4的,现在为了让1.1.1.1/32经过R3到达R4.为此我们可以增加AS-path属性来进行选路。
实验步骤:
[R2]acl number 2001
[R2-acl-basic-2001]rule 5 permit source 1.1.1.1 0.0.0.255
[R2-acl-basic-2001]route-policy as-path permit node 10
[R2-route-policy]if-match acl 2001
[R2-route-policy]apply as-path 200 200 additive //增加两个AS号
[R2-route-policy]quit
[R2]bgp 200
[R2-bgp]peer 10.0.24.4 route-policy as-path export //因为我们是为了增加1.1.1.1/32的属性,而10.0.24.2是1.1.1.1/32的下一跳,因此我们应该在R2上进行as-path的配置。一般都是通过增加as-path的长度来进行选路原则,为了出现问题,一般都是增加相同的AS号,如本例中as-path是200,增加的as号也是200.
现在重新查看R4的BGP路由表:
[R4]display bgp routing-table

BGP Local router ID is 10.0.34.4
Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete


Total Number of Routes: 3
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

*>   1.1.1.1/32         10.0.34.3                                      0      200 100i
*                            10.0.24.2                                      0      200 200 200 100i
*>   11.1.1.1/32        10.0.34.3                                      0      200 100i
从上面可以看出,R4去往1.1.1.1/32的路由从R3去往R1.而非R2.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
下面是给路由器的配置:
R4:
[R4]dis current-configuration
[V200R003C00]
#
sysname R4
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
drop illegal-mac alarm
#
wlan ac-global carrier id other ac id 0
#
set cpu-usage threshold 80 restore 75
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
local-user admin service-type http
#
firewall zone Local
priority 15
#
interface GigabitEthernet0/0/0
ip address 10.0.34.4 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 10.0.24.4 255.255.255.0
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
#
bgp 300
peer 10.0.24.2 as-number 200
peer 10.0.34.3 as-number 200
#
ipv4-family unicast
  undo synchronization
  peer 10.0.24.2 enable
  peer 10.0.34.3 enable
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return

R3:
[R3]display current-configuration
[V200R003C00]
#
sysname R3
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
drop illegal-mac alarm
#
router id 3.3.3.3
#
wlan ac-global carrier id other ac id 0
#
set cpu-usage threshold 80 restore 75
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
local-user admin service-type http
#
firewall zone Local
priority 15
#
interface GigabitEthernet0/0/0
ip address 10.0.34.3 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 10.0.13.3 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 10.0.23.3 255.255.255.0
#
interface NULL0
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
bgp 200
peer 2.2.2.2 as-number 200
peer 2.2.2.2 connect-interface LoopBack0
peer 10.0.13.1 as-number 100
peer 10.0.34.4 as-number 300
#
ipv4-family unicast
  undo synchronization
  peer 2.2.2.2 enable
  peer 2.2.2.2 next-hop-local
  peer 10.0.13.1 enable
  peer 10.0.34.4 enable
#
ospf 100
area 0.0.0.0
  network 3.3.3.0 0.0.0.255
  network 10.0.23.0 0.0.0.255
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return

R2:
[R2]display current-configuration
[V200R003C00]
#
sysname R2
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
drop illegal-mac alarm
#
router id 2.2.2.2
#
wlan ac-global carrier id other ac id 0
#
set cpu-usage threshold 80 restore 75
#
acl number 2001  
rule 5 permit source 1.1.1.0 0.0.0.255
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
local-user admin service-type http
#
firewall zone Local
priority 15
#
interface GigabitEthernet0/0/0
ip address 10.0.12.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 10.0.24.2 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 10.0.23.2 255.255.255.0
#
interface NULL0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
bgp 200
peer 3.3.3.3 as-number 200
peer 3.3.3.3 connect-interface LoopBack0
peer 10.0.12.1 as-number 100
peer 10.0.24.4 as-number 300
#
ipv4-family unicast
  undo synchronization
  peer 3.3.3.3 enable
  peer 3.3.3.3 next-hop-local
  peer 10.0.12.1 enable
  peer 10.0.24.4 enable
  peer 10.0.24.4 route-policy as-path export
#
ospf 100
area 0.0.0.0
  network 2.2.2.0 0.0.0.255
  network 10.0.23.0 0.0.0.255
#
route-policy as-path permit node 10
if-match acl 2001
apply as-path 200 200 additive
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return

R1:
[R1]dis current-configuration
[V200R003C00]
#
sysname R1
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
drop illegal-mac alarm
#
wlan ac-global carrier id other ac id 0
#
set cpu-usage threshold 80 restore 75
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
local-user admin service-type http
#
firewall zone Local
priority 15
#
interface GigabitEthernet0/0/0
ip address 10.0.12.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 10.0.13.1 255.255.255.0
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
interface LoopBack2
ip address 11.1.1.1 255.255.255.255
#
bgp 100
peer 10.0.12.2 as-number 200
peer 10.0.13.3 as-number 200
#
ipv4-family unicast
  undo synchronization
  network 1.1.1.1 255.255.255.255
  network 11.1.1.1 255.255.255.255
  peer 10.0.12.2 enable
  peer 10.0.13.3 enable
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return



发表于 2015-12-28 11:40:09 | 显示全部楼层
不懂华为的路过
沙发 2015-12-28 11:40:09 回复 收起回复
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-12-28 12:02:20 | 显示全部楼层

我也是刚刚学习,感觉有些地方不懂或者不清楚的地方,就发发帖子,大家来学习
板凳 2015-12-28 12:02:20 回复 收起回复
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2025-2-10 08:59 , Processed in 0.073582 second(s), 17 queries , Redis On.  

  Powered by Discuz!

  © 2001-2025 HH010.COM

快速回复 返回顶部 返回列表