Saturday 3 December 2011

Nugget 20
BGP Routing - Implementing Basic BGP Part 1





The lab is now setup as above, with OSPF being the interior routing protocol and BGP the external ... and well we will configure an internal BGP peering between R4 and R1 later.

Lets check out the commands at our disposal in BGP:


Router-5(config)#router bgp 6500
Router-5(config-router)#neighbor 10.1.45.1 ?
  activate                 Enable the Address Family for this Neighbor
  advertise-map            specify route-map for conditional advertisement
  advertisement-interval   Minimum interval between sending BGP routing updates
  allowas-in               Accept as-path with my AS present in it
  capability               Advertise capability to the peer
  default-originate        Originate default route to this neighbor
  description              Neighbor specific description
  disable-connected-check  One-hop away EBGP peer using loopback address
  distribute-list          Filter updates to/from this neighbor
  dmzlink-bw               Propagate the DMZ link bandwidth
  ebgp-multihop            Allow EBGP neighbors not on directly connected networks
  fall-over                session fall on peer route lost
  filter-list              Establish BGP filters
  inherit                  Inherit a template
  local-as                 Specify a local-as number
  maximum-prefix           Maximum number of prefixes accepted from this peer
  next-hop-self            Disable the next hop calculation for this neighbor
  next-hop-unchanged       Propagate the iBGP paths's next hop unchanged for this neighbor
  password                 Set a password
  peer-group               Member of the peer-group
  prefix-list              Filter updates to/from this neighbor
  remote-as                Specify a BGP neighbor
  remove-private-as        Remove private AS number from outbound updates
  route-map                Apply route map to neighbor
  route-reflector-client   Configure a neighbor as Route Reflector client
  send-community           Send Community attribute to this neighbor
  shutdown                 Administratively shut down this neighbor
  soft-reconfiguration     Per neighbor soft reconfiguration
  timers                   BGP per neighbor timers
  translate-update         Translate Update to MBGP format
  transport                Transport options
  ttl-security             BGP ttl security check
  unsuppress-map           Route-map to selectively unsuppress suppressed routes
  update-source            Source of routing updates
  version                  Set the BGP version to match a neighbor
  weight                   Set default weight for routes from this neighbor


Check out all them options!!! wow boi!
First thing we need to do, in order to get started and get this relationship up and running is the remote-as command, this will get the conversation flowing with OPEN msgs to the neighbour statement we are configuring.

Router-5(config-router)#neighbor 10.1.45.1 remote-as 5500




Router-5#show ip bgp summ
BGP router identifier 109.170.1x7.xx, local AS number 6500
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd <--seq of the DB it has recieved
10.1.45.1       4  5500       0       0        0    0    0 never    Active


Here we can see we have our configured neighbor .... totally dead (Up/Down column) at the moment, no messages sent or recieved.  Notice the state/PfxRcd is set to ACTIVE, this means the exact same thing as in the EIGRP world:

ACTIVE = BAD

It is actively trying to bring the relationship up (whereas EIGRP was actively trying to find a backup route)


Lets configure his buddy;

Router-4(config)#router bgp 5500
Router-4(config-router)#neighbor 10.1.45.2 remote-as 6500


Now, lets see how long it takes for the relationship to come up!.... remember this is a SLOW protocol:



Router-5#show clock
21:48:35.778 GB Sat Nov 19 2011
Router-5#
013151: Nov 19 21:48:50.025: %BGP-5-ADJCHANGE: neighbor 10.1.45.1 Up

Okay, 15 seconds, that came up pretty quick (bit dissapointed in away as jeremy - the instructor was saying it can take as long as 60 seconds!)


Router-4#show ip bgp sum
BGP router identifier 10.1.45.1, local AS number 5500
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.1.45.2       4  6500       8       7        1    0    0 00:04:36        0


So notice we have msgs being sent and recieved, BUT the state/PfxRcd column is still 0, thats because with BGP you can establish a neighbour and not send/exchange any routes/information ..... SO different to what we are used to!! (so is statically configuring the neighbours too! lol BUT i guess if it did auto discover neighbours, imagine the issues ISPs would have, peoples home routers bringing up BGP, peering with them and then injecting routes all over the place LOL)


Now for iBGP, there is no funky command or any funny business, it will just be when we enter the remote-as command we enter "our" internal AS and the router will know it will be an iBGP speaker.


As the plan goes, we plan to get a iBGP peering going with routers 1&4, even though, they are not directly connected :0)


First though, we need to setup some loopbacks for the peering of the relationships, as it would be silly peering with x1 of the physical interfaces, as if x1 of those interfaces where to go down, we would loose the BGP peering.
We also then need to advertise the loopbacks into the internal routing protocol (OSPF) so the rest of the network knows about them (otherwise the BGP messages would not make it from either iBGP speaker)



Router-4#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router-4(config)#inter loopback4
Router-4(config-if)#ip address 4.4.4.4 255.255.255.255
Router-4(config-if)#exit
Router-4(config)#router ospf 1
Router-4(config-router)#network 4.4.4.4 0.0.0.0 area 0



lets do the same for Router-1, but first double check he is now seeing this new loopback;

Router-1#show ip route

     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/75] via 10.1.12.2, 00:01:02, Ethernet0/0
                [110/75] via 10.1.13.2, 00:01:02, Serial0/0



Swweeet, lets do the loopback on this router too;


Router-1(config)#inter loopback1
Router-1(config-if)#ip address 1.1.1.1 255.255.255.255
Router-1(config-if)#exit
Router-1(config)#router ospf 1
Router-1(config-router)#network 1.1.1.1 0.0.0.0 area 0


lets configure the BGP part now on both routers;

Router-4(config)#router bgp 5500
Router-4(config-router)#neighbor 1.1.1.1 remote-as 5500

Router-1(config)#router bgp 5500
Router-1(config-router)#neighbor 4.4.4.4 remote-as 5500


BUT the neighbourship will NEVER form;

Router-1#show ip bgp summary

BGP router identifier 1.1.1.1, local AS number 5500
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
4.4.4.4         4  5500       0       0        0    0    0 never    Active


BECAUSE .... the BGP packets will be hitting the neighbour with a source interface IP address which wont be the loopback (whichever OSPF determines the quicker path to the neighbour), therefore the relationship will not form as the BGP router has no idea who that interface is/belongs too, it wont be the statically configured IP in the neighbour command!!

So to fix this, we can use the update-source command, here we can specify the loopback of Router-4
Router-4(config)#router bgp 5500
Router-4(config-router)#neighbor 1.1.1.1 update-source loopback 4



lets go do the other router:


Router-1(config)#router bgp 5500
Router-1(config-router)#neighbor 4.4.4.4 update-source loopback 1



ah ha ...

Router-1#
000018: *Mar  1 01:52:30.823: %BGP-5-ADJCHANGE: neighbor 4.4.4.4 Up



Router-1#show ip bgp summ
BGP router identifier 1.1.1.1, local AS number 5500
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
4.4.4.4         4  5500       3       4        1    0    0 00:00:37        0



Notice, we now have no ACTIVE state and a 0 for the revision of the BGP database.

Over on router-4 we have the iBGP and eBGP neighbourships up;

Router-4#show ip bgp summ
BGP router identifier 10.1.45.1, local AS number 5500
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
1.1.1.1         4  5500      10       9        1    0    0 00:06:10        0
10.1.45.2       4  6500      52      51        1    0    0 00:48:19        0


just for clarification and sanity checking:

Router-4#show ip bgp neighbors
BGP neighbor is 1.1.1.1,  remote AS 5500, internal link  <---iBGP

 Index 2, Offset 0, Mask 0x4
  BGP version 4, remote router ID 1.1.1.1
  BGP state = Established, table version = 1, up for 00:08:10
  Last read 00:00:10, hold time is 180, keepalive interval is 60 seconds
  Minimum time between advertisement runs is 5 seconds
  Received 12 messages, 0 notifications, 0 in queue
  Sent 11 messages, 0 notifications, 0 in queue
  Prefix advertised 0, suppressed 0, withdrawn 0
  Connections established 1; dropped 0
  Last reset never
  0 accepted prefixes consume 0 bytes
  0 history paths consume 0 bytes
Connection state is ESTAB, I/O status: 1, unread input bytes: 0
Local host: 4.4.4.4, Local port: 11012
Foreign host: 1.1.1.1, Foreign port: 179


BGP neighbor is 10.1.45.2,  remote AS 6500, external link  <----eBGP
 Index 1, Offset 0, Mask 0x2

  BGP version 4, remote router ID 109.170.1x7.xx (my public IP range)
  BGP state = Established, table version = 1, up for 00:50:50
  Last read 00:00:50, hold time is 180, keepalive interval is 60 seconds
  Minimum time between advertisement runs is 30 seconds
  Received 54 messages, 0 notifications, 0 in queue
  Sent 53 messages, 0 notifications, 0 in queue
  Prefix advertised 0, suppressed 0, withdrawn 0
  Connections established 1; dropped 0
  Last reset never
  0 accepted prefixes consume 0 bytes
  0 history paths consume 0 bytes


BUT, we still have no BGP routes;

Router-4#show ip bgp

Becuase the neighbours and networks/routes are seperated in BGP unlike other routing protocols, whereby you have neighbours and you are told of the routes they know (via the network command under the routing protocol, which would tell the router what interfaces to advertise on and what networks to advertise into the process) ...

So with BGP, we have neighbour commands to bring up neighbour relationships BUT then to get the routing aspect we have to then apply the network commands, so they are totally seperate with BGP.


Right before we get BGP exchanging routes, lets just look at an example and at the same time tidy up our relationship with Router-5 (lets get it using a loopack interface tooo)



Router-5(config)#interface loopback5
Router-5(config-if)#ip address 5.5.5.5 255.255.255.255

Plus we need a static route to our neighbour, as if we were an ISP, we would not be running an interior routing protocol;
Router-5(config-if)#ip route 4.4.4.4 255.255.255.255 10.1.45.1



test;
Router-5#ping 4.4.4.4

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms


Now lets set a static on Router-4 to reach Router-5's (the ISP) loopback, as currently this router does not no anything about the 5.5.5.5 network;

Router-4(config)#ip route 5.5.5.5 255.255.255.255 10.1.45.2
Router-4#ping 5.5.5.5


Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms



Lets just say for a moment, that say we had to links (T1 lines) going to the same ISP, we could have another static route on the ISP end and have that point to a 2nd loopback interface and then the cisco router would perform load balancing (see diagram above)


 HOWEVER there is a rule for eBGP, and that is the neighbours MUST BE DIRECTLY CONNECTED, although we may be thinking well, yeah they are, the router has to pass through the routers interface to get to the loopback, and so see's it as being more than 1 hop away ...


SO, this can be fixed by apply the update-source command and setting it to the loopback 4.4.4.4 and then with this command:


Router-4(config-router)#neighbor 5.5.5.5 ebgp-multihop ?
  <1-255>  maximum hop count
  <cr>

Router-4(config-router)#neighbor 5.5.5.5 ebgp-multihop 2


But again, be careful as for routing loops!! recommended is no more than 5!

RIGHT, so lets watch the neighbourship come up after i apply this on both routers;



Router-4(config)#router bgp 5500
Router-4(config-router)#neighbor 5.5.5.5 ebgp-multihop 2
Router-4(config-router)#neighbor 5.5.5.5 update-source loopback 4



Router-5(config)#router bgp 6500
Router-5(config-router)#neighbor 4.4.4.4 ebgp-multihop 2
Router-5(config-router)#neighbor 4.4.4.4 update-source loopback 5
Router-5(config-router)#
013233: Nov 19 23:22:28.467: %BGP-5-ADJCHANGE: neighbor 4.4.4.4 Up


Router-5#show ip bgp summ

BGP router identifier 109.170.1x7.xx, local AS number 6500
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
4.4.4.4         4  5500       3       4        1    0    0 00:00:57        0


SWEEET, without that multihop command this neighbour would never of come up.

RIGHT, lets get on with part 2