How to advertise networks in BGP

Ok, thanks Rene, thats kind of what I was thinking. So I would potentially end up with multiple route-maps for different neighbors to filter out undesirable routes for specific neighbors while by default redistributed routes would all get advertised to all neighbors. Actually, the question came from attempt to move configuration from Juniper to CISCO. In Juniper its another way around - by default nothing is advertised, need to have a policy indicating what neighbors the routes are redistributed to. Certainly better in this scenario. Just another proof no vendor is better or worse than another - shortcoming in one’s product is the strong feature in competitor’s. :slight_smile:

Hi, I have a question about the BGP network command.

In the article you state this:

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.

So if, for example, the router learns about a network via EIGRP and installs it in its routing table, can that network be advertised directly into BGP with the network command, without redistributing EIGRP into BGP?

Thanks for any help :slight_smile:

Hello Jeremy

Yes, that is exactly correct. BGP can advertise networks using either the network command as described, or using redistribution.

I hope this has been helpful!

Laz

Thank you, Laz, that answers my question perfectly.

1 Like

Hi,
Ospf add entry from ospf database to routing table .
But bgp add from routing table to bgp table
Why it is like that

Thanks

Hello Sims

This is one of the fundamental differences between IGPs and BGP. To put it more clearly, OSPF will choose the best route to a particular destination found in its database into the routing table.

BGP on the other hand works a little differently. In order for a network to be installed in the BGP table, as it says in the lesson, it must be either installed using the network command or redistributed from another routing protocol. Now as you mention, in the first case, a prerequisite is that the destination address/subnet mask exist exactly in the routing table. (In the second case, since it is being redistributed, you know that it is already in the routing table).

BGP requires that any local configurations used to allow a router to learn of networks must have, as a prerequisite, a route to that network in the routing table. This ensures that any network that is advertised using a specific local configuration (network/redistribution) can indeed be reached from that router.

Now notice I’ve stressed “local configuration” in my statements above, refering to the network and redistribution features of BGP. The reason I have done this is because a router can learn about BGP routes from one additional source: neighboring BGP routers. Any routes that are advertised from neighbors and reach a router are automatically put in the BGP table without the prerequisite of requiring an exact mach in the local routing table. From there, the best match is installed in the routing table.

The result is that any routes in the BGP table that are in there because of the network command or redistribution, never enter the routing table as BGP routes, but either as static routes or routes learned by an IGP. Only BGP routes learned from neighbors actually find themselves in the routing table as BGP learned routes.

I hope this has been helpful!

Laz

HI,
Why ibgp requires an IGP routing protocol and BGP does not require igp
Thanks

Hi Sims

Thanks for mentioning this. All of the information stated in the previous post has to do with iBGP, that is, BGP routes that are shared between BGP routers in the same AS.

When configured correctly, an IGP will only function within the boundaries of the BGP AS. No routes should be learned between different BGP AS’es via IGPs such as OSPF or EIGRP. Only BGP should be used to learn routes between BGP AS’es.

It is this very structure of BGP that makes eBGP not require the use of an IGP. The destination that exists outside of the local AS should not be known by any IGP internal to the AS. This is why eBGP does not require the use of an IGP.

I hope this has been helpful!

Laz

You mean iBGP or BGp

What you mean by BGP routes are shared…

Thanks

Can you just simplify this :slight_smile:

Hello Sims

I mean iBGP. In other words, routes that are shared between routers in the same AS. That’s the definition of iBGP, peerings between BGP routers with the same AS. iBGP shares or advertises network destinations between BGP routers in the same AS. So the information stated in the previous post refers to iBGP. iBGP requires a routing protocol within the AS, while eBGP does not (this was your original question).

To clarify, BGP requires any configurations using the network command or redistribution, to have the destination network in question already in the routing table. Only if this prerequisite is fulfilled will a BGP router be able to advertise the specific network to its iBGP peers. That’s what I mean by local configurations (network/redistribution.)

This means that any routes found in the BGP table are in there because of one of two things:

  1. The above prerequisites have been fulfilled (i.e. the network command is used or redistribution takes place AND the destination networks are in the routing table either from an IGP or a static route)
  2. The routes are in the BGP table because they have been learned directly from a BGP peer using the BGP protocol. This doesn’t have the “must be in the routing table” prerequisite.

I hope this has been helpful!

Laz

Hi,
How can we know the details of the route originate .
Thanks

Hello Sims

If you use the show ip bgp command you will see that it includes an origin code. Cisco states the following:

This is the origin of the entry. The origin code is placed at the end of each line in the table. It can be one of the following values:

a—Path is selected as an additional path.
i—Entry originated from an Interior Gateway Protocol (IGP) and was advertised with a network router configuration command.
e—Entry originated from an Exterior Gateway Protocol (EGP).
?—Origin of the path is not clear. Usually, this is a router that is redistributed into BGP from an IGP.

Now if you use the show ip bgp <network> command where network is a particular IP address, you will be able to see more information about the origin. For example, this output from the lesson:

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

It shows that the origin is IGP, and it states the IP address of the router from which it was learned (192.168.12.1).

I hope this has been helpful!

Laz

Hello @ReneMolenaar,

I used a network command to advertise the following subnets:
192.168.4.0(a directly connected link between two routers BGP routers)
5.5.5.0/24 (directly connected, Loopback0)
But my configuration and BGP table installed 192.168.4.0 for 192.168.4.0/24.

router bgp 3
 bgp log-neighbor-changes
 network 5.5.5.0 mask 255.255.255.0
 network 192.168.4.0
 neighbor 192.168.4.4 remote-as 2


R5#show ip bgp  | be Network
     Network          Next Hop            Metric LocPrf Weight Path
 *>  5.5.5.0/24       0.0.0.0                  0         32768 i
 *>  192.168.4.0      0.0.0.0                  0         32768 i

Why is the subnet mask omitted for 192.168.4.0 and not for 5.5.5.0/24?

Hello Nonso

I attempted to recreate the specific output on my lab, but I was unable to get a result without a prefix/subnet mask in the network column. However, searching Cisco documentation, there are cases where the prefix does not appear. I have not been able to determine why this is the case, although whenever the prefix is not shown, it always corresponds to the classful prefix of that particular network.

It may also be IOS version related as well. I’ll let @ReneMolenaar ene know to see if he has any more insight into this…

Laz

“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” - Could you tell a practical use case of this situation where we advertise with null route.

Hello Ajith

Let’s say you have the following topology:
image
Imagine that behind R1, you have the following prefixes:

172.16.1.0/24
172.16.2.0/24
172.16.3.0/24
172.16.4.0/24
172.16.5.0/24

You configure R1 as follows:

R1#show run | section router bgp
router bgp 1
 no synchronization
 bgp log-neighbor-changes
 aggregate-address 172.16.0.0 255.255.0.0
 neighbor 192.168.12.2 remote-as 2
 no auto-summary 

Notice that instead of advertising each and every prefix, you use the aggregate-address command to indicate the summary you want to advertise.

However, because BGP will only advertise whatever already exists in the routing table, with an exact prefix length, R2 will not receive these routes. Remember, the routing table will only have the individual prefixes rather than the summary. To remedy this, you can create the following static route:

R1(config)#ip route 172.16.0.0 255.255.0.0 null 0

and replace the aggregate-address command in the BGP configuration with this one:

R1(config-router)#network 172.16.0.0 mask 255.255.0.0

This solution is detailed in the following lesson under the BGP Summarization section. You can take a look for more details:

I hope this has been helpful!

Laz

Thank you! I’m clear now.

1 Like

Hello,
Please I would like to clarify the redistribution example in the topic.
Under router bgp 1, redistribute ospf 1.
This command imports all routes under the ospf process 1 into bgp process 1?

What if I want to redistribute just a single subnet from ospf process.

Thanks

Hello Anuoluwapo

Yes, that is correct. If you wanted to redistribute only specific prefixes, then you would have to use a route-map. Specifically, this could be done using the following command:

R2(config-router)#redistribute ospf 1 route-map ?
  WORD  Pointer to route-map entries

For more information about route-maps, take a look at the following lesson:

I hope this has been helpful!

Laz