BGP on Juniper for beginners

BGP on Juniper for beginners!
Here in this lab I’m going to do enjoy with configuring BGP on Juniper. You should have at least following knowledge before trying to configure BGP.
1
Sound knowledge about Routing Policy on Juniper
Sound knowledge about IGP (OSPF, ISIS)
What is BGP?
Basic terminology of BGP (AS Number, IBGP, EBGP)
When / when not need BGP?
How BGP Works?


Network Scenario
Here in this Lab we have three different AS numbered AS10 which is configured on R1, AS20 which is configured on R2 & R3 and Finally AS30 which is configured on R4. We have a network 172.16.0.0/22 which belongs to AS10 configured on the Loopback interface of R1 and network 172.16.4.0/22 which belongs to AS30 configured on the loopback interface of R4.

Now let’s move to the topology information
SN
Router
AS
Interface IP
1
R1
10
lo0.1 : 172.16.0.1/24
lo0.1 : 172.16.1.1/24
lo0.1 : 172.16.2.1/24
lo0.1 : 172.16.3.1/24
em0.0 : 192.168.12.1/24
2
R2
20
lo0.1 : 2.2.2.2/32
em1.0 : 192.168.12.2/24
em0.0 : 192.168.23.2/24
3
R3
20
lo0.1 : 3.3.3.3/32
em1.0 : 192.168.23.3/24
em0.0 : 192.168.34.3/24
4
R4
30
lo0.1 : 172.16.4.1/24
lo0.1 : 172.16.5.1/24
lo0.1 : 172.16.6.1/24
lo0.1 : 172.16.7.1/24
em1.0 : 192.168.34.4/24

First of all we are going to configure Host Name, Authentication Password, and Interface IP. Let’s begin with R1. 

Step-1. Configuring Hostname, Authentication Password and IP address on the interface.

login: root

root@% cli

root> configure

root# set system host-name R1

root# set system root-authentication plain-text-password

root# set interface em0.0 family inet address 192.168.12.1/24

root# set interface lo0.1 family inet address 172.16.0.1/24

root# set interface lo0.1 family inet address 172.16.1.1/24

root# set interface lo0.1 family inet address 172.16.2.1/24

root# set interface lo0.1 family inet address 172.16.3.1/24


I’m not going to configure R2, R3 and R4 here because the task is identical to configure Host Name, Authentication Password and IP address on the interface. 

Step-2. Configure Autonomous System Number, BGP (EBGP/IBGP) Protocol, Policy as per needs.

Here I’m going to Configure R2 for Step-2 task

Configuring AS Number
root@R2#set routing-options autonomous-system 20

Configuring External BGP (EBGP with AS10)
root@R2#set protocol bgp group Ext-AS10 neighbor 192.168.12.1 peer-as 10

root@R2#set protocol bgp group Ext-AS10 type   external

Configuring Internal BGP (IBGP with AS20)
root@R2#set protocol bgp group Int-AS20 neighbor 3.3.3.3

root@R2#set protocol bgp group Int-AS20 type internal

root@R2#set protocol bgp group Int-AS20 local-address 2.2.2.2

Explanation: In this particular scenario if I configured IBGP with 192.168.23.3 instead of 3.3.3.3 it will be working fine. Because it is directly connected to R3. But in general IBGP is configured in the loopback interface because multiple links can be exists in the production network. So to do the best practice I’m configuring here with loopback interface of R3. Don’t forget to define local-address otherwise IBGP will not establish because R3 will be peered with R2 loopback interface. If you forget do define local-address, source of the bgp packet will be 192.168.23.2 and it will not matched with the address defined by R3 i.e. neighbor 2.2.2.2, to avoid such issue don’t forget to define local address. 

Here I’m not going to configure R1, R3 and R4 because task is identical as shown in the above.
After configuring R1, R3 and R4 you will notice EBGP between R1 & R2 and R3 & R4 will be established. But IBGP between R2 & R3 will not be established.

Why?

We have configured IBGP with the loopback interface of R2 and R3. Loopback interface is not reachable from each other. Here I’m going to configure OSPF between R2 and R3 to solve the reachability issue. Multiple methods are available to accomplish the task. 

I’m configuring OSPF on R2 for sample
root@R2# set protocol ospf area 0 interface lo0.1

root@R2# set protocol ospf area 0 interface em0.0

Step-3. Advertise Network
Now it’s time to advertise 172.16.0.0/24 network to the EBGP AS20 from AS10 and 172.16.4.0/24 network from AS30 to AS 20. To accomplish the task I’m going to configure Policy on R1
root@R1# set policy-options policy-statement Ext-Local term To-AS20 from interface lo0.1

root@R1# set policy-options policy-statement Ext-Local term To-AS20 then accept

roo@R1# set protocol bgp group Ext export Ext-Local

Here I’m not going to configure policy on R4 because task is identical to each other.

Now you will encounter another problem. The Route Advertised from R1 will be displayed on R2 but not on R3 and same thing happen to Route Advertised from R4. Route Advertised from R4 will be displayed on R3 but not on R2.

Router 2 is advertising route receive from R1 which shown from the following output

root@R2> show route advertising-protocol bgp 3.3.3.3



inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden)

  Prefix                  Nexthop              MED     Lclpref    AS path

* 172.16.0.0/24           192.168.12.1                 100        10 I

* 172.16.1.0/24           192.168.12.1                 100        10 I

* 172.16.2.0/24           192.168.12.1                 100        10 I

* 172.16.3.0/24           192.168.12.1                 100        10 I

But R3 is not receiving route advertising from R2 which shown from the following output

root@R3> show route receive-protocol bgp 2.2.2.2



inet.0: 11 destinations, 11 routes (7 active, 0 holddown, 4 hidden)


From the above output we see 4 routes are hidden. Let’s find what are them? Hidden routes are shown as bellow
root@R3> show route hidden



inet.0: 11 destinations, 11 routes (7 active, 0 holddown, 4 hidden)

+ = Active Route, - = Last Active, * = Both



172.16.0.0/24       [BGP/170] 00:11:14, localpref 100, from 2.2.2.2

                      AS path: 10 I

                      Unusable

172.16.1.0/24       [BGP/170] 00:11:14, localpref 100, from 2.2.2.2

                      AS path: 10 I

                      Unusable

172.16.2.0/24       [BGP/170] 00:11:14, localpref 100, from 2.2.2.2

                      AS path: 10 I

                      Unusable

172.16.3.0/24       [BGP/170] 00:11:14, localpref 100, from 2.2.2.2

                      AS path: 10 I

                      Unusable


From the above output we can see these routes are unusable. But why ? Let’s find out the root cause.
Router 2 is advertising route receive from R1 which shown from the following output

root@R2> show route advertising-protocol bgp 3.3.3.3



inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden)

  Prefix                  Nexthop              MED     Lclpref    AS path

* 172.16.0.0/24           192.168.12.1                 100        10 I

* 172.16.1.0/24           192.168.12.1                 100        10 I

* 172.16.2.0/24           192.168.12.1                 100        10 I

* 172.16.3.0/24           192.168.12.1                 100        10 I

When BGP router receives routes from the Peer it check different attribute before moving routes in the Local-RIB. BGP Next-hop attribute states that if next hop value is not reachable from the local router that route will be discarded.  As we see from the above output Nexthop address is 192.168.12.1 is not reachable from R3 so the router discarded route.  
To fix the issue we have lots of way but I’m going to change the next-hop value when the router advertises routes which were received from BGP with the help of Policy.  

I’m going to configure On R2.

root@R2 # set policy-options policy-statement TO-IBGP term advt from protocol bgp

root@R2 # set policy-options policy-statement TO-IBGP term advt then next-hop self

root@R2 # set protocol bgp group Int-AS20 export TO-IBGP

Here I’m not going to configure R3 because configuration is identical to R2.

Enjoy !

Comments

Popular Posts Last 30 days

Site-to-Site IPSec VPN Cisco-Juniper

के हो साइबर सेक्युरिटि ? हाम्रा बैंक कति सुरक्षित ?

Lets Play with BGP