How to configure BGP AS_Path with regular Expressions on Cisco routers?

BGP AS_PATH Attribute
AS_PATH filtration basically used to filter the BGP route to control the network traffic. For example:
_99$ = Routes having as-path value ends with 99
^10_ = Routes having as-path value starts with 10
_88_ = Routes having as-path value 88, either at start or at end or in middle
.* = Routes having any value of as-path
RUNNING RIP ON ROUTER-A
A(config)# router rip
A(config-router)# network 200.100.50.0
A(config-router)# network 1.0.0.0
RUNNING EBGP ON ROUTER-A
A(config)# router bgp 10
A(config-router)# no synchronization
A(config-router)# neighbor 1.1.1.2 remote-as 20
A(config-router)# neighbor 4.1.1.1 remote-as 20
A(config-router)# network200.100.50.0
RUNNING EBGP ON ROUTER-B
B(config)# router bgp 20
B(config-router)# no synchronization
B(config-router)# neighbor 1.1.1.1remote-as 10
RUNNING EBGP ON ROUTER-D
D(config)# router bgp 20
D(config-router)# no synchronization
D(config-router)# neighbor 4.1.1.2 remote-as 10
RUNNING OSPF ON ROUTER-B
B(config)# router ospf 1
B(config-router)# network 2.0.0.0 0.255.255.255 area 0
B(config-router)# network 1.0.0.0 0.255.255.255 area 0
RUNNING OSPF ON ROUTER-C
C(config)# router ospf 1
C(config-router)# network 2.0.0.0 0.255.255.255 area 0
C(config-router)# network 3.0.0.0 0.255.255.255 area 0
RUNNING OSPF ON ROUTER-D
D(config)# router ospf 1
D(config-router)# network 3.0.0.0 0.255.255.255 area 0
D(config-router)# network 4.0.0.0 0.255.255.255 area 0
RUNNING IBGP ON ROUTER-B
B(config)# router bgp 20
B(config-router)# no synchronization
B(config-router)# neighbor 4.1.1.1 remote-as 20
B(config-router)# neighbor 2.1.1.2 remote-as 20
RUNNING IBGP ON ROUTER-C
C(config)# router bgp 20
C(config-router)# no synchronization
C(config-router)# neighbor 2.1.1.1 remote-as 20
C(config-router)# neighbor 3.1.1.2 remote-as 20
RUNNING IBGP ON ROUTER-D
D(config)# router bgp 20
D(config-router)# no synchronization
D(config-router)# neighbor 3.1.1.1 remote-as 20
D(config-router)# neighbor 2.1.1.1 remote-as 20
DEFINING 4 STATIC ROUTES ON ROUTER-A
A(config)# ip route 192.1.18.0 255.255.255.0 null 0
A(config)# ip route 192.1.19.0 255.255.255.0 null 0
A(config)# ip route 192.1.20.0 255.255.255.0 null 0
REDISTRIBUTION OF STATIC ROUTES INTO BGP 10 on ROUTER-A
A(config)# router bgp 10
A(config-router)# redistribute static
CREATING ACCESS-LIST ON ROUTER-A
A(config)# access-list 51 permit 200.100.50.0 0.0.0.255
A(config)# access-list 51 permit 192.1.17.0 0.0.0.255
A(config)# access-list 51 permit 192.1.18.0 0.0.0.255
A(config)# access-list 52 permit 192.1.19.0 0.0.0.255
A(config)# access-list 52 permit 192.1.20.0 0.0.0.255
CREATING ROUTE-MAP (AD) ON ROUTER-A
A(config)# route-map AD permit 10
A(config-route-map)# match ip address 51
A(config-route-map)# set as-path prepend 33
A(config-route-map)# exit
A(config)# route-map AD permit 20
A(config-route-map)# match ip address 52
A(config-route-map)# set as-path prepend 88 99
CREATING ROUTE-MAP (AB) ON ROUTER-A
A(config)# route-map AB permit 10
A(config-route-map)# match ip address 51
A(config-route-map)# et as-path prepend 44 55
A(config-route-map)# exit
A(config)# route-map AB permit 20
A(config-route-map)# match ip address 52
A(config-route-map)# et as-path prepend 66
APPLYING ROUTE-MAP (AD & AB) ON ROUTER-A
A(config)# router bgp 10
A(config-router)# neighbor 4.1.1.1 route-map AD out
A(config-router)# neighbor 1.1.1.2 route-map AB out
D(config)# ip as-path access-list 5 deny _99$
D(config)# ip as-path access-list 5 permit .*
D(config)# router bgp 20
D(config)# neighbor 4.1.1.2 filter-list 5 in
D# clear ip bgp *
D# show ip bgp

Related Articles
-
How to configure RIP v2 step by step? RIP short for "Routing Information Protocol" is a routing protocol used to select the suitable route for packets with in network.. Read More...
How to configure static routes on Cisco routers? You can configure two types of routing on the router- static and dynamic to send the traffic to destination. Read More...
How to configure VLAN on a Cisco Switch? VLAN stands for virtual LAN and technically we can say, a VLAN is a broadcast domain created by switch. When managing a switch, the management domain is always VLAN 1, the default VLAN. All ports of switch are assigned to VLAN 1 by default. VLAN increase the performance of a network because it divide a network logically in different parts and limit the broadcasts. Read More...
How to configure VTP Client and Server? VTP (VLAN Trunking Protocol) is the protocol that propagates the information about which VLANs exist from one switch to another switch. If VTP did not provide this information, VLANs would have to be created on all switches individually in the network. Read More..
How to configure Trunking between VLANs with 802.1q? Trunk link is used to carry the different VLANs traffic on a single link. There are two different protocols are used for Ethernet trunking, 802. 1q and ISL. Trunking change the formatting of the packets. Read More...How to configure Trunking between VLANs with ISL? Trunking is a technique to carry different VLAN traffic using point to point link between two devices. ISL (InterSwitch Link) is a cisco proprietary protocol can work with Ethernet token ring and Fddi also. Trunking changes the formatting of the packets. Read More...