- 积分
- 646
- 鸿鹄币
- 个
- 好评度
- 点
- 精华
- 注册时间
- 2015-3-24
- 最后登录
- 1970-1-1
- 阅读权限
- 40
- 听众
- 收听
中级工程师
|
通过AS-path属性来影响选路原则
实验拓扑:
先在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
|
|