This article presents a short BGP (Border Gateway Protocol) lab on Cisco routers. Many of you have heard what the BGP is, but not everyone had the opportunity to try out the protocol. This lab will be especially interesting for those, who have not had the chance to see this protocol in action.
In order to run the lab it is recommended to use GNS3, a great simulator that can be easily found online.
The purpose of the lab is configuration of the client’s and the operator’s routers in order to obtain multihoming, using the connection to one ISP. Here is the topology of our future network:
The goal is to make the connection between routers A and C primary for incoming and outgoing traffic, while the connection between B and D a backup one, used only when the primary connection fails.
Interfaces on routers must be configured in compliance with the following table:
|interface/router||Router A||Router B||Router C||Router D|
For Serial 1/1 on BGP router A:
R1(config) # interface S1/1 R1(config-if) # ip address 126.96.36.199 255.255.255.252 R1(config-if) # no shutdown
The rest of the interfaces must be setup independently in a similar manner.
Each BGP router must have an AS number (according to the topology) that specifies which AS the router belongs to. Additionally, each BGP router will serve two sessions: one iBGP session with the router in the same AS to operate within an autonomous system, and one eBGP with a router located in another AS to operate between autonomous systems. Sessions must be configured on both sides of the connection.
R1(config) # router bgp 65500 R1(config-router) # neighbor 188.8.131.52 remote-as 65500 R1(config-router) # neighbor 184.108.40.206 remote-as 100
The configuration of the rest of the routers remains an independent task.
The next thing to do – is to use a non-standard mechanism, proposed by Cisco, next-hop-self. Essentially, it allows you to change the Next_Hop address before advertising the route to another BGP router in the same AS. The BGP router changes the value Next_Hop attribute to its own address. Because of this, intra-domain routing in each AS does not need to be configured. This mechanism has to be configured only between routers in the same AS.
R1(config) # router bgp 65500 R1(config-router) # neighbor 220.127.116.11 next-hop-self
Configuration of the other routers remains a separate task.
The address space used in AS 65500 is 18.104.22.168/24. In order to simulate a network like that, connected to the router, one can configure a loopback interface on BGP router B.
R2(config) # interface loopback 0 R2(config-if) # ip address 22.214.171.124 255.255.255.0
Then, the routers must advertise the subnet to which they have access. BGP router B advertises 126.96.36.199 network with 255.255.255.0 mask, which is on the Loopback 0 interface.
R2(config) # router bgp 65500 R2(config-router) # network 188.8.131.52 mask 255.255.255.0
Routers C and D will announce only the default route to A and B (the route that will be used for all outgoing traffic from AS 65500).
R3(config) # router bgp 100 R3(config-router) # neighbor 184.108.40.206 default-originate
Outbound traffic management
Attribute Local Preference can be used in case the goal is to make routers A and B use only the primary link for the outbound traffic. The attribute has a value of 100 by default. The value of Local Preference is exchanged between all the routers located in an AS. The higher the attribute value, the higher the priority of the connection. Changing the Local Preference value can be achieved by using a Route Map.
Establishing the link between A and C primary:
R1(config) # router-map primary R1(config-route-map) # match ip address 1 R1(config-route-map) # set local-preference 150 R1(config-route-map) # exit R1(config) # access-list 1 permit host 0.0.0.0
R1(config) # router bgp 65500 R1(config-router) # neighbor 220.127.116.11 route-map primary in
In order for Local Preference changes to take effect, the previous BGP session settings must be reset.
R1 # clear ip bgp *
Traceroute can be used to check whether the configuration is correct and to enjoy the result, by turning off and on certain interfaces, simulating a link fail.
Inbound traffic management
In case the goal is to ensure that the routers C and D route all their traffic via the primary connection, MED attribute can be used to accomplish this task. The main link should get a lower value (in this case MED 20) than the backup (MED 30). This can be done using a Route Map.
R1(config) # route-map trafic_out permit 10 R1(config-route-map) # match ip address 10 R1(config-route-map) # set metric 20 R1(config-route-map) # exit R1(config) # access-list 10 permit host 18.104.22.168
R1(config) # router bgp 65500 R1(config-router) # neighbor 22.214.171.124 route-map trafic_out out
The same procedure must be accomplished on BGP router B with the value of MED 30. It is essential to reset BGP session on the ISP routers, so that new metrics values can be obtained.