Supported Platforms
Related Documentation
- ACX, J, M, MX, SRX Series
- Understanding External BGP Peering Sessions
- BGP Configuration Overview
- M, MX, PTX, T Series
- 4-Byte Autonomous System Numbers Overview in the Using 4-Byte Autonomous System Numbers in BGP Networks Technology Overview
Example: Configuring a Local AS for EBGP Sessions
This example shows how to configure a local autonomous system (AS) for a BGP peer so that both the global AS and the local AS are used in BGP inbound and outbound updates.
Requirements
No special configuration beyond device initialization is required before you configure this example.
Overview
Use the local-as statement when ISPs merge and want to preserve a customer’s configuration, particularly the AS with which the customer is configured to establish a peer relationship. The local-as statement simulates the AS number already in place in customer routers, even if the ISP’s router has moved to a different AS.
This example shows how to use the local-as statement to configure a local AS. The local-as statement is supported for BGP at the global, group, and neighbor hierarchy levels.
When you configure the local-as statement, you must specify an AS number. You can specify a number from 1 through 4,294,967,295 in plain-number format. In Junos OS Release 9.1 and later, the range for AS numbers is extended to provide BGP support for 4-byte AS numbers as defined in RFC 4893, BGP Support for Four-octet AS Number Space. In Junos OS Release 9.3 and later, you can also configure a 4-byte AS number using the AS-dot notation format of two integer values joined by a period: <16-bit high-order value in decimal>.<16-bit low-order value in decimal>. For example, the 4-byte AS number of 65,546 in plain-number format is represented as 1.10 in the AS-dot notation format. You can specify a value from 0.0 through 65535.65535 in AS-dot notation format. Junos OS continues to support 2-byte AS numbers. The 2-byte AS number range is 1 through 65,535 (this is a subset of the 4-byte range).
Figure 1 shows the sample topology.
Figure 1: Topology for Configuring the Local AS

In this example, Device R2 formerly belonged to AS 250 and now is in AS 200. Device R1 and Device R3 are configured to peer with AS 250 instead of with the new AS number (AS 200). Device R2 has the new AS number configured with the autonomous-system 200 statement. To enable the peering sessions to work, the local-as 250 statement is added in the BGP configuration. Because local-as 250 is configured, Device R2 includes both the global AS (200) and the local AS (250) in its BGP inbound and outbound updates.
Configuration
CLI Quick Configuration
To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.
Device R1
Device R2
Device R3
Configuring Device R1
Step-by-Step Procedure
The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.
To configure Device R1:
- Configure the interfaces.[edit interfaces]user@R1# set fe-1/2/0 unit 1 family inet address 10.0.0.1/30
user@R1# set lo0 unit 1 family inet address 192.168.0.1/32 - Configure external BGP (EBGP).[edit protocols bgp group ext]user@R1# set type externaluser@R1# set export send-directuser@R1# set export send-staticuser@R1# set peer-as 250user@R1# set neighbor 10.0.0.2
- Configure the routing policy.[edit policy-options]user@R1# set policy-statement send-direct term 1 from protocol directuser@R1# set policy-statement send-direct term 1 then acceptuser@R1# set policy-statement send-static term 1 from protocol staticuser@R1# set policy-statement send-static term 1 then accept
- Configure a static route to the remote network between
Device R2 and Device R3.[edit routing-options]user@R1# set static route 10.1.0.0/30 next-hop 10.0.0.2
- Configure the global AS number.[edit routing-options]user@R1# set autonomous-system 100
Results
From configuration mode, confirm your configuration by entering the show interfaces, show policy-options, show protocols, and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.
When you are done configuring the device, enter commit from configuration mode.
Configuring Device R2
Step-by-Step Procedure
The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.
To configure Device R2:
- Configure the interfaces.[edit interfaces]user@R2# set fe-1/2/0 unit 2 family inet address 10.0.0.2/30
user@R2# set fe-1/2/1 unit 3 family inet address 10.1.0.1/30
user@R2# set lo0 unit 2 family inet address 192.168.0.2/32 - Configure EBGP.[edit protocols bgp group ext]user@R2# set type externaluser@R2# set export send-directuser@R2# set export send-staticuser@R2# set neighbor 10.0.0.1 peer-as 100user@R2# set neighbor 10.1.0.2 peer-as 300
- Configure the local autonomous system (AS) number.[edit protocols bgp group ext]user@R2# set local-as 250
- Configure the global AS number.[edit routing-options]user@R2# set autonomous-system 200
- Configure the routing policy.[edit policy-options]user@R2# set policy-statement send-direct term 1 from protocol directuser@R2# set policy-statement send-direct term 1 then acceptuser@R2# set policy-statement send-static term 1 from protocol staticuser@R2# set policy-statement send-static term 1 then accept
Results
From configuration mode, confirm your configuration by entering the show interfaces, show policy-options, show protocols, and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.
When you are done configuring the device, enter commit from configuration mode.
Configuring Device R3
Step-by-Step Procedure
The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.
To configure Device R3:
- Configure the interfaces.[edit interfaces]user@R3# set fe-1/2/0 unit 4 family inet address 10.1.0.2/30
user@R3# set lo0 unit 3 family inet address 192.168.0.3/32 - Configure EBGP.[edit protocols bgp group ext]user@R3# set type externaluser@R3# set export send-directuser@R3# set export send-staticuser@R3# set peer-as 250user@R3# set neighbor 10.1.0.1
- Configure the global autonomous system (AS) number.[edit routing-options]user@R3# set autonomous-system 300
- Configure a static route to the remote network between
Device R1 and Device R2.[edit routing-options]user@R3# set static route 10.0.0.0/30 next-hop 10.1.0.1
- Configure the routing policy.[edit policy-options]user@R3# set policy-statement send-direct term 1 from protocol directuser@R3# set policy-statement send-direct term 1 then acceptuser@R3# set policy-statement send-static term 1 from protocol staticuser@R3# set policy-statement send-static term 1 then accept
Results
From configuration mode, confirm your configuration by entering the show interfaces, show policy-options, show protocols, and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.
When you are done configuring the device, enter commit from configuration mode.
Verification
Confirm that the configuration is working properly.
- Checking the Local and Global AS Settings
- Checking the BGP Peering Sessions
- Verifying the BGP AS Paths
Checking the Local and Global AS Settings
Purpose
Make sure that Device R2 has the local and global AS settings configured.
Action
From operational mode, enter the show bgp neighbors command.
user@R2> show bgp neighbors
Peer: 10.0.0.1+179 AS 100 Local: 10.0.0.2+61036 AS 250 Type: External State: Established Flags: <Sync> Last State: OpenConfirm Last Event: RecvKeepAlive Last Error: None Export: [ send-direct send-static ] Options: <Preference PeerAS LocalAS Refresh> Holdtime: 90 Preference: 170 Local AS: 250 Local System AS: 200 Number of flaps: 0 Peer ID: 192.168.0.1 Local ID: 192.168.0.2 Active Holdtime: 90 Keepalive Interval: 30 Peer index: 0 BFD: disabled, down Local Interface: fe-1/2/0.2 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 100) Peer does not support Addpath Table inet.0 Bit: 10000 RIB State: BGP restart is complete Send state: in sync Active prefixes: 1 Received prefixes: 3 Accepted prefixes: 2 Suppressed due to damping: 0 Advertised prefixes: 4 Last traffic (seconds): Received 6 Sent 14 Checked 47 Input messages: Total 258 Updates 3 Refreshes 0 Octets 4969 Output messages: Total 258 Updates 2 Refreshes 0 Octets 5037 Output Queue[0]: 0 Peer: 10.1.0.2+179 AS 300 Local: 10.1.0.1+52296 AS 250 Type: External State: Established Flags: <Sync> Last State: OpenConfirm Last Event: RecvKeepAlive Last Error: None Export: [ send-direct send-static ] Options: <Preference PeerAS LocalAS Refresh> Holdtime: 90 Preference: 170 Local AS: 250 Local System AS: 200 Number of flaps: 0 Peer ID: 192.168.0.3 Local ID: 192.168.0.2 Active Holdtime: 90 Keepalive Interval: 30 Peer index: 1 BFD: disabled, down Local Interface: fe-1/2/1.3 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 300) Peer does not support Addpath Table inet.0 Bit: 10000 RIB State: BGP restart is complete Send state: in sync Active prefixes: 1 Received prefixes: 3 Accepted prefixes: 2 Suppressed due to damping: 0 Advertised prefixes: 4 Last traffic (seconds): Received 19 Sent 26 Checked 9 Input messages: Total 256 Updates 3 Refreshes 0 Octets 4931 Output messages: Total 256 Updates 2 Refreshes 0 Octets 4999 Output Queue[0]: 0
Meaning
The Local AS: 250 and Local System AS: 200 output shows that Device R2 has the expected settings. Additionally, the output shows that the options list includes LocalAS.
Checking the BGP Peering Sessions
Purpose
Ensure that the sessions are established and that the local AS number 250 is displayed.
Action
From operational mode, enter the show bgp summary command.
user@R1> show bgp summary
Groups: 1 Peers: 1 Down peers: 0 Table Tot Paths Act Paths Suppressed History Damp State Pending inet.0 4 2 0 0 0 0 Peer AS InPkt OutPkt OutQ Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped... 10.0.0.2 250 232 233 0 4 1:42:37 2/4/4/0 0/0/0/0
user@R3> show bgp summary
Groups: 1 Peers: 1 Down peers: 0 Table Tot Paths Act Paths Suppressed History Damp State Pending inet.0 4 2 0 0 0 0 Peer AS InPkt OutPkt OutQ Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped... 10.1.0.1 250 235 236 0 4 1:44:25 2/4/4/0 0/0/0/0
Meaning
Device R1 and Device R3 appear to be peering with a device in AS 250, even though Device R2 is actually in AS 200.
Verifying the BGP AS Paths
Purpose
Make sure that the routes are in the routing tables and that the AS paths show the local AS number 250.
Action
From configuration mode, enter the set route protocol bgp command.
user@R1> show route protocol bgp
inet.0: 6 destinations, 8 routes (6 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 10.0.0.0/30 [BGP/170] 01:46:44, localpref 100 AS path: 250 I > to 10.0.0.2 via fe-1/2/0.1 10.1.0.0/30 [BGP/170] 01:46:44, localpref 100 AS path: 250 I > to 10.0.0.2 via fe-1/2/0.1 192.168.0.2/32 *[BGP/170] 01:46:44, localpref 100 AS path: 250 I > to 10.0.0.2 via fe-1/2/0.1 192.168.0.3/32 *[BGP/170] 01:46:40, localpref 100 AS path: 250 300 I > to 10.0.0.2 via fe-1/2/0.1
user@R3> show route protocol bgp
inet.0: 6 destinations, 8 routes (6 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 10.0.0.0/30 [BGP/170] 01:47:10, localpref 100 AS path: 250 I > to 10.1.0.1 via fe-1/2/0.4 10.1.0.0/30 [BGP/170] 01:47:10, localpref 100 AS path: 250 I > to 10.1.0.1 via fe-1/2/0.4 192.168.0.1/32 *[BGP/170] 01:47:10, localpref 100 AS path: 250 100 I > to 10.1.0.1 via fe-1/2/0.4 192.168.0.2/32 *[BGP/170] 01:47:10, localpref 100 AS path: 250 I > to 10.1.0.1 via fe-1/2/0.4
Meaning
The output shows that Device R1 and Device R3 appear to have routes with AS paths that include AS 250, even though Device R2 is actually in AS 200.
Related Documentation
- ACX, J, M, MX, SRX Series
- Understanding External BGP Peering Sessions
- BGP Configuration Overview
- M, MX, PTX, T Series
- 4-Byte Autonomous System Numbers Overview in the Using 4-Byte Autonomous System Numbers in BGP Networks Technology Overview
Published: 2013-02-08
Supported Platforms
Related Documentation
- ACX, J, M, MX, SRX Series
- Understanding External BGP Peering Sessions
- BGP Configuration Overview
- M, MX, PTX, T Series
- 4-Byte Autonomous System Numbers Overview in the Using 4-Byte Autonomous System Numbers in BGP Networks Technology Overview