BGP basic experiment: 3 experiments on recognized group attributes & MED attribute experiment

3 experiments on recognized group properties


 image.png

 image.png

 

Mark the two routes on R2 and advertise them to R3

[R2]ip ip-prefix 1.1 permit 10.1.1.1 32

 

[R2]ip ip-prefix 1.2 permit 10.1.1.2 32

[R2-route-policy]dis th

 

route-policy comm permit node 10

 if-match ip-prefix 1.1

 apply community 100:1

 

route-policy comm permit node 20

 if-match ip-prefix 1.2

 apply community 100:2

#

[R2-bgp]peer 12.1.1.1 route-policy comm import //Add community attributes to these two routes when R1 enters R2

[R2-bgp]peer 3.3.3.3 advertise-community //Community attributes are advertised to 3.3.3.3

no-advertise

[R2]route-policy 1.2 permit node 10

 

[R2-route-policy]if-match ip-prefix 1.2

[R2-route-policy]apply community no-advertise

[R2]route-policy 1.2 permit node 99

 

[R2-bgp]peer 3.3.3.3 route-policy 1.2 export

 

//Applying on the egress interface, R3 gets the unannounced community attribute and disappears after reaching R4.

<R3>dis bgp routing-table 10.1.1.2

 

 BGP local router ID : 34.1.1.3

 Local AS number : 64512

 Paths:   1 available, 1 best, 1 select

 BGP routing table entry information of 10.1.1.2/32:

 From: 2.2.2.2 (23.1.1.2)

 Route Duration: 00h04m14s  

 Relay IP Nexthop: 23.1.1.2

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 2.2.2.2

 Qos information : 0x0

 Community:no-advertise

 AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal-conf

ed, best, select, active, pre 255

 Not advertised to any peer yet

[R4-bgp]dis bgp routing-table 10.1.1.2

Info: The network does not exist.

Almost never passed to any peer neighbor.

no-export

[R2-route-policy]apply community no-export

//At this time, R3 and R4 check that 1.1 has a group attribute, and 1.2 has a group attribute of no-export.

[R4-bgp]peer 45.1.1.5 advertise-community

 

<R5>dis bgp routing-table 10.1.1.2 //The route of 10.1.1.2 disappears on R5, and there is only the route of 1.1

Info: The network does not exist.

<R5>dis bgp routing-table 10.1.1.1

 

 BGP local router ID : 45.1.1.5

 Local AS number : 300

 Paths:   1 available, 1 best, 1 select

 BGP routing table entry information of 10.1.1.1/32:

 From: 45.1.1.4 (45.1.1.4)

 Route Duration: 00h00m08s  

 Direct Out-interface: GigabitEthernet0/0/1

 Original nexthop: 45.1.1.4

 Qos information : 0x0

 Community:<100:1>

 AS-path 200 100, origin igp, pref-val 0, valid, external, best, select, active,

 pre 255

 Not advertised to any peer yet

 

This attribute is not exported to other AS zones, the attribute is passed within IBGP.

no-export-subconfed

[R2-route-policy]apply community no-export-subconfed

 

It is passed within a sub-area of an AS alliance and disappears outside the sub-area.

<R4>dis bgp routing-table 10.1.1.2

Info: The network does not exist.

<R4>dis bgp routing-table 10.1.1.1

 

 BGP local router ID : 45.1.1.4

 Local AS number : 64513

 Paths:   1 available, 1 best, 1 select

 BGP routing table entry information of 10.1.1.1/32:

 From: 3.3.3.3 (34.1.1.3)

 Route Duration: 00h15m52s  

 Relay IP Nexthop: 34.1.1.3

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 2.2.2.2

 Qos information : 0x0

 Community:<100:1>

 AS-path (64512) 100, origin igp, MED 0, localpref 100, pref-val 0, valid, exter

nal-confed, best, select, active, pre 255

 Advertised to such 1 peers:

    45.1.1.5

 

MED attribute experiment

MED (Multi-Exit Discriminator, multi-exit discriminator) is an optional non-transition attribute, and the MED value will not be transferred across ASs (it will be transferred once between EBGP).

image.png 

By default, the router only compares the MED values of BGP routes from the same adjacent AS. That is, if two routes to the same destination come from different adjacent ASs, the MED values will not be compared.

When a BGP router advertises a route to an EBGP peer, whether it carries the MED attribute needs to be judged based on the following conditions (when no policy is used on the EBGP peer):

1. If the BGP route is originated locally (imported locally through the network or import-route command), the MED attribute is sent to the EBGP peer by default.

2. If the BGP route is learned from the BGP peer, the route will not carry the MED attribute by default when passed to the EBGP peer.

3. When transmitting routes between IBGP peers, the MED value will be retained and transmitted. Unless a policy is deployed, the MED value will not change or be lost during the transmission process.

You can use the default imed command to modify the default MiED value. The default med command only takes effect on the routes imported by the import-route command on the local device and BGP aggregate routes. For example, if default med 999 is configured on R2, then when R2 passes the route generated by the import-route and aggregate commands to R3, the MED carried by the route is 999.

image.png 

Declare in R1

[R1-bgp]network 1.11.11.11 32

When bgp is announced on R1, the MED is 0

[R2-bgp]dis bgp routing-table

 

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 

 *>i  1.11.11.11/32      1.1.1.1         0          100        0      i

[R3-bgp]dis bgp routing-table

 

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 

 *>   1.11.11.11/32      23.1.1.2                              0      100i

It is generated by this router, so the MED is 0, and the next hop AS connected to this AS in the AS is 0.

Declare in R2

[R2-bgp]network 1.11.11.11 32

[R2-bgp]dis bgp routing-table

 

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 

 *>   1.11.11.11/32      0.0.0.0         1                     0      i

[R3-bgp]dis bgp routing-table

 

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 

 *>   1.11.11.11/32      23.1.1.2        1                     0      100i

[R1-bgp]dis bgp routing-table

 

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 

 *>i  1.11.11.11/32      2.2.2.2         1          100        0      i

This route is generated in R2 and learned by ospf. The cost is 1, so the MED value is 1 after being announced in BGP.