1.5.d AS path manipulations
1.5.d i local-as, allowas-in, remove-private-as
Local AS
Local AS configuration, essentially works the same way as the no-export community function, in that prefixes that are tagged are only advertised to neighbours within the same sub-AS, not to other sub-AS’ or eBGP peers. It allows a router to appear to be a member of a second AS in addition to its real AS.
router bgp 65000
neighbor <ip address> local-as <AS>
AllowAS-in
The BGP loop-prevention mechanism doesn’t allow a BGP speaker to accept prefixes with the local AS number in the AS-path list. However in some cases, it would be desirable to accept the routes originated in the same AS via another AS.
router bgp 6500
neighbor <ip address> allowas-in
Remove-Private-AS
Since Private AS’ are not globally unique, a common requirement is for ISPs to remove a private AS number from BGP updates received from that customer before sending updates to upstream eBGP peers.
router bgp 65000
neighbor <ip address> remove-private-as
1.5.d ii Prepend
Prepending is the process of making a route less likely to be installed into the RIB or the BGP table by artificially increasing the length of the AS Path. Remember that the shorter AS Path will be selected, so by manually setting an advertised route to look like it has a longer AS Path, another route will be preferred.
Define the networks for which you want a prepend the as:
ip prefix-list R7-R9-HOST seq 5 permit 155.1.7.0/24
ip prefix-list R7-R9-HOST seq 10 permit 155.1.9.0/24
Define Route map with the match statement and prepend the as-path:
route-map R7-R9-NETWORKS permit 10
match ip address prefix-list R7-R9-HOST
set as-path prepend 200 200
Add the route-map to the specific neighbor:
router bgp 200
neighbor 155.1.37.3 route-map R7-R9-NETWORKS out
Verification (some output omitted):
R3#sh ip bgp
BGP table version is 12, local router ID is 150.1.3.3
Network Next Hop Metric LocPrf Weight Path
*>i 155.1.7.0/24 150.1.6.6 0 100 0 200 i
* 155.1.37.7 0 0 200 200 200 i
*>i 155.1.9.0/24 150.1.6.6 0 100 0 200 i
* 155.1.37.7 0 200 200 200 i
1.5.d iii Regexp
| Character | Use |
| ? | Repeats the previous character one or zero times |
| * | Repeats the previous character zero or many times |
| + | Repeats the previous character one or more times |
| ^ | Matches the beginning of a string |
| $ | Matches the end of a string |
| [] | Defines a range |
| _ | Matches the space between AS numbers or the end of the AS Path List |
| \\ | Is an escape character, required for BGP Confederations |
Examples
| ^$ | Matches an empty AS Path so it will match all prefixes from the local AS. |
| ^51_ | Matches prefixes from AS 51 that is directly connected to our AS |
| _51_ | Matches prefixes that transit AS 51 |
| _51$ | Matches prefixes that originated in AS 51, the $ ensures that it’s the beginning of the AS Path. |
| ^([0-9]+)_51 | Matches prefixes from AS 51, where AS 51 is behind one of our directly connected AS’. |
| ^51_([0-9]+) | Matches prefixes from the clients of directly connected AS 51. |
| ^(51_)+([0-9]+) | Matches prefixes from the clients of directly connected AS 51, where AS 51 might be doing AS Path prepending. |
| ^51_([0-9]+_)+ | Matches prefixes from the clients of directly connected AS 51, where the clients might be doing AS Path prepending. |
| ^\65200\) | Matches |
Comments
So empty here ... leave a comment!