You can configure BGP with a different local AS number for each EBGP session, which allows BGP to configure a local AS for each EBGP session. Configuring a local AS simulates a virtual AS for the router. The AS paths for the routes from that EBGP peer have the configured local-as prepended before the peer AS for that session. This is useful if ISP A has acquired another ISP B, but does not want to change the configurations of ISP B’s customer routers. ISP B’s AS is the AS that is configured as the local AS.
![]() |
Note: If the local AS for the EBGP/IBGP peer is the same as the current AS, do not use the local-as statement to specify the local AS number. |
To configure a local AS, include the local-as statement:
-
local-as autonomous-system <private>;
For a list of hierarchy levels at which you can configure this statement, see the statement summary section for this statement.
For autonomous-system, you can specify a number from 1 through 4,294,967,295 in plain-number format. Beginning with JUNOS Release 9.1, the range for autonomous system (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. The JUNOS software continues to support 2-byte AS numbers.
Beginning with JUNOS Release 9.2, 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 in the range from 0.0 through 65535.65535. in AS-dot notation format.
If you include the private keyword, the local AS is not prepended before the peer AS. This means that the AS paths do not show details of such a configuration, and ISP A’s EBGP peers and IBGP peers do not see any difference from before the local AS configuration.
You can include the local-as statement to configure a router to use a different AS number than the one for which the router is configured. The local AS is used in all BGP protocol exchanges with the routers that are configured for simulating a virtual AS.
![]() |
Note: If you configure the local AS values for any BGP group, the detection of routing loops is performed using both the AS and the local AS values for all BGP groups. |
Use the local-as statement when ISPs merge and want to preserve a customer’s configuration, particularly the AS the customer is configured to peer with. Use the local-as statement to simulate the AS number already in place in customer routers, even if the ISP’s router is in a different AS now.
Figure 10: Local AS Configuration

In Figure 10, Router 1 and Router 2 are in AS 65500, Router 4 is in AS 64513, and Router 3 is in AS 64512. Router 2 uses AS 65001 as its local AS.
Router 2 adds AS 65001 when announcing Router 1’s routes to Router 3. Router 3 sees an AS path of 65001 65500 64512 for the prefix 10/8. To prevent Router 2 from adding the virtual AS number in its announcements to other peers, use the local-as autonomous-system private statement. The local-as autonomous-system private statement configures Router 2 to not include the virtual AS number configured in local-as when announcing Router 1’s routes to Router 3. In this case, Router 3 sees an AS path of 65500 64512 for the prefix 10/8.
The configuration for each router follows.
-
On Router 1:
- routing-options {
- autonomous-system 65500;
- }
- protocols {
-
- bgp {
-
- group internal-AS65500 {
- type internal;
- local-address 10.1.1.1;
- neighbor 10.1.1.2;
- }
- }
- }
-
On Router 2:
- routing-options {
- autonomous-system 65500;
- }
- protocols {
-
- bgp {
-
- group internal-AS65500 {
- type internal;
- local-address 10.1.1.2;
- neighbor 10.1.1.1;
- }
-
- group external-AS64513 {
- type external;
- peer-as 64513;
- neighbor 192.168.1.2;
- }
-
- group external-AS64512 {
- type external;
- peer-as 64512;
- neighbor 192.168.10.2;
- }
- }
- }
-
On Router 3:
- routing-options {
- autonomous-system 64512;
- }
- protocols {
-
- bgp {
-
- group external-AS65001 {
- type external;
- peer-as 65001;
- neighbor 192.168.10.1;
- }
- }
- }
-
On Router 4:
- routing-options {
- autonomous-system 64513;
- }
- protocols {
-
- bgp {
-
- group external-65500 {
- peer-as 65500;
- neighbor 192.168.1.1;
- }
- }
- }