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
Goal 1
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;
Now that we have cr1-sfo setup let us go back to cr1-tx and run again "show bgp neighbor"
Verification
- On cr1-tx
root@cr1-tx> show bgp neighbor Peer: 10.10.10.2+55085 AS 29 Local: 10.10.10.1+179 AS 17 Type: External State: Established Flags: <Sync> Last State: OpenConfirm Last Event: RecvKeepAlive Last Error: None Options: <Preference PeerAS Refresh> Holdtime: 90 Preference: 170 Number of flaps: 0 Peer ID: 10.10.10.2 Local ID: 10.10.10.1 Active Holdtime: 90 Keepalive Interval: 30 Group index: 0 Peer index: 0 BFD: disabled, down Local Interface: xe-0/0/0.0 NLRI for restart configured on peer: inet-unicast NLRI advertised by peer: inet-unicast NLRI for this session: inet-unicast Peer supports Refresh capability (2) Stale routes from peer are kept for: 300 Peer does not support Restarter functionality NLRI that restart is negotiated for: inet-unicast NLRI of received end-of-rib markers: inet-unicast NLRI of all end-of-rib markers sent: inet-unicast Peer supports 4 byte AS extension (peer-as 29) Peer does not support Addpath Table inet.0 Bit: 10000 RIB State: BGP restart is complete Send state: in sync Active prefixes: 0 Received prefixes: 0 Accepted prefixes: 0 Suppressed due to damping: 0 Advertised prefixes: 0 Last traffic (seconds): Received 10 Sent 6 Checked 65 Input messages: Total 5 Updates 1 Refreshes 0 Octets 139 Output messages: Total 5 Updates 0 Refreshes 0 Octets 158 Output Queue[0]: 0
- On cr1-sfo
root@cr1-sfo> show bgp neighbor Peer: 10.10.10.1+179 AS 17 Local: 10.10.10.2+55085 AS 29 Type: External State: Established Flags: <Sync> Last State: OpenConfirm Last Event: RecvKeepAlive Last Error: None Options: <Preference PeerAS Refresh> Holdtime: 90 Preference: 170 Number of flaps: 0 Peer ID: 10.10.10.1 Local ID: 10.10.10.2 Active Holdtime: 90 Keepalive Interval: 30 Group index: 0 Peer index: 0 BFD: disabled, down Local Interface: xe-0/0/0.0 NLRI for restart configured on peer: inet-unicast NLRI advertised by peer: inet-unicast NLRI for this session: inet-unicast Peer supports Refresh capability (2) Stale routes from peer are kept for: 300 Peer does not support Restarter functionality NLRI that restart is negotiated for: inet-unicast NLRI of received end-of-rib markers: inet-unicast NLRI of all end-of-rib markers sent: inet-unicast Peer supports 4 byte AS extension (peer-as 17) Peer does not support Addpath Table inet.0 Bit: 10000 RIB State: BGP restart is complete Send state: in sync Active prefixes: 0 Received prefixes: 0 Accepted prefixes: 0 Suppressed due to damping: 0 Advertised prefixes: 0 Last traffic (seconds): Received 2 Sent 18 Checked 23 Input messages: Total 15 Updates 1 Refreshes 0 Octets 289 Output messages: Total 16 Updates 0 Refreshes 0 Octets 367 Output Queue[0]: 0
We have setup peering between cr1-tx and cr1-sfo.
BGP verification commands
show bgp neighbor show bgp group show bgp summary