Local As

This scenario demonstrates how to configure local-as feature. This feature allows for BGP sessions to establish using an alternate ASN than the ASN that the BGP process is running on.

Test BGP Local-AS options

Description

In this scenario, DUT1 and DUT2 are configured as BGP peers against DUT0. A route in DUT1 will be exported to DUT2 through DUT0. The option “local-as” is used in DUT0 to establish the BGP connection, as running ASN in DUT0 is different than remote AS configured in DUT1 and DUT2. The AS-Path of the route received in DUT2 will be checked after configure “no-prepend” and “replace-as” options in DUT0.

Scenario

Example 1

Step 1: Set the following configuration in DUT0 :

set interfaces dummy dum0 address 1.1.1.1/24
set interfaces ethernet eth0 address 192.168.100.1/24
set interfaces ethernet eth1 address 192.168.200.1/24
set protocols bgp 50 neighbor DUT1 local-as 10
set protocols bgp 50 neighbor DUT1 remote-address 192.168.100.2
set protocols bgp 50 neighbor DUT1 remote-as 20
set protocols bgp 50 neighbor DUT1 route-map import PERMIT
set protocols bgp 50 neighbor DUT2 local-as 10
set protocols bgp 50 neighbor DUT2 remote-address 192.168.200.2
set protocols bgp 50 neighbor DUT2 remote-as 30
set protocols bgp 50 neighbor DUT2 route-map export PERMIT
set protocols route-map PERMIT rule 1 action permit
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces dummy dum0 address 1.1.1.1/24
set interfaces ethernet eth0 address 192.168.100.2/24
set protocols bgp 20 neighbor DUT0 remote-address 192.168.100.1
set protocols bgp 20 neighbor DUT0 remote-as 10
set protocols bgp 20 neighbor DUT0 route-map export PERMIT
set protocols bgp 20 redistribute connected route-map RED
set protocols route-map PERMIT rule 1 action permit
set protocols route-map RED rule 1 action permit
set protocols route-map RED rule 1 match interface dum0
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Set the following configuration in DUT2 :

set interfaces ethernet eth0 address 192.168.200.2/24
set protocols bgp 30 neighbor DUT0 remote-address 192.168.200.1
set protocols bgp 30 neighbor DUT0 remote-as 10
set protocols bgp 30 neighbor DUT0 route-map import PERMIT
set protocols route-map PERMIT rule 1 action permit
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 4: Ping IP address 192.168.100.2 from DUT0:

admin@DUT0$ ping 192.168.100.2 count 3 size 56 timeout 1
Show output
PING 192.168.100.2 (192.168.100.2) 56(84) bytes of data.
64 bytes from 192.168.100.2: icmp_seq=1 ttl=64 time=0.232 ms
64 bytes from 192.168.100.2: icmp_seq=2 ttl=64 time=0.196 ms
64 bytes from 192.168.100.2: icmp_seq=3 ttl=64 time=0.257 ms

--- 192.168.100.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2045ms
rtt min/avg/max/mdev = 0.196/0.228/0.257/0.025 ms

Step 5: Ping IP address 192.168.200.2 from DUT0:

admin@DUT0$ ping 192.168.200.2 count 3 size 56 timeout 1
Show output
PING 192.168.200.2 (192.168.200.2) 56(84) bytes of data.
64 bytes from 192.168.200.2: icmp_seq=1 ttl=64 time=0.224 ms
64 bytes from 192.168.200.2: icmp_seq=2 ttl=64 time=0.274 ms
64 bytes from 192.168.200.2: icmp_seq=3 ttl=64 time=0.284 ms

--- 192.168.200.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2045ms
rtt min/avg/max/mdev = 0.224/0.260/0.284/0.026 ms

Note

By default, the alternate ASN is added to the AS-Path for routes that are sent and received between peers.

Step 6: Run command protocols bgp show ip summary at DUT0 and check if output matches the following regular expressions:

192.168.100.2.*Established
Show output
IPv4 Unicast Summary:
BGP router identifier 192.168.200.1, local AS number 50 VRF default vrf-id 0
BGP table version 1
RIB entries 1, using 128 bytes of memory
Peers 2, using 47 KiB of memory

Neighbor        LocalAddr       V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down        State   PfxRcd   PfxSnt Desc
192.168.100.2   -               4         20         4         3        1    0    0 00:00:06  Established        1 (Policy) N/A
192.168.200.2   -               4         30         4         7        1    0    0 00:00:04  Established (Policy)        1 N/A

Total number of neighbors 2

Step 7: Run command protocols bgp show ip summary at DUT0 and check if output matches the following regular expressions:

192.168.200.2.*Established
Show output
IPv4 Unicast Summary:
BGP router identifier 192.168.200.1, local AS number 50 VRF default vrf-id 0
BGP table version 1
RIB entries 1, using 128 bytes of memory
Peers 2, using 47 KiB of memory

Neighbor        LocalAddr       V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down        State   PfxRcd   PfxSnt Desc
192.168.100.2   -               4         20         4         3        1    0    0 00:00:07  Established        1 (Policy) N/A
192.168.200.2   -               4         30         4         7        1    0    0 00:00:05  Established (Policy)        1 N/A

Total number of neighbors 2

Step 8: Run command protocols bgp show ip at DUT2 and check if output matches the following regular expressions:

\*>\s+1.1.1.0/24\s+192.168.200.1\s+.\s+10 50 10 20
Show output
BGP table version is 1, local router ID is 192.168.200.2, vrf id 0
Default local pref 100, local AS 30
local address -
Status codes:  s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.0/24       192.168.200.1                          0 10 50 10 20 ?

Displayed 1 routes and 1 total paths

Step 9: Modify the following configuration lines in DUT0 :

set protocols bgp 50 neighbor DUT1 local-as 10 no-prepend

Note

The option “no-prepend” is used to stop the alternate ASN from being prepended when receiving routes.

Step 10: Run command protocols bgp show ip at DUT2 and check if output matches the following regular expressions:

\*>\s+1.1.1.0/24\s+192.168.200.1\s+.\s+10 50 20
Show output
BGP table version is 3, local router ID is 192.168.200.2, vrf id 0
Default local pref 100, local AS 30
local address -
Status codes:  s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.0/24       192.168.200.1                          0 10 50 20 ?

Displayed 1 routes and 1 total paths

Step 11: Modify the following configuration lines in DUT0 :

set protocols bgp 50 neighbor DUT2 local-as 10 no-prepend replace-as

Note

The option “replace-as” is used to stop the alternate ASN from being prepended when sending routes.

Step 12: Run command protocols bgp show ip at DUT2 and check if output matches the following regular expressions:

\*>\s+1.1.1.0/24\s+192.168.200.1\s+.\s+10 20
Show output
BGP table version is 5, local router ID is 192.168.200.2, vrf id 0
Default local pref 100, local AS 30
local address -
Status codes:  s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.0/24       192.168.200.1                          0 10 20 ?

Displayed 1 routes and 1 total paths

Example 2

Step 1: Set the following configuration in DUT0 :

set interfaces dummy dum0 address 1.1.1.1/24
set interfaces ethernet eth0 address 192.168.100.1/24
set interfaces ethernet eth1 address 192.168.200.1/24
set protocols bgp 50 peer-group DUT1 listen range 192.168.100.0/24
set protocols bgp 50 peer-group DUT1 local-as 10
set protocols bgp 50 peer-group DUT1 remote-as 20
set protocols bgp 50 peer-group DUT1 route-map import PERMIT
set protocols bgp 50 peer-group DUT2 listen range 192.168.200.0/24
set protocols bgp 50 peer-group DUT2 local-as 10
set protocols bgp 50 peer-group DUT2 remote-as 30
set protocols bgp 50 peer-group DUT2 route-map export PERMIT
set protocols route-map PERMIT rule 1 action permit
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces dummy dum0 address 1.1.1.1/24
set interfaces ethernet eth0 address 192.168.100.2/24
set protocols bgp 20 neighbor DUT0 remote-address 192.168.100.1
set protocols bgp 20 neighbor DUT0 remote-as 10
set protocols bgp 20 neighbor DUT0 route-map export PERMIT
set protocols bgp 20 redistribute connected route-map RED
set protocols route-map PERMIT rule 1 action permit
set protocols route-map RED rule 1 action permit
set protocols route-map RED rule 1 match interface dum0
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Set the following configuration in DUT2 :

set interfaces ethernet eth0 address 192.168.200.2/24
set protocols bgp 30 neighbor DUT0 remote-address 192.168.200.1
set protocols bgp 30 neighbor DUT0 remote-as 10
set protocols bgp 30 neighbor DUT0 route-map import PERMIT
set protocols route-map PERMIT rule 1 action permit
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 4: Ping IP address 192.168.100.2 from DUT0:

admin@DUT0$ ping 192.168.100.2 count 3 size 56 timeout 1
Show output
PING 192.168.100.2 (192.168.100.2) 56(84) bytes of data.
64 bytes from 192.168.100.2: icmp_seq=1 ttl=64 time=0.264 ms
64 bytes from 192.168.100.2: icmp_seq=2 ttl=64 time=0.365 ms
64 bytes from 192.168.100.2: icmp_seq=3 ttl=64 time=0.341 ms

--- 192.168.100.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2051ms
rtt min/avg/max/mdev = 0.264/0.323/0.365/0.043 ms

Step 5: Ping IP address 192.168.200.2 from DUT0:

admin@DUT0$ ping 192.168.200.2 count 3 size 56 timeout 1
Show output
PING 192.168.200.2 (192.168.200.2) 56(84) bytes of data.
64 bytes from 192.168.200.2: icmp_seq=1 ttl=64 time=0.318 ms
64 bytes from 192.168.200.2: icmp_seq=2 ttl=64 time=0.330 ms
64 bytes from 192.168.200.2: icmp_seq=3 ttl=64 time=0.274 ms

--- 192.168.200.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2044ms
rtt min/avg/max/mdev = 0.274/0.307/0.330/0.024 ms

Note

By default, the alternate ASN is added to the AS-Path for routes that are sent and received between peers.

Step 6: Run command protocols bgp show ip summary at DUT0 and check if output matches the following regular expressions:

192.168.100.2.*Established
Show output
IPv4 Unicast Summary:
BGP router identifier 192.168.200.1, local AS number 50 VRF default vrf-id 0
BGP table version 1
RIB entries 1, using 128 bytes of memory
Peers 2, using 47 KiB of memory
Peer groups 2, using 128 bytes of memory

Neighbor        LocalAddr       V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down        State   PfxRcd   PfxSnt Desc
*192.168.100.2  192.168.100.1   4         20         4         3        1    0    0 00:00:06  Established        1 (Policy) N/A
*192.168.200.2  192.168.200.1   4         30         4         7        1    0    0 00:00:04  Established (Policy)        1 N/A

Total number of neighbors 2
* - dynamic neighbor
2 dynamic neighbor(s), limit 65535

Step 7: Run command protocols bgp show ip summary at DUT0 and check if output matches the following regular expressions:

192.168.200.2.*Established
Show output
IPv4 Unicast Summary:
BGP router identifier 192.168.200.1, local AS number 50 VRF default vrf-id 0
BGP table version 1
RIB entries 1, using 128 bytes of memory
Peers 2, using 47 KiB of memory
Peer groups 2, using 128 bytes of memory

Neighbor        LocalAddr       V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down        State   PfxRcd   PfxSnt Desc
*192.168.100.2  192.168.100.1   4         20         4         3        1    0    0 00:00:06  Established        1 (Policy) N/A
*192.168.200.2  192.168.200.1   4         30         4         7        1    0    0 00:00:04  Established (Policy)        1 N/A

Total number of neighbors 2
* - dynamic neighbor
2 dynamic neighbor(s), limit 65535

Step 8: Run command protocols bgp show ip at DUT2 and check if output matches the following regular expressions:

\*>\s+1.1.1.0/24\s+192.168.200.1\s+.\s+10 50 10 20
Show output
BGP table version is 1, local router ID is 192.168.200.2, vrf id 0
Default local pref 100, local AS 30
local address -
Status codes:  s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.0/24       192.168.200.1                          0 10 50 10 20 ?

Displayed 1 routes and 1 total paths

Step 9: Modify the following configuration lines in DUT0 :

set protocols bgp 50 peer-group DUT1 local-as 10 no-prepend

Note

The option “no-prepend” is used to stop the alternate ASN from being prepended when receiving routes.

Step 10: Run command protocols bgp show ip at DUT2 and check if output matches the following regular expressions:

\*>\s+1.1.1.0/24\s+192.168.200.1\s+.\s+10 50 20
Show output
BGP table version is 3, local router ID is 192.168.200.2, vrf id 0
Default local pref 100, local AS 30
local address -
Status codes:  s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.0/24       192.168.200.1                          0 10 50 20 ?

Displayed 1 routes and 1 total paths

Step 11: Modify the following configuration lines in DUT0 :

set protocols bgp 50 peer-group DUT2 local-as 10 no-prepend replace-as

Note

The option “replace-as” is used to stop the alternate ASN from being prepended when sending routes.

Step 12: Run command protocols bgp show ip at DUT2 and check if output matches the following regular expressions:

\*>\s+1.1.1.0/24\s+192.168.200.1\s+.\s+10 20
Show output
BGP table version is 5, local router ID is 192.168.200.2, vrf id 0
Default local pref 100, local AS 30
local address -
Status codes:  s suppressed, d damped, h history, u unsorted, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.0/24       192.168.200.1                          0 10 20 ?

Displayed 1 routes and 1 total paths