Junos sample BGP configuration

root> show configuration routing-options

graceful-restart; ## To enable GR globally

static {

route 1.1.1.1/32 next-hop 10.2.2.2;

}

autonomous-system 65020 loops 2; ## Local router AS number and local router is allowed to see its AS number twice in AS path.

root> show configuration protocols bgp

path-selection always-compare-med; ## To compare MED from all AS.

log-updown; ## To log updown event

group ibgp-peers { ## a group is created with name ‘ibgp-peers’

type internal; ## set to IBGP

local-preference 200; ## LP set to 200

local-address 2.2.2.2; ## similar to ‘update-source’ in IOS

export nhs; ## Route policy to set next-hop-self to all exported route

cluster 5.5.5.5; ## Local router is RR and the cluster ID is 5.5.5.5

neighbor 100.100.100.100 {

export [ nhs set-extended-comm ]; ## export map to set NHS and set an extended community

}

neighbor 4.4.4.4;

}

group ebgp-peer { ## a group is created with name ‘ibgp-peers’

type external; ## set to EBGP

traceoptions {

file bgp.1;

flag packets detail;

}

metric-out 180; ## MED for all advertised routes set to 180

hold-time 60; ## Hold timer set to 60 secs. Default: 90 sec

passive; ## Local router will not intiate TCP session.

family inet {

unicast {

prefix-limit { ## set prefix limit to 100  routes. Log message will appear on reaching 90%

maximum 100; ## once it exceeds 100 routes, the session will go down permanently.

teardown 90 idle-timeout forever; ## “Clear bgp neighbor” to restore the session.

}

}

}

export to-bgp; ## export route policy to advertise local routes.

remove-private; ## Private AS will be removed before advertising to EBGP

peer-as 65010; ## Remote AS number is 65010

graceful-restart { ## Graceful restart settings.

restart-time 200;

stale-routes-time 400;

}

multipath multiple-as; ## to skip router ID, peer ID election and install more than one path

as-override; ## Replace peer AS with own AS if found in As path

neighbor 1.1.1.1 { ## EBGP session via loopback interface. TTL set to 2

multihop {

ttl 2;

}

local-address 2.2.2.2;

import user-damp; ## To implement user-defined damping parameters for routes from this neighbor

}

neighbor 10.2.3.2 {

damping; ## Enables default damping for all routes recevied from this neighbor.

authentication-key “$9$/007ABEleW-VYSreW8Xws”; ## SECRET-DATA           ## MD5 authentication key.

}

}

root>

root#

[edit policy-options]

root# show

policy-statement nhs { ## To set next-hop-self

term nhs {

from protocol bgp;

then {

next-hop self;

}

}

}

policy-statement set-extended-comm { ## To set extended community attribute

term ec {

from {

protocol bgp;

route-filter 15.1.1.0/24 exact;

}

then {

community add ec;

}

}

}

policy-statement to-bgp { ## To advertise a route into BGP with origin= I

term to-bgp {

from {

protocol direct;

route-filter 2.2.2.2/32 exact;

}

then {

metric { ## MED set to minimum IGP cost

minimum-igp;

}

origin igp; ## Origin set to I

as-path-prepend “65020 6520”; ## Own AS number prepend twice

accept;

}

}

term reject-others {

then reject;

}

}

policy-statement user-damp {

term in-damp {

from as-path from65010; ## AS path filter

then damping user-damp; ## Apply damping parameters

}

}

community ec members origin:65010:1111;

as-path from65010 “.*_65010$”;

damping user-damp {

half-life 5;

reuse 5000;

suppress 8000;

max-suppress 20;

}

[edit policy-options]

root#

Topology Diagram:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Note: Above topology and config might not be best and it is only for configuration test purpose.

Advertisements
This entry was posted in bgp, jncis, Junos and tagged , . Bookmark the permalink.

2 Responses to Junos sample BGP configuration

  1. chong says:

    Hi,

    In what situation should I use family inet “any” instead of unicast in the BGP teardown parameter? or normally use unicast?

    Thanks

    regards,

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s