# BGP 4-Byte AS Number

Before January 2009, we only had 2 byte AS numbers in the range of 1-65535. 1024 of those (64512-65534) are reserved for private AS numbers.

Similar to IPv4, we started running out of AS numbers so IANA increased the AS numbers by introducing 4-byte AS numbers in the range of 65536 to 4294967295.

There are three ways to write down these new 4-byte AS numbers:

• Asplain
• Asdot
• Asdot+

Asplain is the most simple to understand, these are just regular decimal numbers. For example, AS number 545435, 4294937295, 4254967294, 2294967295, etc. These numbers are simple to understand but prone to errors. It’s easy to make a configuration mistake or misread a number in the BGP table.

Asdot represents AS numbers less than 65536 using the asplain notation and AS numbers above 65536 with the asdot+ notation.

Asdot+ breaks the AS number in two 16-bit parts, a high-order value, and a low-order value, separated by a dot. All older AS numbers can fit in the second part where the first part is set to 0. For example:

• AS 6541 becomes 0.6541
• AS 54233 becomes 0.54233
• AS 544 becomes 0.544

For AS numbers above 65535, we use the next high order bit value and start counting again at 0. For example:

• AS 65536 becomes 1.0
• AS 65537 becomes 1.1
• AS 65538 becomes 1.1

These numbers are easier to read but harder to calculate than the asplain numbers, it’s also a bit trickier to create regular expressions.

If you want to convert an asplain AS number to an asdot+ AS number, you take the asplain number and see how many times you can divide it by 65536. This is the integer that we use for the high order bit value.

Then, you take the asplain number and deduct (65536 * the integer) to get your low order bit value. In other words, this is the formula:

``````integer (high order bit value) = asplain / 65536
remainder (low order bit value) = asplain - (integer * 65536)
asdot value = integer.remainder``````

Here are two examples:

``````#AS 5434995
5434995 / 65536 = 82
5434995 - (82 * 65536) = 61043
asdot = 82.6104``````
``````#AS 1499547
1499547 / 65536 = 22
1499547 - (22 * 65536) = 57755
asdot = 22.57755``````

Once you understand how the conversion is done, you can use the APNIC asplain to asdot calculator to convert this automatically and make your life a bit easier.

BGP speakers that support 4-byte AS numbers advertise this via BGP capability negotiation and there is backward compatibility. When a “new” router talks to an “old” router (one that only supports 2-byte AS numbers), it can use a reserved AS number (23456) called AS_TRANS instead of its 4-byte AS number. I’ll show you how this works in the configuration.

## Configuration

Cisco routers support the asplain and asdot representations. The configuration is pretty straightforward and I’ll show you two scenarios:

• Two routers that both have 4-byte AS support.
• Two routers where one router only has 2-byte AS support.

### 4-byte AS support

Before January 2009, we only had 2 byte AS numbers in the range of 1-65535. 1024 of those (64512-65534) are reserved for private AS numbers. Similar to IPv4, we started running out of AS numbers so IANA increased the AS numbers by introducing 4-byte AS numbers in the range of 65536 to 4294967295. Th

We have two routers: Both routers support 4-byte AS numbers. You can see this when you configure the AS number:

``````R1(config)#router bgp ?
<1-4294967295>  Autonomous system number
<1.0-XX.YY>     Autonomous system number``````

As you can see, this IOS router supports asplain and asdot numbers. Let’s pick asplain and establish a BGP neighbor adjacency:

``````R1(config)#router bgp 12000012
R1(config-router)#neighbor 192.168.12.2 remote-as 12000012``````
``````R2(config)#router bgp 12000012
R2(config-router)#neighbor 192.168.12.1 remote-as 12000012``````

You can see the asplain AS numbers in all bgp show commands:

``````R1#show ip bgp summary
BGP router identifier 192.168.12.1, local AS number 12000012
BGP table version is 1, main routing table version 1

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.12.2    4     12000012       5       5        1    0    0 00:01:02        0``````

If you want, you can change the representation to the asdot format:

``````R1(config-router)#bgp asnotation ?
dot  asdot notation``````

Let’s change it:

``R1(config-router)#bgp asnotation dot``

You will now see the asdot format in all show commands:

``````R1#show ip bgp summary
BGP router identifier 192.168.12.1, local AS number 183.6924
BGP table version is 1, main routing table version 1

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.12.2    4     183.6924       6       6        1    0    0 00:02:38        0``````

AS 12000012 now shows up as AS 183.6924.

## Configurations

Want to take a look for yourself? Here you will find the configuration of each device.

## R1

``````hostname R1
!
ip cef
!
interface GigabitEthernet0/1
!
router bgp 183.6924
bgp asnotation dot
neighbor 192.168.12.2 remote-as 183.6924
!
end``````

## R2

``````hostname R2
!
ip cef
!
interface GigabitEthernet0/1
!
router bgp 12000012
neighbor 192.168.12.1 remote-as 12000012
!
end``````

### 2-byte AS support

Before January 2009, we only had 2 byte AS numbers in the range of 1-65535. 1024 of those (64512-65534) are reserved for private AS numbers. Similar to IPv4, we started running out of AS numbers so IANA increased the AS numbers by introducing 4-byte AS numbers in the range of 65536 to 4294967295. Th

Let’s use two routers. R1 only supports 2-byte AS numbers, R2 supports 4-byte AS numbers: R1 has no clue what an AS number above 65535 is:

## Forum Replies

1. martystoyanoff says:

Excellent! Thank you Rene!

2. nnmore says:

“Removing the private AS numbers is a bit similar to NAT where we hide private IP addresses behind one or more public IP addresses”
Accepted.
But how are we going to do the mapping from private AS to public AS and back when the private AS number is not advertised by AS2 to AS 3 ?

3. ReneMolenaar says:

Hi Nikhil,

We don’t. The only thing we do is remove the private AS number and then advertise the prefix(es). Take a look here:

BGP Remove Private AS

There’s no need to create a mapping between the private/public AS number.

Rene

4. sahilbhola2 says:

Hey Rene,

In your last diagram in this lesson, suppose we have many private AS behind R2 which needs to go to the Internet, in this case how will R2 handle those sessions ? We all know that in similar situation in IPv4 world we have PAT which maps the private IP with one Public IP using unique port number how does R2 handle this situation? Appreciate if you shed some light on this.

Best,

Sahil

5. ReneMolenaar says:

Hi Sahil,

You can see it in this example:

BGP Remove Private AS

R2 will have the private AS paths in its own BGP table so it knows what to do.

Rene

Ask a question or join the discussion by visiting our Community Forum