How to advertise networks in BGP

In this lesson we’ll take a look how you can advertise networks in BGP. There are two methods how we can do this:

  • Network command
  • Redistribution

Just like our IGPs we can use the network command to advertise something or we can redistribute networks into BGP. There’s one big difference though, the network command for BGP behaves differently.

When you use any of the IGPs (RIP, OSPF or EIGRP) then the network command is used to activate the IGP on all interfaces that fall within the range of the network command.

BGP doesn’t care about interfaces, it doesn’t even look at them. When we use the network command in BGP then BGP will only look at the routing table. When it finds the network that matches the network command, it will install it in the BGP table.

Let me show you some examples to explain what I’m talking about. We will use the following two routers:

R1 R2 AS1 AS2 EBGP

R1 and R2 are in different autonomous systems so we use eBGP. Here is the BGP configuration:

R1#show running-config | section bgp
router bgp 1
 bgp log-neighbor-changes
 neighbor 192.168.12.2 remote-as 2
R2#show running-config | section bgp
router bgp 2
 bgp log-neighbor-changes
 neighbor 192.168.12.1 remote-as 1

Nothing special here, just plain eBGP between R1 and R2. Let’s advertise some networks in BGP…

Network Command

Let’s create a loopback interface with a network and advertise it in BGP:

R1(config)#interface loopback 1
R1(config-if)#ip address 1.1.1.1 255.255.255.0

R1(config)#router bgp 1
R1(config-router)#network 1.1.1.0 mask 255.255.255.0

Above we have created a loopback interface with network 1.1.1.0 /24, this is what we will advertise in BGP. Since we created a loopback interface, this network will be directly connected for R1:

R1#show ip route 1.1.1.0
Routing entry for 1.1.1.0/24
Known via "connected", distance 0, metric 0 (connected, via interface)
Advertised by bgp 1
Routing Descriptor Blocks:
* directly connected, via Loopback1
Route metric is 0, traffic share count is 1

Since it’s in the routing table, BGP will be able to install this network in the BGP table:

R1#show ip bgp
BGP table version is 2, local router ID is 192.168.12.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, x best-external, f RT-Filter
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.0/24       0.0.0.0                  0         32768 i

Since R1 has it in its BGP table it will be able to advertise it to R2:

R2#show ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.0/24, version 2
Paths: (1 available, best #1, table default)
  Not advertised to any peer
  1
    192.168.12.1 from 192.168.12.1 (192.168.12.1)
      Origin IGP, metric 0, localpref 100, valid, external, best

That’s all there is to it. Just use the network command to put the networks you want in the BGP table. One thing you have to be aware of is that you have to use the exact network and subnet mask for the network command. Let me give you an example:

R1(config)#interface loopback 2
R1(config-if)#ip address 11.11.11.11 255.255.255.255
R1(config)#router bgp 1
R1(config-router)#network 11.11.11.0 mask 255.255.255.0

I created a loopback interface with network 11.11.11.11 /32. BGP uses the network command to advertise 11.11.11.0 /24. This network will never be placed in the BGP table since the subnet mask doesn’t match:

R1#show ip bgp 11.11.11.11
% Network not in table

Be aware of this. Make sure you type the exact network address and subnet mask when advertising something in BGP. Let’s fix this:

R1(config)#router bgp 1
R1(config-router)#no network 11.11.11.0 mask 255.255.255.0
R1(config-router)#network 11.11.11.11 mask 255.255.255.255

With the correct network command, BGP will be able to advertise this network in the BGP table:

R1#show ip bgp 11.11.11.11
BGP routing table entry for 11.11.11.11/32, version 5
Paths: (1 available, best #1, table default)
  Advertised to update-groups:
     1
  Local
    0.0.0.0 from 0.0.0.0 (192.168.12.1)
      Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best

And because R1 has it in its BGP table, R2 will be able to learn it:

R2#show ip bgp | begin Network
   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.0/24       192.168.12.1             0             0 1 i
*> 11.11.11.11/32   192.168.12.1             0             0 1 i

Alright so far so good. What if we want to advertise a network that we don’t have? Let’s say that I want to advertise network 1.0.0.0 /8 in BGP. We won’t be able to advertise this network in BGP if it’s not in the routing table. To achieve this, we’ll put this network in our routing table:

We're Sorry, Full Content Access is for Members Only...

If you like to keep on reading, Become a Member Now! Here is why:

  • Learn any CCNA, CCNP and CCIE R&S Topic. Explained As Simple As Possible.
  • Try for Just $1. The Best Dollar You've Ever Spent on Your Cisco Career!
  • Full Access to our 657 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

551 Sign Ups in the last 30 days

satisfaction-guaranteed
100% Satisfaction Guaranteed!
You may cancel your monthly membership at any time.
No Questions Asked!

Forum Replies

  1. Hi Derek,
    There are three cases that must be considered for your question. I will answer your question directly first, and then mention the other two cases.

    Case #1:
    Think of “default-information originate” as a safety check. Suppose there was some careless BGP admin that told a router to redistribute some other protocol’s routes into BGP, say EIGRP. If that admin didn’t use a route-map or some other filter, and he didn’t think about that EIGRP was advertising a default route, the consequences could be really bad. You might not want all of your BGP peers to

    ... Continue reading in our forum

  2. Hi Rouzbeh,

    1. If no mask is specified, default mask is used, that is /8 in your example.
    2. When Rene said “exact mask has to be added in network command” meant that if we have a prefix in routing table (say 192.168.1.0/25), and we want this prefix to be injected in bgp with network command we should use
    router bgp 1
    network 192.168.1.0 255.255.255.128
    

    in our config.
    If we are going to use:

    router bgp 1
    network 192.168.1.0
    

    , router will assume an implicit mask (255.255.255.0).
    So 192.168.1.0/24 prefix will not enter bgp table because we do not have 192.168.1.0/2

    ... Continue reading in our forum

  3. Hello Mohammad

    BGP does use triggered updates when it learns of a change on its internal domain. However, there are a few things that affect the operation of this triggering that will in turn affect the behaviour of BGP.

    Lets say that there is a network on the internal domain that is learned via OSPF, and this network continually goes up and down. BGP updates will be affected by the following:

    1. The detection of the changes - how fast does the router detect that the OSPF route is down? This depends primarily on the BGP scanner process. This process walks th

    ... Continue reading in our forum

  4. Hello Hussein,

    That is no problem. You advertise the network with the network command and then use route-maps to filter what you need.

    Here’s R1 advertising to R2:

    R1#show ip bgp neighbors 192.168.12.2 advertised-routes 
    BGP table version is 4, local router ID is 1.1.1.1
    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
                  r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
                  x best-external, a additional-path, c RIB-compressed, 
                  t secondary path, 
    Origin codes: i - IGP, e - EGP, 
    ... Continue reading in our forum

  5. Hello Hussein,

    I’m afraid you can’t do this. With BGP, the network command adds something to the global BGP table and then you can use route-maps to decide if you want to advertise something or not to your neighbors.

    What exactly are you trying to do? If you want something where you don’t advertise anything to a neighbor unless you configure it to do so, then you still could use a route-map with some regular expressions. For example, let’s say you don’t want to advertise anything by default that you added to the BGP table then you can use a route-map with a reg

    ... Continue reading in our forum

48 more replies! Ask a question or join the discussion by visiting our Community Forum