Sei sulla pagina 1di 8

8/8/2016 How to advertise networks in BGP | NetworkLessons.

com

Search...

Table of Contents
BGP

Unit 1: Introduction to BGP


Introduction to BGP

eBGP (external BGP)

eBGP Multi-Hop

iBGP (internal BGP)

How to read the BGP Table

How to advertise networks in BGP

iBGP Next Hop Self

BGP Auto-summary

Unit 2: BGP Neighbor Adjacency


Unit 3: BGP Attributes
Unit 4: BGP Communities
Unit 5: BGP Filtering
Unit 6: Advanced BGP Features

You are here: Home » BGP

How to advertise networks in BGP


29 votes
https://networklessons.com/bgp/how­to­advertise­networks­in­bgp/ 1/16
8/8/2016 How to advertise networks in BGP | NetworkLessons.com

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 diㆨerence though, the network command for BGP behaves
diㆨerently.

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 ⦜哈nds 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 and R2 are in diㆨerent autonomous systems so we use eBGP. Here is the BGP con⦜哈guration:

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

https://networklessons.com/bgp/how­to­advertise­networks­in­bgp/ 2/16
8/8/2016 How to advertise networks in BGP | NetworkLessons.com

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 

https://networklessons.com/bgp/how­to­advertise­networks­in­bgp/ 3/16
8/8/2016 How to advertise networks in BGP | NetworkLessons.com

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 ⦜哈x this:

https://networklessons.com/bgp/how­to­advertise­networks­in­bgp/ 4/16
8/8/2016 How to advertise networks in BGP | NetworkLessons.com

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:

R1(config)#ip route 1.0.0.0 255.0.0.0 null 0

This can be done with a static route that points to the null interface, everything you send to the
null interface will be discarded. Using a static route like this is also called a discard route.

Network 1.0.0.0 /8 is now in the routing table:

https://networklessons.com/bgp/how­to­advertise­networks­in­bgp/ 5/16
8/8/2016 How to advertise networks in BGP | NetworkLessons.com

R1#show ip route 1.0.0.0 
Routing entry for 1.0.0.0/8, 3 known subnets 
  Attached (3 connections) 
  Variably subnetted with 3 masks 
S        1.0.0.0/8 is directly connected, Null0 
C        1.1.1.0/24 is directly connected, Loopback1 
L        1.1.1.1/32 is directly connected, Loopback1

This allows BGP to advertise it:

R1(config)#router bgp 1 
R1(config‐router)#network 1.0.0.0 mask 255.0.0.0

Take a look at the BGP table of R1 and R2:

R1#show ip bgp 1.0.0.0 
BGP routing table entry for 1.0.0.0/8, version 6 
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

R2#show ip bgp 1.0.0.0 
BGP routing table entry for 1.0.0.0/8, version 6 
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

R1 was able to install network 1.0.0.0 /8 in its BGP table and advertises it to R2.

Redistribution
https://networklessons.com/bgp/how­to­advertise­networks­in­bgp/ 6/16
8/8/2016 How to advertise networks in BGP | NetworkLessons.com

Redistribution
Instead of using the network command we can also redistribute something into BGP.  To
demonstrate this I will create a new loopback interface, advertise it in OSPF and then redistribute it
into BGP:

R1(config)#interface loopback 3 
R1(config‐if)#ip address 111.111.111.111 255.255.255.0 
R1(config‐if)#exit 

R1(config)#router ospf 1 
R1(config‐router)#network 111.111.111.0 0.0.0.255 area 0 

R1(config)#router bgp 1 
R1(config‐router)#redistribute ospf 1

I created a loopback with network 111.111.111.0 /24, advertised it in OSPF and redistributed it into
BGP. Let's check the BGP table:

R1#show ip bgp | begin Network 
   Network          Next Hop            Metric LocPrf Weight Path 
*> 1.0.0.0          0.0.0.0                  0         32768 i 
*> 1.1.1.0/24       0.0.0.0                  0         32768 i 
*> 11.11.11.11/32   0.0.0.0                  0         32768 i 
*> 111.111.111.0/24 0.0.0.0                  0         32768 ?

R2#show ip bgp | begin Network 
   Network          Next Hop            Metric LocPrf Weight Path 
*> 1.0.0.0          192.168.12.1             0             0 1 i 
*> 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 
*> 111.111.111.0/24 192.168.12.1             0             0 1 ?

There we go, R1 placed the network in its BGP table and was able to advertise it to R2.

https://networklessons.com/bgp/how­to­advertise­networks­in­bgp/ 7/16
8/8/2016 How to advertise networks in BGP | NetworkLessons.com

I hope this lesson has been useful to understand how to advertise something in BGP, if you have
any question feel free to leave a comment!

Rate this Lesson:

« Previous Lesson
How to read the BGP Table
Next Lesson
iBGP Next Hop Self »
Home › Forums › How to advertise networks in BGP

This topic contains 18 replies, has 8 voices, and was last updated by   rouzbeh t 3 weeks, 5 days
ago.

Viewing 15 posts - 1 through 15 (of 18 total)


12→
Author
Posts  | Subscribe
July 4, 2015 at 00:43 #10626 Reply

ALFREDO V
Participant
Hi Rene,

What is the use of the null0, I learned that is the trash can of the packets but never fully
understand when will I use it.

Please advise

July 5, 2015 at 18:35 #10627 Reply


https://networklessons.com/bgp/how­to­advertise­networks­in­bgp/ 8/16

Potrebbero piacerti anche