BGP with auto-summary
As we knew, when we want to advertise a network in BGP we have to type the exact network and subnet mask of that network or it will not be placed into the BGP table. But with “auto-summary” command, we can advertise the classful network of our network if we have this classful or a subnet of this network in our routing table. Let’s have a small lab with the topology below:
R1 Initial Config interface loopback0 ip address 172.16.128.1 255.255.224.0 interface Loopback1 ip address 172.16.160.1 255.255.224.0 interface Loopback2 ip address 172.16.192.1 255.255.224.0 interface Loopback3 ip address 172.16.224.1 255.255.224.0 interface Ethernet0/0 ip address 192.168.10.1 255.255.255.0 ! router bgp 1 neighbor 192.168.10.2 remote-as 2 Note: In fact we only need one loopback interface |
R2 Initial Config interface Ethernet0/0 ip address 192.168.10.2 255.255.255.0 ! router bgp 2 neighbor 192.168.10.1 remote-as 1
|
By default, auto-summary is disabled in BGP so when we advertise the classful network (even with or without “mask 255.255.0.0” keyword):
R1(config)#router bgp 1 R1(config-router)#network 172.16.0.0
The classful network will not be placed into the BGP table:
R1#show ip bgp 172.16.0.0 %Network not in table
But now we will use the “auto-summary” feature to see the difference:
R1(config)#router bgp 1 R1(config-router)#auto-summary
Now check the BGP table again, we can see the summarized route:
R1#show ip bgp 172.16.0.0 BGP routing table entry for 172.16.0.0/16, version 17 Paths: (1 available, best #1, table default) Advertised to update-groups: 3 Refresh Epoch 1 Local 0.0.0.0 from 0.0.0.0 (172.16.160.1) Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best rx pathid: 0, tx pathid: 0x0
Also on R2 side, this summarized route is also installed into R2 routing table:
R2#show ip route --output omitted-- Gateway of last resort is not set B 172.16.0.0/16 [20/0] via 192.168.10.1, 00:05:25 192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.10.0/24 is directly connected, Ethernet0/0 L 192.168.10.2/32 is directly connected, Ethernet0/0
and
R2#show ip bgp --output omitted-- Network Next Hop Metric LocPrf Weight Path *> 172.16.0.0 192.168.10.1 0 0 1 i
What will happen if we advertise all the subnets of R1 via BGP? Will R2 receive all of them or just a summarized route as as above?
R1(config)#router bgp 1 R1(config-router)#network 172.16.128.0 mask 255.255.224.0 R1(config-router)#network 172.16.160.0 mask 255.255.224.0 R1(config-router)#network 172.16.192.0 mask 255.255.224.0 R1(config-router)#network 172.16.224.0 mask 255.255.224.0
Let’s check the BGP table of R2:
R2#show ip bgp --output omitted-- Network Next Hop Metric LocPrf Weight Path *> 172.16.0.0 192.168.10.1 0 0 1 i *> 172.16.128.0/19 192.168.10.1 0 0 1 i *> 172.16.160.0/19 192.168.10.1 0 0 1 i *> 172.16.192.0/19 192.168.10.1 0 0 1 i *> 172.16.224.0/19 192.168.10.1 0 0 1 i R2#show ip route bgp --output omitted-- Gateway of last resort is not set 172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks B 172.16.0.0/16 [20/0] via 192.168.10.1, 00:00:01 B 172.16.128.0/19 [20/0] via 192.168.10.1, 00:00:01 B 172.16.160.0/19 [20/0] via 192.168.10.1, 00:00:01 B 172.16.192.0/19 [20/0] via 192.168.10.1, 00:00:01 B 172.16.224.0/19 [20/0] via 192.168.10.1, 00:00:01
-> R1 advertised all the subnets along with the summarized route to R2.
================================================================================
For your information, above config is called auto summarization. If we want a manual summarization, we can do as follows (use “no auto-summary” command and remove all “network” commands for subnets under BGP first):
R1(config)#ip route 172.16.0.0 255.255.0.0 null0 R1(config)#router bgp 1 R1(config-router)#network 172.16.0.0
Or the last method of summarization is called “Aggregate Address”. We need to remove two “ip route” and “network” command above with “no ip route 172.16.0.0 255.255.0.0 null0” and “no network 172.16.0.0” before doing this method:
R1(config)#router bgp 1 R1(config-router)#network 172.16.128.0 mask 255.255.224.0 R1(config-router)#network 172.16.160.0 mask 255.255.224.0 R1(config-router)#network 172.16.192.0 mask 255.255.224.0 R1(config-router)#network 172.16.224.0 mask 255.255.224.0 R1(config-router)#aggregate-address 172.16.0.0 255.255.0.0 summary-only
On R2 we will only see the summarized route because of the “summary-only” keyword above:
R2#show ip bgp --output omitted-- Network Next Hop Metric LocPrf Weight Path *> 172.16.0.0 192.168.10.1 0 0 1 i R2#show ip route bgp --output omitted-- Gateway of last resort is not set B 172.16.0.0/16 [20/0] via 192.168.10.1, 00:05:13