MED (or metric) is the sixth BGP attribute:
- MED can be used to advertise to your neighbors how they should enter your AS.
- MED is exchanged between autonomous systems.
- The LOWEST MED is the preferred path.
- MED is propagated to all routers within the neighbor AS but not passed along any other autonomous systems.
Consider the below topology:
R1 has to reach the Loopback address of R4 (4.4.4.4/32) through R3 router. By default, it passes through the R3 router.
Lets start our configuration part:
R1 Interface Configuration:
R1#show ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.12.1 YES manual up up
FastEthernet0/1 192.168.13.1 YES manual up up
Loopback0 1.1.1.1 YES manual up up
R1#
R2 Interface Configuration:
R2#show ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.12.2 YES manual up up
FastEthernet0/1 192.168.24.2 YES manual up up
Loopback0 2.2.2.2 YES manual up up
R2#
R3 Interface Configuration:
R3#show ip int br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.13.3 YES manual up up
FastEthernet0/1 192.168.34.3 YES manual up up
Loopback0 3.3.3.3 YES manual up up
R3#
R4 Interface Configuration:
R4#show ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.24.4 YES manual up up
FastEthernet0/1 192.168.34.4 YES manual up up
Loopback0 4.4.4.4 YES manual up up
R4#
Now, we can start configuring BGP in all our routers.
R1 BGP Configuration:
R1#conf terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#router bgp 1
R1(config-router)#nei
R1(config-router)#neighbor 192.168.12.2 remote-as 23
R1(config-router)#neighbor 192.168.13.3 remote-as 23
R1(config-router)#redistribute connected
R1(config-router)#end
R1#
R2 BGP Configuration:
R2#conf terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#
R2(config)#router bgp 23
R2(config-router)#neighbor 192.168.12.1 remote-as 1
R2(config-router)#neighbor 192.168.24.4 remote-as 4
R2(config-router)#redistribute connected
R2(config-router)#end
R2#
R3 BGP Configuration:
R3#conf terminal
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#
R3(config)#router bgp 23
R3(config-router)#neighbor 192.168.13.1 remote-as 1
R3(config-router)#neighbor 192.168.34.4 remote-as 4
R3(config-router)#redistribute connected
R3(config-router)#end
R3#
R4 BGP Configuration:
R4#conf terminal
Enter configuration commands, one per line. End with CNTL/Z.
R4(config)#router bgp 4
R4(config-router)#
R4(config-router)#neighbor 192.168.24.2 remote-as 23
R4(config-router)#neighbor 192.168.34.3 remote-as 23
R4(config-router)#redistribute connected
R4(config-router)#end
R4#
- From the below R1 BGP table, we can see that the R1 prefers the path through R3 (Next Hop IP as 192.168.13.3) to reach the Network 4.4.4.4/32.
- Symbol ">" in-front of the network indicates the best path (router prefers to use this path to send the traffic)
Lets start our Metric attribute configuration,
Here, I have created a route-map named as MED-TEST. Next, I have used the command "match ip address 1" to match the access-list 1, and then if it matches I have set the Metric (MED) value as 500. I have created a second permit statement for the same route-map AS-PATH-TEST.
Creating a Route-Map:
R3#conf terminal
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#
R3(config)#route-map MED-TEST permit
R3(config-route-map)#match ip address 1
R3(config-route-map)#set metric 500
R3(config-route-map)#exi
R3(config)#route-map MED-TEST permit 20
R3(config-route-map)#end
R3#
You can also view the created c-map using the below command:
R3#show route-map
route-map MED-TEST, permit, sequence 10
Match clauses:
ip address (access-lists): 1
Set clauses:
metric 500
Policy routing matches: 0 packets, 0 bytes
route-map MED-TEST, permit, sequence 20
Match clauses:
Set clauses:
Policy routing matches: 0 packets, 0 bytes
R3#
Next create a access-list as below:
R3#conf terminal
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#access-list 1 permit host 4.4.4.4
R3(config)#end
R3#
You can view configured access-list using the below command,
R3#show access-lists
Standard IP access list 1
10 permit 4.4.4.4
R3#
Applying the created route-map to bgp configuration.
R3#conf terminal
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#router bgp 23
R3(config-router)#neighbor 192.168.13.1 route-map MED-TEST out
R3(config-router)#end
R3#
Here, I have mapped the route-map MED-TEST as "OUT" to the neighbor R1 (192.168.13.1). so that it will advertise the configured Metric value (value: 500) its neighbor.
You need to clear the BGP session to take the newly applied configuration to take effect.
In-order to clear the bgp session, use the command "clear ip bgp * soft in"
- The metric for the neighbor 192.168.13.3 (R3 router) has now changed to 500.
- Best path changed to R2 (Next hop 192.168.12.2 ) as the metric has been changed.
Note:
- The lower the metric is preferred.
- MED will compare the configured value only if it receives from the same AS number. In this article, R1 is receiving the network 4.4.4.4/32 from R2 and R3 routers, but both the routers belongs to the same AS (AS 23)
- If received from the different AS number, by default it will not be compared, but there is a command by which we can make our device to compare. That feature is called as "BGP Always compare MED". We will discuss about in a different chapter.
That's it about MED (Metric) BGP Attribute.
You can also look into my video tutorial in Tamil:
Post a Comment
Post a Comment