User Tools

Site Tools


tech:network:cisco:bgp:bgp:bgp-as-path:bgp-as-path

BGP: Configuring AS_PATH

AS_PATH prepend.

Project name: ccna-bgp7-as-path

Basic BGP lab

  • R1
en
conf t
!
hostname R1
no ip domain-lookup
line console 0
exec-timeout 0 0
logging synchronous
!
int Lo0
ip address 1.1.1.1 255.255.255.255
exit
int Lo1
ip address 1.10.0.1 255.255.0.0
exit
int Lo2
ip address 1.20.0.1 255.255.0.0
exit
int Lo3
ip address 1.30.0.1 255.255.0.0
exit
int Lo4
ip address 1.40.0.1 255.255.0.0
exit
int gig0/0
ip address 2.1.1.1 255.255.255.0
no shut
exit
int gig0/1
ip address 3.1.1.1 255.255.0.0
no shut
exit
!
router bgp 10
neighbor 2.1.1.2 remote-as 20
neighbor 3.1.1.3 remote-as 30
network 1.1.1.1 mask 255.255.255.255
network 1.10.0.0 mask 255.255.0.0
network 1.20.0.0 mask 255.255.0.0
network 1.30.0.0 mask 255.255.0.0
network 1.40.0.0 mask 255.255.0.0
exit
!
end
wr
  • R2
en
conf t
!
hostname R2
no ip domain-lookup
line console 0
exec-timeout 0 0
logging synchronous
!
int Lo0
ip address 2.2.2.2 255.255.255.255
exit
int gig0/0
ip address 4.2.1.2 255.255.255.0
no shut
exit
int gig0/1
ip address 2.1.1.2 255.255.255.0
no shut
exit
!
router bgp 20
neighbor 2.1.1.1 remote-as 10
neighbor 4.2.1.4 remote-as 40
network 2.2.2.2 mask 255.255.255.255
exit
!
end
wr
  • R3
en
conf t
!
hostname R3
no ip domain-lookup
line console 0
exec-timeout 0 0
logging synchronous
!
int Lo0
ip address 3.3.3.3 255.255.255.255
exit
int gig0/0
ip address 3.1.1.3 255.255.255.0
no shut
exit
int gig0/1
ip address 4.3.1.3 255.255.255.0
no shut
exit
!
router bgp 30
neighbor 3.1.1.1 remote-as 10
neighbor 4.3.1.4 remote-as 40
network 3.3.3.3 mask 255.255.255.255
exit
!
end
wr
  • R4
en
conf t
!
hostname R4
no ip domain-lookup
line console 0
exec-timeout 0 0
logging synchronous
!
int Lo0
ip address 4.4.4.4 255.255.255.255
exit
int gig0/0
ip address 4.3.1.4 255.255.255.0
no shut
exit
int gig0/1
ip address 4.2.1.4 255.255.255.0
no shut
exit
!
router bgp 40
neighbor 4.2.1.2 remote-as 20
neighbor 4.3.1.3 remote-as 30
network 4.4.4.4 mask 255.255.255.255
exit
!
end
wr

Verification of BGP configuration

ping with source option by advertised network IP.
because established link network not advertised.

R1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
R1#ping 4.4.4.4 source 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/5/7 ms
R2#ping 3.3.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
R2#ping 3.3.3.3 source 2.2.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 2.2.2.2
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/5/7 ms
R3#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 3/4/5 ms
R3#ping 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 3/3/4 ms
R3#ping 2.2.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
R3#ping 2.2.2.2 source 3.3.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
Packet sent with a source address of 3.3.3.3
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/6 ms
R4#ping 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
R4#ping 1.1.1.1 source 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 4.4.4.4
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/6 ms
R4#ping 1.10.0.1 source 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.10.0.1, timeout is 2 seconds:
Packet sent with a source address of 4.4.4.4
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 5/5/7 ms
R4#ping 1.20.0.1 source 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.20.0.1, timeout is 2 seconds:
Packet sent with a source address of 4.4.4.4
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/6 ms
R4#ping 1.30.0.1 source 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.30.0.1, timeout is 2 seconds:
Packet sent with a source address of 4.4.4.4
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/5/6 ms
R4#ping 1.40.0.1 source 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.40.0.1, timeout is 2 seconds:
Packet sent with a source address of 4.4.4.4
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/6 ms
R1#sh ip bgp
BGP table version is 9, local router ID is 1.40.0.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
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.1/32       0.0.0.0                  0         32768 i
 *>  1.10.0.0/16      0.0.0.0                  0         32768 i
 *>  1.20.0.0/16      0.0.0.0                  0         32768 i
 *>  1.30.0.0/16      0.0.0.0                  0         32768 i
 *>  1.40.0.0/16      0.0.0.0                  0         32768 i
 *   2.2.2.2/32       3.1.1.3                                0 30 40 20 i
 *>                   2.1.1.2                  0             0 20 i
 *>  3.3.3.3/32       3.1.1.3                  0             0 30 i
 *   4.4.4.4/32       2.1.1.2                                0 20 40 i
 *>                   3.1.1.3                                0 30 40 i
R1#sh ip ro
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 9 subnets, 2 masks
C        1.1.1.1/32 is directly connected, Loopback0
C        1.10.0.0/16 is directly connected, Loopback1
L        1.10.0.1/32 is directly connected, Loopback1
C        1.20.0.0/16 is directly connected, Loopback2
L        1.20.0.1/32 is directly connected, Loopback2
C        1.30.0.0/16 is directly connected, Loopback3
L        1.30.0.1/32 is directly connected, Loopback3
C        1.40.0.0/16 is directly connected, Loopback4
L        1.40.0.1/32 is directly connected, Loopback4
      2.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C        2.1.1.0/24 is directly connected, GigabitEthernet0/0
L        2.1.1.1/32 is directly connected, GigabitEthernet0/0
B        2.2.2.2/32 [20/0] via 2.1.1.2, 00:08:50
      3.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C        3.1.0.0/16 is directly connected, GigabitEthernet0/1
L        3.1.1.1/32 is directly connected, GigabitEthernet0/1
B        3.3.3.3/32 [20/0] via 3.1.1.3, 00:08:49
      4.0.0.0/32 is subnetted, 1 subnets
B        4.4.4.4 [20/0] via 3.1.1.3, 00:08:49
R2#sh ip bgp
BGP table version is 9, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
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.1/32       2.1.1.1                  0             0 10 i
 *>  1.10.0.0/16      2.1.1.1                  0             0 10 i
 *>  1.20.0.0/16      2.1.1.1                  0             0 10 i
 *>  1.30.0.0/16      2.1.1.1                  0             0 10 i
 *>  1.40.0.0/16      2.1.1.1                  0             0 10 i
 *>  2.2.2.2/32       0.0.0.0                  0         32768 i
 *   3.3.3.3/32       4.2.1.4                                0 40 30 i
 *>                   2.1.1.1                                0 10 30 i
 *   4.4.4.4/32       2.1.1.1                                0 10 30 40 i
 *>                   4.2.1.4                  0             0 40 i
R2#sh ip ro
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
B        1.1.1.1/32 [20/0] via 2.1.1.1, 00:08:48
B        1.10.0.0/16 [20/0] via 2.1.1.1, 00:08:48
B        1.20.0.0/16 [20/0] via 2.1.1.1, 00:08:48
B        1.30.0.0/16 [20/0] via 2.1.1.1, 00:08:48
B        1.40.0.0/16 [20/0] via 2.1.1.1, 00:08:48
      2.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C        2.1.1.0/24 is directly connected, GigabitEthernet0/1
L        2.1.1.2/32 is directly connected, GigabitEthernet0/1
C        2.2.2.2/32 is directly connected, Loopback0
      3.0.0.0/32 is subnetted, 1 subnets
B        3.3.3.3 [20/0] via 2.1.1.1, 00:08:23
      4.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C        4.2.1.0/24 is directly connected, GigabitEthernet0/0
L        4.2.1.2/32 is directly connected, GigabitEthernet0/0
B        4.4.4.4/32 [20/0] via 4.2.1.4, 00:08:47
R3#sh ip bgp
BGP table version is 9, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
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.1/32       4.3.1.4                                0 40 20 10 i
 *>                   3.1.1.1                  0             0 10 i
 *   1.10.0.0/16      4.3.1.4                                0 40 20 10 i
 *>                   3.1.1.1                  0             0 10 i
 *   1.20.0.0/16      4.3.1.4                                0 40 20 10 i
 *>                   3.1.1.1                  0             0 10 i
 *   1.30.0.0/16      4.3.1.4                                0 40 20 10 i
 *>                   3.1.1.1                  0             0 10 i
 *   1.40.0.0/16      4.3.1.4                                0 40 20 10 i
 *>                   3.1.1.1                  0             0 10 i
 *   2.2.2.2/32       3.1.1.1                                0 10 20 i
 *>                   4.3.1.4                                0 40 20 i
 *>  3.3.3.3/32       0.0.0.0                  0         32768 i
 *>  4.4.4.4/32       4.3.1.4                  0             0 40 i
R3#sh ip ro
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
B        1.1.1.1/32 [20/0] via 3.1.1.1, 00:08:45
B        1.10.0.0/16 [20/0] via 3.1.1.1, 00:08:45
B        1.20.0.0/16 [20/0] via 3.1.1.1, 00:08:45
B        1.30.0.0/16 [20/0] via 3.1.1.1, 00:08:45
B        1.40.0.0/16 [20/0] via 3.1.1.1, 00:08:45
      2.0.0.0/32 is subnetted, 1 subnets
B        2.2.2.2 [20/0] via 4.3.1.4, 00:08:45
      3.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C        3.1.1.0/24 is directly connected, GigabitEthernet0/0
L        3.1.1.3/32 is directly connected, GigabitEthernet0/0
C        3.3.3.3/32 is directly connected, Loopback0
      4.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C        4.3.1.0/24 is directly connected, GigabitEthernet0/1
L        4.3.1.3/32 is directly connected, GigabitEthernet0/1
B        4.4.4.4/32 [20/0] via 4.3.1.4, 00:08:45
R4#sh ip bgp
BGP table version is 9, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
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.1/32       4.3.1.3                                0 30 10 i
 *>                   4.2.1.2                                0 20 10 i
 *   1.10.0.0/16      4.3.1.3                                0 30 10 i
 *>                   4.2.1.2                                0 20 10 i
 *   1.20.0.0/16      4.3.1.3                                0 30 10 i
 *>                   4.2.1.2                                0 20 10 i
 *   1.30.0.0/16      4.3.1.3                                0 30 10 i
 *>                   4.2.1.2                                0 20 10 i
 *   1.40.0.0/16      4.3.1.3                                0 30 10 i
 *>                   4.2.1.2                                0 20 10 i
 *>  2.2.2.2/32       4.2.1.2                  0             0 20 i
 *   3.3.3.3/32       4.2.1.2                                0 20 10 30 i
 *>                   4.3.1.3                  0             0 30 i
 *>  4.4.4.4/32       0.0.0.0                  0         32768 i
R4#sh ip ro
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
B        1.1.1.1/32 [20/0] via 4.2.1.2, 00:08:44
B        1.10.0.0/16 [20/0] via 4.2.1.2, 00:08:44
B        1.20.0.0/16 [20/0] via 4.2.1.2, 00:08:44
B        1.30.0.0/16 [20/0] via 4.2.1.2, 00:08:44
B        1.40.0.0/16 [20/0] via 4.2.1.2, 00:08:44
      2.0.0.0/32 is subnetted, 1 subnets
B        2.2.2.2 [20/0] via 4.2.1.2, 00:08:44
      3.0.0.0/32 is subnetted, 1 subnets
B        3.3.3.3 [20/0] via 4.3.1.3, 00:08:44
      4.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
C        4.2.1.0/24 is directly connected, GigabitEthernet0/1
L        4.2.1.4/32 is directly connected, GigabitEthernet0/1
C        4.3.1.0/24 is directly connected, GigabitEthernet0/0
L        4.3.1.4/32 is directly connected, GigabitEthernet0/0
C        4.4.4.4/32 is directly connected, Loopback0

Configure AS_PATH prepend

  • R1
conf t
!
ip prefix-list PRE-AS permit 1.10.0.0/16
!
route-map R-ASPRE permit 10
match ip address prefix-list PRE-AS
set as-path prepend 10 10 10
exit
!
route-map R-ASPRE permit 20
exit
!
router bgp 10
neighbor 2.1.1.2 route-map R-ASPRE out
exit
!
end
  • All Router
debug ip bgp updates
clear ip bgp *
u all
  • R1

may route-map not works….

R1#sh route-map
route-map R-ASPRE, permit, sequence 10
  Match clauses:
    ip address prefix-lists: PRE-AS
  Set clauses:
    as-path prepend 10 10 10
  Policy routing matches: 0 packets, 0 bytes
route-map R-ASPRE, permit, sequence 20
  Match clauses:
  Set clauses:
  Policy routing matches: 0 packets, 0 bytes
R1#sh ip prefix-list
ip prefix-list PRE-AS: 1 entries
   seq 5 permit 1.10.0.0/24
R1#sh ip proto | section bgp
Routing Protocol is "bgp 10"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  IGP synchronization is disabled
  Automatic route summarization is disabled
  Neighbor(s):
    Address          FiltIn FiltOut DistIn DistOut Weight RouteMap
    2.1.1.2
     3.1.1.3
    3.1.1.3
  Maximum path: 1
  Routing Information Sources:
    Gateway         Distance      Last Update
    3.1.1.3               20      00:06:02
    2.1.1.2               20      00:06:00
  Distance: external 20 internal 200 local 200
R1#sh run | section router bgp 10
router bgp 10
 bgp log-neighbor-changes
 network 1.1.1.1 mask 255.255.255.255
 network 1.10.0.0 mask 255.255.0.0
 network 1.20.0.0 mask 255.255.0.0
 network 1.30.0.0 mask 255.255.0.0
 network 1.40.0.0 mask 255.255.0.0
 neighbor 2.1.1.2 remote-as 20
 neighbor 2.1.1.2 route-map R-ASPRE out
 neighbor 3.1.1.3 remote-as 30

oh… prefix-list mask wrong… expected 16, but actual 24…

R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#no ip prefi
R1(config)#no ip prefix-list PRE-AS ?
  deny         Specify packets to reject
  description  Prefix-list specific description
  permit       Specify packets to forward
  seq          sequence number of an entry
  <cr>

R1(config)#no ip prefix-list PRE-AS
R1(config)#ip prefi
R1(config)#ip prefix-list PRE-AS 1.10.0.0/16
                                 ^
% Invalid input detected at '^' marker.

R1(config)#ip prefix-list PRE-AS  1.10.0.0/16
*Nov 25 06:06:33.553: BGP(0): (base) 2.1.1.2 send UPDATE (format) 3.3.3.3/32, next 2.1.1.1, metric 0, path 30
*Nov 25 06:06:33.554: BGP(0): (base) 2.1.1.2 send UPDATE (format) 1.1.1.1/32, next 2.1.1.1, metric 0, path Local
*Nov 25 06:06:33.581: BGP(0): 2.1.1.2 rcv UPDATE w/ attr: nexthop 2.1.1.2, origin i, originator 0.0.0.0, merged path 20 40 30 10, AS_PATH , community , extended community , SSA attribute
*Nov 25 06:06:33.583: BGPSSA ssacount is 0
*Nov 25 06:06:33.583: BGP(0): 2.1.1.2 rcv UPDATE about 1.1.1.1/32 -- DENIED due to: AS-PATH contains our own AS;
*Nov 25 06:06:33.584: BGP(0): 2.1.1.2 rcv UPDATE about 1.10.0.0/16 -- DENIED due to: AS-PATH contains our own AS;
R1(config)#ip prefix-list PRE-AS  1.10.0.0/16
*Nov 25 06:06:33.584: BGP(0): 2.1.1.2 rcv UPDATE about 1.20.0.0/16 -- DENIED due to: AS-PATH contains our own AS;
*Nov 25 06:06:33.585: BGP(0): 2.1.1.2 rcv UPDATE about 1.30.0.0/16 -- DENIED due to: AS-PATH contains our own AS;
*Nov 25 06:06:33.586: BGP(0): 2.1.1.2 rcv UPDATE about 1.40.0.0/16 -- DENIED due to: AS-PATH contains our own AS;
R1(config)#ip prefix-list PRE-AS permit 1.10.0.0/16
R1#sh route-map
route-map R-ASPRE, permit, sequence 10
  Match clauses:
    ip address prefix-lists: PRE-AS
  Set clauses:
    as-path prepend 10 10 10
  Policy routing matches: 0 packets, 0 bytes
route-map R-ASPRE, permit, sequence 20
  Match clauses:
  Set clauses:
  Policy routing matches: 0 packets, 0 bytes
R1#sh ip prefix-list
ip prefix-list PRE-AS: 1 entries
   seq 5 permit 1.10.0.0/16
R1#sh ip proto | sect bgp
Routing Protocol is "bgp 10"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  IGP synchronization is disabled
  Automatic route summarization is disabled
  Neighbor(s):
    Address          FiltIn FiltOut DistIn DistOut Weight RouteMap
    2.1.1.2
     3.1.1.3
    3.1.1.3
  Maximum path: 1
  Routing Information Sources:
    Gateway         Distance      Last Update
    3.1.1.3               20      00:11:43
    2.1.1.2               20      00:11:41
  Distance: external 20 internal 200 local 200
R4#sh ip bgp
BGP table version is 9, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
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.1/32       4.2.1.2                                0 20 10 i
 *>                   4.3.1.3                                0 30 10 i
 *>  1.10.0.0/16      4.3.1.3                                0 30 10 i
 *   1.20.0.0/16      4.2.1.2                                0 20 10 i
 *>                   4.3.1.3                                0 30 10 i
 *   1.30.0.0/16      4.2.1.2                                0 20 10 i
 *>                   4.3.1.3                                0 30 10 i
 *   1.40.0.0/16      4.2.1.2                                0 20 10 i
 *>                   4.3.1.3                                0 30 10 i
 *   2.2.2.2/32       4.3.1.3                                0 30 10 20 i
 *>                   4.2.1.2                  0             0 20 i
 *>  3.3.3.3/32       4.3.1.3                  0             0 30 i
 *>  4.4.4.4/32       0.0.0.0                  0         32768 i

no changes

R1#clear ip bgp * soft out
R1#
*Nov 25 06:08:31.080: BGP(0): (base) 3.1.1.3 send UPDATE (format) 4.4.4.4/32, next 3.1.1.1, metric 0, path 20 40
*Nov 25 06:08:31.081: BGP(0): (base) 2.1.1.2 send UPDATE (format) 3.3.3.3/32, next 2.1.1.1, metric 0, path 30
*Nov 25 06:08:31.083: BGP(0): (base) 3.1.1.3 send UPDATE (format) 2.2.2.2/32, next 3.1.1.1, metric 0, path 20
*Nov 25 06:08:31.084: BGP(0): (base) 2.1.1.2 send UPDATE (format) 1.1.1.1/32, next 2.1.1.1, metric 0, path Local
*Nov 25 06:08:31.084: BGP(0): (base) 2.1.1.2 send UPDATE (format) 1.10.0.0/16, next 2.1.1.1, metric 0, path Local
*Nov 25 06:08:31.085: BGP(0): (base) 3.1.1.3 send UPDATE (format) 1.1.1.1/32, next 3.1.1.1, metric 0, path Local
R1#sh ip proto | sect bgp
Routing Protocol is "bgp 10"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  IGP synchronization is disabled
  Automatic route summarization is disabled
  Neighbor(s):
    Address          FiltIn FiltOut DistIn DistOut Weight RouteMap
    2.1.1.2
     3.1.1.3
    3.1.1.3
  Maximum path: 1
  Routing Information Sources:
    Gateway         Distance      Last Update
    3.1.1.3               20      00:12:58
    2.1.1.2               20      00:12:57
  Distance: external 20 internal 200 local 200
R1#clear ip bgp *
R1#
*Nov 25 06:10:08.879: %BGP-3-NOTIFICATION_ALL: sent to all sessions 6/4 (Administrative Reset)
R1#
*Nov 25 06:10:08.904: %BGP-5-ADJCHANGE: neighbor 2.1.1.2 Down User reset
*Nov 25 06:10:08.905: %BGP_SESSION-5-ADJCHANGE: neighbor 2.1.1.2 IPv4 Unicast topology base removed from session  User reset
*Nov 25 06:10:08.909: %BGP-5-ADJCHANGE: neighbor 3.1.1.3 Down User reset
*Nov 25 06:10:08.909: %BGP_SESSION-5-ADJCHANGE: neighbor 3.1.1.3 IPv4 Unicast topology base removed from session  User reset

All routers hard reset.

clear ip bgp *
R1#sh ip bgp
BGP table version is 9, local router ID is 1.40.0.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
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.1/32       0.0.0.0                  0         32768 i
 *>  1.10.0.0/16      0.0.0.0                  0         32768 i
 *>  1.20.0.0/16      0.0.0.0                  0         32768 i
 *>  1.30.0.0/16      0.0.0.0                  0         32768 i
 *>  1.40.0.0/16      0.0.0.0                  0         32768 i
 *   2.2.2.2/32       3.1.1.3                                0 30 40 20 i
 *>                   2.1.1.2                  0             0 20 i
 *>  3.3.3.3/32       3.1.1.3                  0             0 30 i
 *   4.4.4.4/32       2.1.1.2                                0 20 40 i
 *>                   3.1.1.3                                0 30 40 i
R2#sh ip bgp
BGP table version is 10, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
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.1/32       2.1.1.1                  0             0 10 i
 *>  1.10.0.0/16      4.2.1.4                                0 40 30 10 i
 *                    2.1.1.1                  0             0 10 10 10 10 i
 *>  1.20.0.0/16      2.1.1.1                  0             0 10 i
 *>  1.30.0.0/16      2.1.1.1                  0             0 10 i
 *>  1.40.0.0/16      2.1.1.1                  0             0 10 i
 *>  2.2.2.2/32       0.0.0.0                  0         32768 i
 *   3.3.3.3/32       4.2.1.4                                0 40 30 i
 *>                   2.1.1.1                                0 10 30 i
 *   4.4.4.4/32       2.1.1.1                                0 10 30 40 i
 *>                   4.2.1.4                  0             0 40 i
R3#sh ip bgp
BGP table version is 9, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
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.1/32       4.3.1.4                                0 40 20 10 i
 *>                   3.1.1.1                  0             0 10 i
 *>  1.10.0.0/16      3.1.1.1                  0             0 10 i
 *   1.20.0.0/16      4.3.1.4                                0 40 20 10 i
 *>                   3.1.1.1                  0             0 10 i
 *   1.30.0.0/16      4.3.1.4                                0 40 20 10 i
 *>                   3.1.1.1                  0             0 10 i
 *   1.40.0.0/16      4.3.1.4                                0 40 20 10 i
 *>                   3.1.1.1                  0             0 10 i
 *   2.2.2.2/32       3.1.1.1                                0 10 20 i
 *>                   4.3.1.4                                0 40 20 i
 *>  3.3.3.3/32       0.0.0.0                  0         32768 i
 *>  4.4.4.4/32       4.3.1.4                  0             0 40 i
R4#traceroute 1.10.0.1 source 4.4.4.4
Type escape sequence to abort.
Tracing the route to 1.10.0.1
VRF info: (vrf in name/id, vrf out name/id)
  1 4.3.1.3 5 msec 4 msec 5 msec
  2 3.1.1.1 6 msec 5 msec 6 msec
R4#sh ip bgp
BGP table version is 10, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
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.1/32       4.3.1.3                                0 30 10 i
 *>                   4.2.1.2                                0 20 10 i
 *>  1.10.0.0/16      4.3.1.3                                0 30 10 i
 *   1.20.0.0/16      4.3.1.3                                0 30 10 i
 *>                   4.2.1.2                                0 20 10 i
 *   1.30.0.0/16      4.3.1.3                                0 30 10 i
 *>                   4.2.1.2                                0 20 10 i
 *   1.40.0.0/16      4.3.1.3                                0 30 10 i
 *>                   4.2.1.2                                0 20 10 i
 *>  2.2.2.2/32       4.2.1.2                  0             0 20 i
 *   3.3.3.3/32       4.2.1.2                                0 20 10 30 i
 *>                   4.3.1.3                  0             0 30 i
 *>  4.4.4.4/32       0.0.0.0                  0         32768 i
R4#sh ip ro
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
B        1.1.1.1/32 [20/0] via 4.2.1.2, 00:02:58
B        1.10.0.0/16 [20/0] via 4.3.1.3, 00:02:57
B        1.20.0.0/16 [20/0] via 4.2.1.2, 00:02:58
B        1.30.0.0/16 [20/0] via 4.2.1.2, 00:02:58
B        1.40.0.0/16 [20/0] via 4.2.1.2, 00:02:58
      2.0.0.0/32 is subnetted, 1 subnets
B        2.2.2.2 [20/0] via 4.2.1.2, 00:02:58
      3.0.0.0/32 is subnetted, 1 subnets
B        3.3.3.3 [20/0] via 4.3.1.3, 00:02:57
      4.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
C        4.2.1.0/24 is directly connected, GigabitEthernet0/1
L        4.2.1.4/32 is directly connected, GigabitEthernet0/1
C        4.3.1.0/24 is directly connected, GigabitEthernet0/0
L        4.3.1.4/32 is directly connected, GigabitEthernet0/0
C        4.4.4.4/32 is directly connected, Loopback0
R4#sh ip ro
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
B        1.1.1.1/32 [20/0] via 4.2.1.2, 00:02:58
B        1.10.0.0/16 [20/0] via 4.3.1.3, 00:02:57
B        1.20.0.0/16 [20/0] via 4.2.1.2, 00:02:58
B        1.30.0.0/16 [20/0] via 4.2.1.2, 00:02:58
B        1.40.0.0/16 [20/0] via 4.2.1.2, 00:02:58
      2.0.0.0/32 is subnetted, 1 subnets
B        2.2.2.2 [20/0] via 4.2.1.2, 00:02:58
      3.0.0.0/32 is subnetted, 1 subnets
B        3.3.3.3 [20/0] via 4.3.1.3, 00:02:57
      4.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
C        4.2.1.0/24 is directly connected, GigabitEthernet0/1
L        4.2.1.4/32 is directly connected, GigabitEthernet0/1
C        4.3.1.0/24 is directly connected, GigabitEthernet0/0
L        4.3.1.4/32 is directly connected, GigabitEthernet0/0
C        4.4.4.4/32 is directly connected, Loopback0
R4#ping 1.10.0.1 source 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.10.0.1, timeout is 2 seconds:
Packet sent with a source address of 4.4.4.4
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 5/6/8 ms

let's say erase route-map explicit permit any.

R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#no route-map R-ASPRE ?
  <0-65535>  Sequence to insert to/delete from existing route-map entry
  deny       Route map denies set operations
  permit     Route map permits set operations
  <cr>

R1(config)#no route-map R-ASPRE pe
R1(config)#no route-map R-ASPRE permit ?
  <0-65535>  Sequence to insert to/delete from existing route-map entry
  <cr>

R1(config)#no route-map R-ASPRE permit 20
R1(config)#do sh route-map
route-map R-ASPRE, permit, sequence 10
  Match clauses:
    ip address prefix-lists: PRE-AS
  Set clauses:
    as-path prepend 10 10 10
  Policy routing matches: 0 packets, 0 bytes
R1#sh ip bgp
BGP table version is 9, local router ID is 1.40.0.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
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.1/32       0.0.0.0                  0         32768 i
 *>  1.10.0.0/16      0.0.0.0                  0         32768 i
 *>  1.20.0.0/16      0.0.0.0                  0         32768 i
 *>  1.30.0.0/16      0.0.0.0                  0         32768 i
 *>  1.40.0.0/16      0.0.0.0                  0         32768 i
 *   2.2.2.2/32       3.1.1.3                                0 30 40 20 i
 *>                   2.1.1.2                  0             0 20 i
 *   3.3.3.3/32       2.1.1.2                                0 20 40 30 i
 *>                   3.1.1.3                  0             0 30 i
 *   4.4.4.4/32       2.1.1.2                                0 20 40 i
 *>                   3.1.1.3                                0 30 40 i
R2#sh ip bgp
BGP table version is 10, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
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.1/32       4.2.1.4                                0 40 30 10 i
 *>  1.10.0.0/16      4.2.1.4                                0 40 30 10 i
 *                    2.1.1.1                  0             0 10 10 10 10 i
 *>  1.20.0.0/16      4.2.1.4                                0 40 30 10 i
 *>  1.30.0.0/16      4.2.1.4                                0 40 30 10 i
 *>  1.40.0.0/16      4.2.1.4                                0 40 30 10 i
 *>  2.2.2.2/32       0.0.0.0                  0         32768 i
 *>  3.3.3.3/32       4.2.1.4                                0 40 30 i
 *>  4.4.4.4/32       4.2.1.4                  0             0 40 i
R3#sh ip bgp
BGP table version is 9, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
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.1/32       3.1.1.1                  0             0 10 i
 *>  1.10.0.0/16      3.1.1.1                  0             0 10 i
 *>  1.20.0.0/16      3.1.1.1                  0             0 10 i
 *>  1.30.0.0/16      3.1.1.1                  0             0 10 i
 *>  1.40.0.0/16      3.1.1.1                  0             0 10 i
 *   2.2.2.2/32       3.1.1.1                                0 10 20 i
 *>                   4.3.1.4                                0 40 20 i
 *>  3.3.3.3/32       0.0.0.0                  0         32768 i
 *>  4.4.4.4/32       4.3.1.4                  0             0 40 i
R4#sh ip bgp
BGP table version is 10, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
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.1/32       4.3.1.3                                0 30 10 i
 *>  1.10.0.0/16      4.3.1.3                                0 30 10 i
 *>  1.20.0.0/16      4.3.1.3                                0 30 10 i
 *>  1.30.0.0/16      4.3.1.3                                0 30 10 i
 *>  1.40.0.0/16      4.3.1.3                                0 30 10 i
 *>  2.2.2.2/32       4.2.1.2                  0             0 20 i
 *>  3.3.3.3/32       4.3.1.3                  0             0 30 i
 *>  4.4.4.4/32       0.0.0.0                  0         32768 i

following routes via AS 20 removed from BGP table R1-R4 because implicit route-map deny applied.
R1 does not advertise any routes exclude 1.10.0.0/16 to AS 20 peer.

1.20.0.0/16
1.30.0.0/16
1.40.0.0/16

above destination route, all traffics to AS 10, through AS 30.

References

tech/network/cisco/bgp/bgp/bgp-as-path/bgp-as-path.txt · Last modified: 2018/11/25 15:29 by wnoguchi