Académique Documents
Professionnel Documents
Culture Documents
www.huawei.com
BGP can be used to combine many policy tools, use BGP path attributes
such as AS_PATH, COMMUNITY and so on as well as filter routes
received from or sent to peers. This section will introduce many of the
policy mechanisms within BGP to support manipulation of all traffic.
BGP compares the origin attribute of the route and selects the route with the
lowest origin attribute code: IGP is lower than EGP, which is lower than
Incomplete.
Select the route with the lowest MED value.
Prefer the route with smaller Originator ID. Select the route
with smaller router ID if Originator ID is unavailable.
Prefer the route with smaller peer IP address.
Preferred Value
Local-Preference
AS-Path
Origin
MED
EBGP/IBGP
IGP Cost
Cluster-list
Communities
[RTB]bgp 200
[RTB-bgp]default local-preference 2000 AS 200
10.1.1.2
AS 100 10.1.1.1
RTB
192.168.1.1/32 10.4.4.1
RTA
RTD
10.4.4.2
AS 200
10.1.1.2
AS 100 10.1.1.1
RTB
RTD
192.168.1.0/24 10.4.4.1
192.168.2.0/24 RTA
10.4.4.2
RTC
#
acl number 2000
rule 5 permit source 192.168.1.0 0.0.0.255
#
bgp 200
peer 10.1.1.1 as-number 100
peer 3.3.3.3 as-number 200
#
ipv4-family unicast
undo synchronization
peer 10.1.1.1 enable
peer 10.1.1.1 route-policy test1 import
#
route-policy test1 permit node 10
if-match acl 2000
apply local-preference 2000
route-policy test1 permit node 20
apply local-preference 1000
#
192.168.1.0/24
192.168.3.0/24
Prefix/Mask Med
RTC 192.168.1.0/24 2000 RTD
192.168.3.0/24 1000
Characters Explanation
Match the beginning of a string. For example “^200” indicates match only if the first
^
value of the AS_PATH is 200.
Match the end of a string. For example “200$” indicates match only if the last value of
$
the AS_PATH is 200.
_ Match any delimiters. For example, comma, bracket, white space and so on.
^ regular expression
$ (Dollar) matches the end of a line.
$ regular expression
Example
Example
- Hyphen
Example
Example
=========|| =============
^$ Match the routes originated in local AS
AS 100 10.1.1.1
RTB
10.2.2.2
AS 300
192.168.1.0/24 RTC
10.4.4.2 10.3.3.1
192.168.2.0/24 RTA RTD
10.4.4.1 10.3.3.2
AS 400
RTC wants to receive only routing information from AS300.
#
bgp 400
peer 10.4.4.2 as-number 100
peer 10.3.3.1 as-number 300
#
ipv4-family unicast
undo synchronization
peer 10.4.4.2 enable
peer 10.4.4.2 as-path-filter 1 import
peer 10.3.3.1 enable
peer 10.3.3.1 as-path-filter 1 import
#
ip as-path-filter 1 permit ^300_
#
AS 200
10.1.1.1 10.1.1.2
RTA RTB
1000M
AS 100 10.4.4.2 10.2.2.1 1000M
10.0.0.0/24
10.4.4.1 10.2.2.2 AS 300
10.3.3.2 10.3.3.1
RTD RTC
10M
bgp 100
peer 10.4.4.1 as-number 100
peer 10.1.1.2 as-number 200
#
ipv4-family unicast
undo synchronization
peer 10.4.4.1 enable
peer 10.1.1.2 enable
peer 10.1.1.2 route-policy set_community export
peer 10.1.1.2 advertise-community
#
route-policy set_community permit node 10
apply community 100:1
bgp 100
peer 10.4.4.2 as-number 100
peer 10.3.3.1 as-number 300
#
ipv4-family unicast
undo synchronization
peer 10.4.4.2 enable
peer 10.3.3.1 enable
peer 10.3.3.1 route-policy set_community export
peer 10.3.3.1 advertise-community
#
route-policy set_community permit node 10
apply community 100:2
in BGP.