1、网络拓扑图

BGP 之公认任意local-preference(复习)_Time

2、属性描述

1)可以通过bgp default 1ocal-preference命令修改缺省Local Preference值

2)可以在AS边界路由器上使用|mport方向或export方向的策略来修改Local Preference属性值

3)Local Preference缺省值为100

4)取值越大越优先

3、详细配置

R1:

<r1>display 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 portalpage.zip

#

drop illegal-mac alarm

#

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.1.1.1 255.255.255.0  

#

interface GigabitEthernet0/0/1

ip address 20.1.1.1 255.255.255.0  

#

interface GigabitEthernet0/0/2

#

interface NULL0

#

interface LoopBack0

ip address 1.1.1.1 255.255.255.255  

#

interface LoopBack1

ip address 192.168.1.1 255.255.255.0  

#

interface LoopBack2

ip address 192.168.2.1 255.255.255.0  

#

bgp 100

router-id 1.1.1.1

peer 10.1.1.2 as-number 200  

peer 10.1.1.2 connect-interface GigabitEthernet0/0/0

peer 20.1.1.2 as-number 200  

peer 20.1.1.2 connect-interface GigabitEthernet0/0/1

#

ipv4-family unicast

 undo synchronization

 network 192.168.1.0  

 network 192.168.2.0  

 peer 10.1.1.2 enable

 peer 20.1.1.2 enable

#

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 portalpage.zip

#

drop illegal-mac alarm

#

set cpu-usage threshold 80 restore 75

#

acl number 2000  

rule 5 permit source 192.168.1.0 0.0.0.255  

acl number 2001  

rule 5 permit source 192.168.2.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.1.1.2 255.255.255.0  

#

interface GigabitEthernet0/0/1

ip address 30.1.1.1 255.255.255.0  

#

interface GigabitEthernet0/0/2

#

interface NULL0

#

interface LoopBack0

ip address 2.2.2.2 255.255.255.255  

#

bgp 200

router-id 2.2.2.2

peer 3.3.3.3 as-number 200  

peer 3.3.3.3 connect-interface LoopBack0

peer 4.4.4.4 as-number 200  

peer 4.4.4.4 connect-interface LoopBack0

peer 10.1.1.1 as-number 100  

peer 10.1.1.1 connect-interface GigabitEthernet0/0/0

#

ipv4-family unicast

 undo synchronization

 peer 3.3.3.3 enable

 peer 3.3.3.3 route-policy p1 export

 peer 3.3.3.3 next-hop-local  

 peer 4.4.4.4 enable

 peer 4.4.4.4 next-hop-local  

 peer 10.1.1.1 enable

#

ospf 100 router-id 2.2.2.2  

area 0.0.0.0  

 network 2.2.2.2 0.0.0.0  

 network 30.1.1.0 0.0.0.255  

#

route-policy p1 permit node 10  

if-match acl 2000  

apply local-preference 200  

#

route-policy p1 permit node 20  

if-match acl 2001  

apply local-preference 150  

#

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 portalpage.zip

#

drop illegal-mac alarm

#

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 30.1.1.2 255.255.255.0  

#

interface GigabitEthernet0/0/1

ip address 40.1.1.2 255.255.255.0  

#

interface GigabitEthernet0/0/2

#

interface NULL0

#

interface LoopBack0

ip address 3.3.3.3 255.255.255.255  

#

interface LoopBack1

ip address 172.16.1.1 255.255.255.0  

#

bgp 200

router-id 3.3.3.3

peer 2.2.2.2 as-number 200  

peer 2.2.2.2 connect-interface LoopBack0

peer 4.4.4.4 as-number 200  

peer 4.4.4.4 connect-interface LoopBack0

#

ipv4-family unicast

 undo synchronization

 network 172.16.1.0 255.255.255.0  

 peer 2.2.2.2 enable

 peer 4.4.4.4 enable

#

ospf 100 router-id 3.3.3.3  

area 0.0.0.0  

 network 3.3.3.3 0.0.0.0  

 network 30.1.1.0 0.0.0.255  

 network 40.1.1.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

R4:

<r4>display 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 portalpage.zip

#

drop illegal-mac alarm

#

set cpu-usage threshold 80 restore 75

#

acl number 2000  

rule 5 permit source 192.168.1.0 0.0.0.255  

acl number 2001  

rule 5 permit source 192.168.2.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 20.1.1.2 255.255.255.0  

#

interface GigabitEthernet0/0/1

ip address 40.1.1.1 255.255.255.0  

#

interface GigabitEthernet0/0/2

#

interface NULL0

#

interface LoopBack0

ip address 4.4.4.4 255.255.255.255  

#

bgp 200

router-id 4.4.4.4

peer 2.2.2.2 as-number 200  

peer 2.2.2.2 connect-interface LoopBack0

peer 3.3.3.3 as-number 200  

peer 3.3.3.3 connect-interface LoopBack0

peer 20.1.1.1 as-number 100  

peer 20.1.1.1 connect-interface GigabitEthernet0/0/0

#

ipv4-family unicast

 undo synchronization

 peer 2.2.2.2 enable

 peer 2.2.2.2 next-hop-local  

 peer 3.3.3.3 enable

 peer 3.3.3.3 route-policy p1 export

 peer 3.3.3.3 next-hop-local  

 peer 20.1.1.1 enable

#

ospf 100 router-id 4.4.4.4  

area 0.0.0.0  

 network 4.4.4.4 0.0.0.0  

 network 40.1.1.0 0.0.0.255  

#

route-policy p1 permit node 10  

if-match acl 2000  

apply local-preference 150  

#

route-policy p1 permit node 20  

if-match acl 2001  

apply local-preference 200  

#

user-interface con 0

authentication-mode password

user-interface vty 0 4

user-interface vty 16 20

#

wlan ac

#

return

4、测试结果

BGP 之公认任意local-preference(复习)_Time_02