BGP · Topic 3 of 4

Configuring BGP Groups, Peers and Options

Configure and verify Junos BGP groups and peers, the AS number, local address, multihop, authentication, passive, remove-private and multipath options.

  • 6 min
In a nutshell
  • Configure routing-options autonomous-system first, then protocols bgp group with type, peer-as and neighbor.
  • Group settings are inherited by neighbors; the neighbor level overrides the group.
  • local-address is for the loopback source; multihop raises the EBGP TTL.

What it is

On Junos, BGP is configured under [edit protocols bgp]. Peers are placed in groups, and each group has a type: internal for IBGP or external for EBGP. Settings made at the group level apply to every neighbor in it, and a neighbor can override a setting for itself.

Before any session can form, the router needs its own autonomous system number under [edit routing-options]. Without it the BGP configuration commits but no session starts.

Set AS numberCreate grouptype internal or externalAdd neighboraddress and peer asCommitCheck stateshow bgp summary

How it works

Basic EBGP configuration

user@router# set routing-options autonomous-system 65001
user@router# set protocols bgp group ISP type external
user@router# set protocols bgp group ISP peer-as 65002
user@router# set protocols bgp group ISP neighbor 192.0.2.2
user@router# commit

The same in hierarchy form:

routing-options {
    autonomous-system 65001;
}
protocols {
    bgp {
        group ISP {
            type external;
            peer-as 65002;
            neighbor 192.0.2.2;
        }
    }
}

An external group needs peer-as, either on the group or on the neighbor. An internal group does not, because the peer AS is your own.

Basic IBGP configuration

user@router# set protocols bgp group CORE type internal
user@router# set protocols bgp group CORE local-address 10.255.0.1
user@router# set protocols bgp group CORE neighbor 10.255.0.2
user@router# set protocols bgp group CORE neighbor 10.255.0.3

local-address makes the router source the session from its loopback. The neighbor must have the matching configuration pointing back to this loopback.

Group and neighbor levels

Statements can sit at three levels. The most specific level wins.

LevelHierarchyApplies to
Global[edit protocols bgp]All groups and peers
Group[edit protocols bgp group name]All neighbors in the group
Neighbor[edit protocols bgp group name neighbor address]That one peer

Put peers with the same role and policy in one group. A group of upstream providers and a group of internal peers will have different types and policies.

Common options

OptionEffect
local-addressSource address of the session, normally a loopback for IBGP
multihopAllows EBGP to a peer that is not directly connected by raising the TTL
authentication-keyUses TCP MD5 authentication; the key must match on both peers
hold-timeChanges the hold time requested in the Open message (default 90 seconds)
passiveThe router does not start the TCP connection and only waits for the peer
local-asPresents a different AS number to this peer, useful during an AS migration
remove-privateRemoves private AS numbers from the AS path in advertisements
as-overrideReplaces the peer's AS in the AS path with your own, for sites sharing one AS number
multipathAllows several equal paths to be used for load sharing
dampingPenalizes routes that flap
bfd-liveness-detectionAdds fast failure detection to the session

A few of these have exam traps. passive on both sides means neither side starts TCP, so the session never forms. A mismatched authentication-key means the TCP segments are rejected, and the session stays in Connect or Active with no useful message.

user@router# set protocols bgp group ISP authentication-key "s3cret"
user@router# set protocols bgp group ISP remove-private
user@router# set protocols bgp group ISP multipath

Monitoring peers

Start with the summary, then go to the neighbor detail.

user@router> show bgp summary
Groups: 1 Peers: 1 Down peers: 0
Table          Tot Paths  Act Paths Suppressed    History Damp State    Pending
inet.0                 3          2          0          0          0          0
Peer           AS     InPkt  OutPkt  OutQ  Flaps  Last Up/Dwn  State|#Active/Received/Accepted/Damped...
192.0.2.2   65002       120     118     0      0     0:49:10   2/3/3/0

The numbers at the end are active, received, accepted and damped routes. Received minus accepted tells you how many routes an import policy rejected.

user@router> show bgp neighbor 192.0.2.2
Peer: 192.0.2.2+179 AS 65002   Local: 192.0.2.1+51234 AS 65001
  Type: External    State: Established
  Last State: OpenConfirm   Last Event: RecvKeepAlive
  Last Error: None
  Holdtime: 90 Preference: 170

show bgp neighbor shows the state, the last state and event, the last error from a Notification, the hold time and the options in use.

Troubleshooting a peer that will not establish

Work through the causes in order.

SymptomLikely causeCheck
Stuck in IdleConfiguration error, no AS number, or an Open error that keeps recurringshow bgp neighbor, show configuration routing-options
Active or ConnectNo route to the peer, wrong neighbor address, a filter blocking TCP 179, or authentication mismatchping, show route, firewall filters
Flaps between Active and EstablishedHold time expiry, unstable link, IGP flaps for an IBGP peershow bgp neighbor, show log messages
Established but 0 routesMissing import or export policy at one sideshow route receive-protocol bgp, show route advertising-protocol bgp

To restart a session on purpose, use clear bgp neighbor 192.0.2.2. To ask for the routes again without a reset, use clear bgp neighbor 192.0.2.2 soft-inbound.

Peer not upcheckPing peer addressfailsFix routing or IGPreachabilityPing peer addressworksCheck AS numbersand authenticationmatchCheck filters onTCP 179

Common mistakes

Missing autonomous-system. A group can be committed without it, but the session cannot start.

Wrong peer-as. The Open message check fails, and the session does not leave Active or Idle.

IBGP on loopbacks without local-address. The neighbor sees packets from an unexpected source address and refuses them.

Watch out

A mismatched MD5 key gives no clear error on the CLI. If everything else looks right and the peer stays in Active or Connect, check authentication-key on both sides.

What to remember for the exam

  • Configure routing-options autonomous-system first, then protocols bgp group with type, peer-as and neighbor.
  • Group settings are inherited by neighbors; the neighbor level overrides the group.
  • local-address is for the loopback source; multihop raises the EBGP TTL.
  • passive on one side only is valid; on both sides no session forms.
  • remove-private, as-override, local-as and multipath are the commonly tested options.
  • show bgp summary for state and route counts; show bgp neighbor for errors and timers.
  • clear bgp neighbor resets a session; soft-inbound asks for the routes again without a reset.

Check yourself

  • A new BGP group commits but no session starts. Which basic setting is easy to miss?

    The router's own autonomous system number under routing-options.

  • What does local-address do for an IBGP group?

    It makes the router use that address, normally a loopback, as the source of the session so the neighbor accepts it.

  • What do the four numbers at the end of a show bgp summary line mean?

    Active, received, accepted and damped routes for that peer.

Topic 3 of 4 in BGP

Test yourself on BGP

The full Juniper JNCIS-ENT JN0-352 question bank has 846 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.