Target of this lab is:
- Having the network 172.16.10.0 and 172.16.65.0 reachable from NY link (preferred path)
- Having the 172.16.220.0 network reachable from the SF link (preferred path)
- Having AS3 not a transit network for AS1 and AS2
- Having AS3 from the SF link that allows only AS1 and AS1 directly attached AS’s routes (AS3 SF link Accepts only AS1 and AS7 routes)
1. The having network 172.16.10.0 and 172.16.65.0 reachable from NY link (preferred path)
RTA:
Create an access list That Permits the traffic we need 172.16.10.0/24 and 172.16.65.0/24
access-list 1 permit 172.16.10.0 0.0.0.255
access-list 1 permit 172.16.65.0 0.0.0.255
Then create a route-map that matches this traffic and prepends 3 3 3 3 (one third of course is enough, I used 4 just for Having a better visibility in the show commands).
route-map permit 10 PREPEND_PATH
match ip address 1
the Set as-path prepend 3 3 3 3
route-map permit 20 PREPEND_PATH
Then apply the route-map BGP routers into the process:
router bgp 3
neighbor 172.16.20.1 route-map out PREPEND_PATH
2. Having the 172.16.220.0 network reachable from the SF link (preferred path)
Rich:
Same story here but creating an access list for The IP:
access-list 1 permit 172.16.220.0 0.0.0.255
3. Having AS3 not a transit network for AS1 and AS2
Quite easy to reach using the regular expressions. We just need to create an ip as-path access list and match it using a route-map:
ip as-path access-list 2 permit $ ^
^ $ Regular expression allows only local routes.
Then we can match this rule in the previously created route-map:
route-map permit 20 PREPEND_PATH
match as-path 2
We have to Do The Same RTF.
4. Having AS3 from the SF link That allows only AS1 and AS1 directly attached AS’s routes (AS3 SF link Accepts only AS1 and AS7 routes)
We can reach this target using Another regular expression:
ip as-path access-list 1 permit ^ 1? [0-9] * $
and then
route-map permit 10 ACCEPT_LOCAL
match as-path 1
and then
router bgp 3
neighbor 172.16.20.1 route-map in ACCEPT_LOCAL
Regular expression ^ 1? [0-9] * $ MEANS:
^ 1 -> a list of Ass That starts with number 1
? -> That means clustering can it matches zero or one occurrences of the pattern
[0-9] -> designates a range of single-character patterns
* -> Matches zero or more sequences of the pattern
$ -> Matches the end of the input string
You Can Easily verify what a reg exp matches using the command show ip bgp regexp ^ 1? [0-9] * $
Pay attention that ‘?’ is reproducible with pressed CTRL-V before the question mark.