1、网络拓扑图

BGP的各种属性_ci

2、属性配置

1)preferred-value(私有属性,本地有效)

peer 2.2.2.2 preferred-value 0-65535//越大越优先

2)local_pref属性:本地优先级

apply local-pref 101//越大越优先

3)as-path

apply as-path 10 20 30 additive

4)Origin的起源

i

e

?

5)MED属性

apply cost 100

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

ip address 192.168.1.1 255.255.255.0  

#

interface NULL0

#

interface LoopBack0

ip address 1.1.1.1 255.255.255.255  

#

bgp 1

router-id 1.1.1.1

undo default ipv4-unicast

peer 2.2.2.2 as-number 1  

peer 2.2.2.2 connect-interface LoopBack0

peer 3.3.3.3 as-number 1  

peer 3.3.3.3 connect-interface LoopBack0

#

ipv4-family unicast

 undo synchronization

 network 192.168.1.0  

 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 next-hop-local  

#

ospf 100 router-id 1.1.1.1  

area 0.0.0.0  

 network 1.1.1.1 0.0.0.0  

 network 10.1.1.0 0.0.0.255  

 network 20.1.1.0 0.0.0.255  

#

user-interface con 0

authentication-mode password

idle-timeout 0 0

user-interface vty 0 4

user-interface vty 16 20

#

wlan ac

#

return

[r1]

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 2001  

rule 5 permit source 192.168.2.0 0.0.0.255  

rule 10 deny  

#

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 1

router-id 2.2.2.2

undo default ipv4-unicast

peer 1.1.1.1 as-number 1  

peer 1.1.1.1 connect-interface LoopBack0

peer 3.3.3.3 as-number 1  

peer 3.3.3.3 connect-interface LoopBack0

peer 30.1.1.2 as-number 2  

#

ipv4-family unicast

 undo synchronization

 peer 1.1.1.1 enable

 peer 1.1.1.1 next-hop-local  

 peer 3.3.3.3 enable

 peer 3.3.3.3 next-hop-local  

 peer 30.1.1.2 enable

 peer 30.1.1.2 route-policy gd import

#

ospf 100 router-id 2.2.2.2  

area 0.0.0.0  

 network 2.2.2.2 0.0.0.0  

 network 10.1.1.0 0.0.0.255  

#

route-policy gd permit node 10  

if-match acl 2001  

apply as-path 10 20 30 additive

apply local-preference 101  

#

user-interface con 0

authentication-mode password

idle-timeout 0 0

user-interface vty 0 4

user-interface vty 16 20

#

wlan ac

#

return

[r2]

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 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 3.3.3.3 255.255.255.255  

#

bgp 1

router-id 3.3.3.3

peer 1.1.1.1 as-number 1  

peer 1.1.1.1 connect-interface LoopBack0

peer 2.2.2.2 as-number 1  

peer 2.2.2.2 connect-interface LoopBack0

peer 40.1.1.2 as-number 2  

#

ipv4-family unicast

 undo synchronization

 peer 1.1.1.1 enable

 peer 1.1.1.1 next-hop-local  

 peer 2.2.2.2 enable

 peer 2.2.2.2 next-hop-local  

 peer 40.1.1.2 enable

#

ospf 100 router-id 3.3.3.3  

area 0.0.0.0  

 network 3.3.3.3 0.0.0.0  

 network 20.1.1.0 0.0.0.255  

#

user-interface con 0

authentication-mode password

idle-timeout 0 0

user-interface vty 0 4

user-interface vty 16 20

#

wlan ac

#

return

[r3]

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

#

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

ip address 192.168.2.1 255.255.255.0  

#

interface NULL0

#

interface LoopBack0

ip address 4.4.4.4 255.255.255.255  

#

bgp 2

router-id 4.4.4.4

undo default ipv4-unicast

peer 30.1.1.1 as-number 1  

peer 40.1.1.1 as-number 1  

#

ipv4-family unicast

 undo synchronization

 network 192.168.2.0  

 peer 30.1.1.1 enable

 peer 40.1.1.1 enable

#

ipv6-family unicast

 undo synchronization

#

user-interface con 0

authentication-mode password

idle-timeout 0 0

user-interface vty 0 4

user-interface vty 16 20

#

wlan ac

#

return

[r4]

5、结果

Total Number of Routes: 2

     Network            NextHop        MED        LocPrf    PrefVal Path/Ogn


*>i  192.168.1.0        1.1.1.1         0          100        0      i

*>   192.168.2.0        30.1.1.2        0          101        0      10 20 30 2

i

[r2]