There are many ways to advertise BGP routes in Juniper. Today we will learn a few of those. This is the 3rd article on Juniper BGP series. You can check other articles of this series from below list. This list will be updated day by day.

For today’s article, below topology is chosen where our juniper router (Juniper-RTR) will advertise its routes towards ISP-RTR router. We will advertise routes based on protocols and route filter. So, let’s get started.

 

How to advertise BGP routes in Juniper

 
Routes advertisement will be completed in two steps. These are- 1. adding policy-statement, and 2. adding policy in bgp group.

Adding Policy-Statemenet

How to advertise connected (direct) routes into BGP

To advertise connected routes or direct routes in BGP, you need to run below commands-

set policy-options policy-statement <policy> term <term>  from protocol direct
set policy-options policy-statement <policy> term <term> then accept

According our LAB, we have added below configuration.

set policy-options policy-statement OUR-ROUTE-TO-EBGP term 1 from protocol direct
set policy-options policy-statement OUR-ROUTE-TO-EBGP term 1 then accept

Below are the output of our candidate configuration.

[edit]
root@Juniper-RTR# show | compare 
[edit policy-options]
+   policy-statement OUR-ROUTE-TO-EBGP {
+       term 1 {
+           from protocol direct;
+           then accept;
+       }
+   }

[edit]
root@Juniper-RTR# 

How to advertise Static routes into BGP

If you want to advertise static routes directly into the bgp, then below are the commands.

set policy-options policy-statement <policy> term <term>  from protocol static
set policy-options policy-statement <policy> term <term> then accept

According our LAB, we have added below configuration.

set policy-options policy-statement OUR-ROUTE-TO-EBGP term 2 from protocol static
set policy-options policy-statement OUR-ROUTE-TO-EBGP term 2 then accept

Let’s check the configuration, before committing by using show | compare command.

[edit]
root@Juniper-RTR# show | compare 
[edit policy-options]
+   policy-statement OUR-ROUTE-TO-EBGP {
+       term 2 {
+           from protocol static;
+           then accept;
+       }
+   }

[edit]
root@Juniper-RTR#

How to advertise OSPF routes into bgp

The configuration is similar like static.

set policy-options policy-statement <policy> term <term>  from protocol ospf
set policy-options policy-statement <policy> term <term> then accept

According our LAB, we have added below configuration.

set policy-options policy-statement OUR-ROUTE-TO-EBGP term 3 from protocol ospf
set policy-options policy-statement OUR-ROUTE-TO-EBGP term 3 then accept

You can check candidate configuration by running show | compare command.

[edit]
root@Juniper-RTR# show | compare 
[edit policy-options]
+   policy-statement OUR-ROUTE-TO-EBGP {
+       term 3 {
+           from protocol ospf;
+           then accept;
+       }
+   }

How to advertise IS-IS routes into bgp

Now we will advertise IS-IS routes into BGP.

set policy-options policy-statement <policy> term <term>  from protocol isis
set policy-options policy-statement <policy> term <term> then accept

According our LAB, we have added below configuration.

set policy-options policy-statement OUR-ROUTE-TO-EBGP term 4 from protocol isis
set policy-options policy-statement OUR-ROUTE-TO-EBGP term 4 then accept

Run show | compare command to check candidate configuration.

[edit]
root@Juniper-RTR# show | compare 
[edit policy-options]
+   policy-statement OUR-ROUTE-TO-EBGP {
+       term 4 {
+           from protocol isis;
+           then accept;
+       }
+   }

How to advertise routes using route-filter into bgp

Now, we will advertise routes in BGP using route-filter command.

set policy-options policy-statement <policy> term <term>  from route-filter
set policy-options policy-statement <policy> term <term> then accept

In our case, we will call it term 5 and add all the routes.

set policy-options policy-statement OUR-ROUTE-TO-EBGP term 5 from route-filter 103.21.40.0/20 upto /24
set policy-options policy-statement OUR-ROUTE-TO-EBGP term 5 route-filter 59.100.99.0/24 exact
set policy-options policy-statement OUR-ROUTE-TO-EBGP term 5 then accept

Adding Policy in BGP group

To add policy group, we need to run below command-

set protocols bgp group <group-name> export <policy-statement>

In my lab, here is the final output-

protocols {
    bgp {
        group EXTERNAL {
            type external;
            export OUR-ROUTE-TO-EBGP;   
            neighbor 1.1.1.1 {
                peer-as 10;
            }
        }
    }

Written by Rajib Kumer Das

I am Rajib Kumer Das, a network engineer with 8+ years of experience in multi-vendor environment. In my current position, I am responsible to take care critical projects and it's support cases. I do have several vendor certificates and have plans to go further.

Leave a Comment

Your email address will not be published. Required fields are marked *