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.
- Part-1: How to configure eBGP on Juniper Router
- Part-2: How to configure iBGP on Juniper Router
- Part-3: How to advertise BGP routes in Juniper (this article)
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.
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; } } }
In your term 5 config you have omitted a ‘from’ statement on line 2.
i have a question. in the policy statement if there is no match condition does that mean it will inherit the directly connected and static route prefixes. i meant the prefixes will be accepted from all the protocols right ? i have a scenario where i received a default route from my upstream device using ibgp and i have a ibgp session with RR and when i issue advertising-protocol bgp command i see that default route is advertised to neigh. but ibgp split horizon should kick in and that default route should not be advertised right ?