JunOS BGP
In this Tutorial We will be discussing how to setup an External Border Gateway Protocol (EBGP) between two routers.
Prerequisites
To complete this tutorial, you will need:
- A laptop running Linux or MacOS. for this tutorial I will be using a laptop running Ubuntu 16
- A console cable. Since all the new laptops today don't come with a USB port, you will need a USB to Console adapter
- The program "Screen"
If you don't have "screen" install it with the command below
sudo apt-get install screen
The Goal
Our goal is to setup the network like in the above image.
We have 2 offices. One in Texas and the other one in San Fransisco. Both offices have a Juniper MX80 router. The Texas router cr1-tx is in AS 17 and the San Fransico router cr1-sfo is in AS 29. We need to setup an External Border Gateway Protocol (EBGP) to connect both offices. If we were to connect 2 router in the same AS, we was going to use an IBGP (Internal Border Gateway Protocol) such as OSPF. We will discuss about this in another tutorial.
Router Setup
We are going to perform the basic setup of the router like we did for the switches in [[JunOS Basics[1]]
The process is the same. Please refer to the link above
- Access the router
- Setup the root password
- Setup the device name
- Create a privilege user
- setup Management interface and enable SSH
Note: for the management setup, since we are using a router the management interface on the MX80 is not me0 like on the switch. The management interface is fxp0. See below for the how the management interface is setup.
root@cr1-tx# show interfaces
fxp0 {
description mgmt;
unit 0 {
family inet {
address 10.192.0.103/24;
}
}
}
After setting up all the basic on both routers, it is time to process to the EBGP setup.
EBGP Setup
On cr1-tx
We are going to use the interface xe-0/0/0 which is a 10Gbs interfaces.
Step 1: Set interface description
set interfaces xe-0/0/0 description to-cr1-sfo
- Check before committing
root@cr1-tx# show | compare
[edit interfaces]
+ xe-0/0/0 {
+ description to-cr1-sfo;
+ }
Step 2: Assign an IP address to the interface
set interfaces xe-0/0/0 unit 0 family inet address 10.10.10.1/30
- Check before committing
root@cr1-tx# show | compare
[edit interfaces xe-0/0/0]
+ unit 0 {
+ family inet {
+ address 10.10.10.1/30;
+ }
+ }
Step 3: Set the Autonomous system (AS) number To set the AS number we need to be in the routing-options level for that type in
edit routing-options
[edit routing-options] root@cr1-tx# set autonomous-system 17
step 4 : Create the BGP group/ add external neighbor address
To do this we need to be in the protocols bgp group external-peers level
Type "exit" to leave the routing-options level and then type in
[edit] root@cr1-tx# edit protocols bgp group external-peers [edit protocols bgp group external-peers] root@cr1-tx# set neighbor 10.10.10.2
Step 5: Specify external AS number
[edit protocols bgp group external-peers] root@cr1-tx# set peer-as 29
Step 6: Set the peer type
[edit protocols bgp group external-peers] root@cr1-tx# set type external
Type " exit"
Checking
[edit]
root@cr1-tx# show interfaces
xe-0/0/0 {
description to-cr1-sfo;
unit 0 {
family inet {
address 10.10.10.1/30;
}
}
}
[edit]
root@cr1-tx# show protocols
bgp {
group external-peers {
type external;
peer-as 29;
neighbor 10.10.10.2;
}
}
[edit] root@cr1-tx# show routing-options autonomous-system 17;
If everything looks good, you can commit
Verification
In operation mode,do show run neighbor
root@cr1-tx> show bgp neighbor Peer: 10.10.10.2 AS 29 Local: unspecified AS 17 Type: External State: Idle Flags: <PeerInterfaceError> Last State: NoState Last Event: NoEvent Last Error: None Options: <Preference PeerAS Refresh> Holdtime: 90 Preference: 170 Number of flaps: 0
We can see from the output the Local= unspecified and the state is Idle Last State: NoState Last Event: NoEvent. The reason being that we haven't setup cr1-sfo yet.
On cr1-sfo
We are going to use the interface xe-0/0/0 which is a 10Gbs interfaces.
Step 1: Set interface description
[edit] root@cr1-sfo# set interfaces xe-0/0/0 description to-cr1-sfo
Step 2: Assign an IP address to the interface
set interfaces xe-0/0/0 unit 0 family inet address 10.10.10.2/30
- Check before committing
root@cr1-sfo# show | compare
[edit interfaces]
+ xe-0/0/0 {
+ description to-cr1-sfo;
+ unit 0 {
+ family inet {
+ address 10.10.10.2/30;
+ }
+ }
+ }
Step 3: Set the Autonomous system (AS) number
To set the AS number we need to be in the routing-options level for that type in
edit routing-options
[edit routing-options] root@cr1-tx# set autonomous-system 29
step 4 : Create the BGP group/ add external neighbor address
To do this we need to be in the protocols bgp group external-peers level
Type "exit" to leave the routing-options level and then type in
[edit] root@cr1-tx# edit protocols bgp group external-peers [edit protocols bgp group external-peers] root@cr1-tx# set neighbor 10.10.10.1
Step 5: Specify external AS number
[edit protocols bgp group external-peers] root@cr1-tx# set peer-as 17
Step 6: Set the peer type
[edit protocols bgp group external-peers] root@cr1-tx# set type external
Type " exit"
Checking
[edit]
root@cr1-sfo# show interfaces
xe-0/0/0 {
description cr1-sfo;
unit 0 {
family inet {
address 10.10.10.2/30;
}
}
}
[edit]
root@cr1-sfo# show protocols
bgp {
group external-peers {
type external;
peer-as 17;
neighbor 10.10.10.1;
}
}
[edit] root@cr1-sfo# show routing-options autonomous-system 29;