
Introduction
The way BGP advertises routes to peers is via network command. However unlike other IGP(e.g OSPF , EIGRP etc) which summerises the entire network.
For example to advertise and summarise an entire /16 network in an IGP (ospf in our example) you would use the following network command:
255.255.255.255 – 255.255.0.0 = 0.0.255.255
RouterA(config-router): network 172.16.0.0 0.0.255.255 area 0
On the above network statement OSPF will advertise all interfaces under that network for example based on the above it will advertise 172.16.1.16/24 and 172.16.10/24. Are you following?
You see OSPF advertises on the interface level. The OSPF DR and the OSPF BDR router will advertise 172.16.1.16/24 and 172.16.10.24/24 interfaces to all adjacent routers. OSPF wIll advertise to multicast using “hello”. It will not advertise the 172.16.0.0/16 directly even though it was in the network statement above.
In BGP, the network statement actually inherently equates to “please advertise this network”. Unlike OSPF we are not enabling BGP on a particular interface. Remember BGP doesn’t use multicast, it’s using direct TCP connection on port 179 to perform peering between neighbours. Adjacent routers are peered and are neighbours, they are not advertising any “networks”.
To provide you with an accurate “wording”, under IGP(OSPF) network statement we are “enabling” OSPF for a particular interface on the router to be advertised. However what makes BGP different(special) is that we are not “enabling” BGP for a interface we are “advertising” the networks.
Subsequently we must advertise BGP network specifically. For example 172.16.1.16/24 and 172.16.10.24/24 we cannot advertise 172.16.0.0/16 to advertise both of those network because 17.16.0.0/16 is not in the control planes RIB. BGP requires the exact mask for a network in order to advertise.
So for example if we need to advertise those network interfaces in BGP we will have to perform the following on the router:
network 172.16.1.16 mask 255.255.255.0
network 172.16.10.16 mask 255.255.255.0
We will have to continue to enable the router interfaces separately…..
The Static Null route: Advertise an entire subnet in BGP
A null route in the control RIB does something fairly simple, it will essentially drop the packet heading to a particular network. It’s mainly utilised to prevent loops and for security purposes. It’s an important tool to prevent loops for example let’s a packet arrives from another router in a neighbouring BGP AS. If it’s destination is down for whatever reason the router will automatically forward to the default route and it will be inherently be routed back again creating “routing loop”.
In order to inject a null static route for example:
ip route 172.16.0.0. 255.255.0.0 null0
Remember in BGP we cannot advertise a network that is NOT in the control planes RIB(routing table) by creating the above static route, we have now injected the above network into the RIB.
Then under the BGP AS statement we would simply advertise the following:
network 172.16.0.0 mask 255.255.255.0
Subsequently one may assume, why? We are going drop all packets destined for 172.16.0.0/16. Doesn’t make any sense correct?
No.
Let’s say a IP packet comes in with destination IP field header of 172.16.1.16 . The router will perform a lookup of its control plane RIB. Remember from the my previous post. It will match 172.16.0.0/16 and it will also match 172.16.1.0/24.
The 172.16.1.0/24 prefix will be the longest match, subsequently it will not drop the packet. The FIB will forward the packet to the 172.16.1.0/24 and the adjacency table will have a pre-made frame header to the interface L2 address then it is forwarded to the corresponding interface.
No need to advertise specific masks in BGP
We can’t advertise entire network in BGP (e.g 172.16.0.0 255.255.0.0) remember we have to be specific with masks in BGP (e.g 172.16.0.1/30 etc)
Which inherently means we must advertise a peers networks individually.
However with this small trick, we can now advertise all networks under 172.16.0.0/16 with single command, as opposed individually. Simply by inserting the static null route into the control planes RIB(routing table).