Basic BGP for JunOS pt2

By | May 5, 2012

For this post we will be using the following network diagram. Our objective for this post is to be able to get from JUNOS2 to R1.

For this post we will be focusing on the router JUNOS1 for most of the configuration. To begin with we need to set up the interface ip address on all the routers. Once this is done we need to set up bgp.

JUNOS1

[edit]
root@Junos01# set routing-options autonomous-system 200
[edit]
root@Junos01# show protocols bgp
group eBGP {
    type external;
    peer-as 100;
    neighbor 172.16.1.2;
}
group iBGP {
    type internal;
    peer-as 200;
    neighbor 192.168.1.2;
}

On the cisco router we have created 3 loopback interfaces to add them as part of the bgp process.

!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 23.0.0.0 mask 255.255.255.0
 network 24.0.0.0 mask 255.255.255.0
 network 25.0.0.0 mask 255.255.255.0
 neighbor 172.16.1.1 remote-as 200
 no auto-summary
!

Now lets check the neighbors.

We can see we have our 2 neighbors now lets have a look at the routes on this router

We can see we have all the routes we need. Now lets have a look at JUNOS2’s routes

Ok we can see there is a problem we don’t have the correct routes on JUNOS2. Now in order for routes to enter the BGP routing table the next-hop address need to be a valid address or the routes would not enter in the routing table. Therefore on router JUNOS1 we need to set the next hop to its self. To do this we need to create a routing policy.

[edit]
root@Junos01# show policy-options
policy-statement NEXT-HOP {
    term 1 {
        from protocol bgp;
        then {
            next-hop self;
        }
    }
}
[edit]
root@Junos01# show protocols bgp group iBGP
type internal;
export NEXT-HOP;
peer-as 200;
neighbor 192.168.1.2;

The policy gets any routes from BGP and puts the next hop as its self. This is applyed under the group we created for iBGP peers. Now lets have a look at the routing table for JUNOS2.

We can now see we have to correct routes in the routing table for JUNOS2. We now need to have a look at the routing table for R1 and make sure we have teh 192.168.1.x network init.

We can see again we have an issue. We don’t have any BGP routes in the routing table. We now need to redistribute the connected interface as part of the BGP process on JUNOS1 so R1 gets the routes it need to get to JUNOS2.

[edit]
root@Junos01# show policy-options
policy-statement CON {
    term 1 {
        from {
            protocol direct;
            route-filter 192.168.1.0/24 exact;
        }
        then accept;
    }
}
[edit]
root@Junos01# show protocols bgp group eBGP
type external;
export CON;
peer-as 100;
neighbor 172.16.1.2;

We need to filter the routes as we don’t want the route 172.16.1.x as part of BGP as this is our directley connected interface. Now lets see if we have the correct route we need on R1

Now we have the route 192.168.1.0/24 learnt from BGP via JUNOS1. Now lets try a ping from JUNOS2 to a loopback on R1.

We can see we have full connectivity bewteen all the routers and have completed our object.