Sunday, February 10, 2013

BGP router-id do you need a interface ip_address

A lot of confusion exist with the BGP router-id. Most network engineers builds around a unique loopback interface and the address of that interface is commonly used for both the BGP and OSPF router-id.

For BGP to work, it must have a bgp router-id.  Here's some key-points to  you should considered
 
  • You can define one or let the ios assume one from  your ip_addressed interfaces
  • If a loopback interface is configured, the BGP speaker will always assume that address for it's bgp router-id
  • If you have no loopback interface and numerous interfaces withan  ip_address, it will always take the highest ip_addressed interface and use that for it's router-id
  • If you have multiple loopbacks, the highest addressed loopback interface will become your router-id 
  • A router-id must be a valid ip_address ( notice I said valid, so 0.0.0.0 or 0.0.0.1 would not be acceptable )
  •  If you are letting the router assume it's bgp router-id, and the interface that it originally assumed for the router-id goes away or is delete, all existing bgp sessions will still stay  up using the previous router-id and any new sessions will use the newly assumed router-id.
  • If you are using a interface as the router-id and delete or change that interface, the active BGP session will state UP, and upon reset or clear, the router will select a new router-id based on the points listed above and if one was not set under your router bgp config
  • Word to the wise, if you ever decide to change the bgp router-id after bgp sessions are up, it will reset ALL established peers.


Let's look at this  configuration and  it's interfaces that I configured ;


!
router bgp 65001
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.0.0.2 remote-as 65001
 no auto-summary
!

r1#show ip int br
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            10.0.0.1        YES manual up                    up     
FastEthernet0/1            unassigned      YES unset  administratively down down   
r1#
 



r2#sh run | beg router
router bgp 65001
 no synchronization
 bgp router-id 192.0.2.1
 bgp log-neighbor-changes
 neighbor 10.0.0.1 remote-as 65001
 no auto-summary
!

r2#show ip int br
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            10.0.0.2        YES manual up                    up     
FastEthernet0/1            unassigned      YES unset  administratively down down   
r2#



You notice how a BGP router-id was configured on r2, but that address did not exist ? Do you think bgp would be established ?

Well look at what happen;

r1#show ip bgp sum
BGP router identifier 10.0.0.1, local AS number 65001
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.0.0.2        4 65001      25      25        1    0    0 00:02:14        0
r1#


and from r2;

r2#show ip bgp sum
BGP router identifier 192.0.2.1, local AS number 65001
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.0.0.1        4 65001      25      25        1    0    0 00:02:26        0
r2#


Bgp established  with no problems. The 192.0.2.1 ip address was not configured anywhere within the  ios config of r2, but bgp used it for the router-id. And r1 automatically picked  it's fas0/0 {10.0.0.1} interface for it's own router-id.

Okay what happens if we duplicate a router-id under a bgp  config? I will now config  r1 to use 192.0.2.1 to demostrate the issue.



r1#show ip bgp sum
BGP router identifier 192.0.2.1, local AS number 65001
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.0.0.2        4 65001      15      15        0    0    0 00:04:59 Active
r1#



and r2

r2#show ip bgp sum
BGP router identifier 192.0.2.1, local AS number 65001
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.0.0.1        4 65001      16      16        0    0    0 00:05:28 Active
r2#


When the bgp router-id are duplicated, you will get the following notification and with the id printed in hex in the error message.


*Mar  1 00:08:19.843: %BGP-3-NOTIFICATION: sent to neighbor 10.0.0.2 2/3 (BGP identifier wrong) 4 bytes C0000201  FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 002D 0104 FDE9 00B4 C000 0201 1002 0601 0400 0100 0102 0280 0002 0202 00

It's always smart to either let the router use one of it ip_addresssed interface or  more preferred & best practices to  built a loopback interface, and defined that address for both your bgp and ospf router-id.

NOTE: For proper route distribution both the  bgp+ospf router-id must match, I will talk about that  in a future post.


I hope the  above helps you in  your bgp design and any configurations considerations.

Ken Felix
Freelance Network/Security  Engineer
kfelix  at hyperfeed d-o-t com

No comments:

Post a Comment