BGP AS (Autonomous System) prepending is a technique used to influence the inbound traffic by making a particular Autonomous System path less attractive. This is achieved by adding the AS number multiple times to the AS path attribute of BGP updates sent to a neighbor. The idea is to make the AS path longer, and therefore less preferred, in order to influence incoming traffic.
Here’s a general guide on how to configure BGP AS prepending:
Cisco IOS Command-Line Configuration:
- Access Global Configuration Mode: Enter the global configuration mode on the router:
bash
router(config)# router bgp <your-AS-number>
- Configure AS Prepending: Specify the AS path for the neighbor you want to influence. The
route-map
is used to apply the AS path prepend configuration.bashrouter(config-router)# neighbor <neighbor-IP-address> route-map <route-map-name> out
- Create a Route Map: Define a route map that includes the
set as-path prepend
command. The following example prepends the local AS number three times:bashrouter(config)# route-map PREPEND-AS permit 10
router(config-route-map)# match ip address <access-list-number>
router(config-route-map)# set as-path prepend <your-AS-number> <your-AS-number> <your-AS-number>
- Apply Access List: Create an access list to match the specific routes you want to influence:
bash
router(config)# ip access-list standard <access-list-number>
router(config-std-nacl)# permit <source-IP-prefix>
Or, you can use a prefix list for more granularity:
bashrouter(config)# ip prefix-list <prefix-list-name> seq 10 permit <source-IP-prefix/mask>
Ensure that the
match ip address
ormatch ip prefix-list
in the route map refers to the correct access list or prefix list. - Verify Configuration: Verify that the AS path has been prepended for the specific routes:
bash
show ip bgp neighbor <neighbor-IP-address> advertised-routes
Check the AS path for the routes you’ve prepended.
- Save Configuration: Save the configuration changes:
bash
write memory
Example Configuration:
Here’s an example configuration:
router bgp 65000
neighbor 192.168.1.1 route-map PREPEND-AS out
route-map PREPEND-AS permit 10match ip address 1
set as-path prepend 65000 65000 65000
ip access-list standard 1permit 10.0.0.0 0.255.255.255
In this example, the AS path for routes matching access list 1 will be prepended three times before being sent to the neighbor with IP address 192.168.1.1.
Adjust the configuration according to your specific network topology, IP addressing, and BGP requirements. Always consider the impact of changes on your overall network routing before applying them.