BGP Policy Lab: Remember, All The Above Applies To Both Ipv4 and Ipv6
BGP Policy Lab: Remember, All The Above Applies To Both Ipv4 and Ipv6
1/22
Pre-requisites
This exercise builds upon the congurations implemented in the basic BGP routing lab. You must:
Verify that all your BGP sessions are up
Be able to see every lab prex in your routing table
Be able to ping and traceroute successfully to any other router in the lab.
Remember, all the above applies to both IPv4 and IPv6.
Workshops - http://workshops.nsrc.org/dokuwiki/
Last update:
2016:preginet-bgp:3-lab-bgp-policy http://workshops.nsrc.org/dokuwiki/doku.php?id=2016:preginet-bgp:3-lab-bgp-policy
2016/01/17 03:37
Local Preference
Our rst goal is to congure our routers to prefer the paths via the NREN for outgoing trac to ALL
destinations.
2016/01/17 04:05
3/22
your own prex). In B12, the next hop should be B11's loopback address. Remember the 'next-hopself' parameter?
show ip bgp
show bgp ipv6 unicast
All good now, right?
Wait! What about the prexes of ASs with whom you are peering directly? Remember the path
selection algorithm? What comes rst, highest local preference or shortest AS path?
Last update:
2016:preginet-bgp:3-lab-bgp-policy http://workshops.nsrc.org/dokuwiki/doku.php?id=2016:preginet-bgp:3-lab-bgp-policy
2016/01/17 03:37
!
route-map set-lpref-isp permit 10
description Set High Local Pref for adjacent ASNs
match as-path 1
set local-preference 200
route-map set-lpref-isp permit 20
description Set Low Local Pref for rest of ISP routes
set local-preference 50
!
router bgp 10
address-family ipv4
neighbor 100.121.1.1 route-map set-lpref-isp in
address-family ipv6
neighbor 2001:18:0:10:: route-map set-lpref-isp in
!
Use BGP route refresh to make sure that the policies are applied:
clear ip bgp external in
clear bgp ipv6 unicast external in
The use of external in the command means to refresh the External BGP (eBGP) sessions only - the
Internal BGP (iBGP) sessions are not touched in this case.
Check your BGP routes again. What is the next hop towards your direct peers' prexes? Can you
explain what is happening now?
2016/01/17 04:05
5/22
!
The other router groups should come up with a similar conguration for B12 through R62. The routemap will be the same, just allowing prexes from the neighbouring AS into the network, and setting
the local preference high. Once this is applied, all prexes from immediately adjacent ASes will be
local preference 200.
Note that the route-map set-lpref-peer does not have a line 20 which makes it an implicit lter. (Cisco
IOS route-maps drop prexes by default unless there is a matching condition.) Not including a
following line ensures that any prex a peer sends to the local AS must only be originated by the
adjacent AS, and not be transited from anywhere else.
Explain why this might be a good idea.
Use BGP route refresh to make sure that the policies are applied:
clear ip bgp external in
clear bgp ipv6 unicast external in
Check your BGP routes again. What is the next hop towards your direct peers' prexes? (Hint: the
path should be direct now!)
AS-Path Prepending
At this point we have inuenced outbound trac only. Now we want to inuence the trac COMING
IN to our AS. We want trac to come to us via the R&E networks as much as possible.
In the case of this lab, every other group is already preferring the NREN link for their outgoing trac.
For groups connected to your same NREN, the trac towards you will NOT go via the commodity
(commercial) Internet. However, this is not the case for groups connected to other NRENs.
To see this, check your paths towards groups NOT connected to your NREN, starting from your core
router (normally the campus core L3 switch) - aim for another core router. For example, from AS10
using both IPv4 and IPv6:
Workshops - http://workshops.nsrc.org/dokuwiki/
Last update:
2016:preginet-bgp:3-lab-bgp-policy http://workshops.nsrc.org/dokuwiki/doku.php?id=2016:preginet-bgp:3-lab-bgp-policy
2016/01/17 03:37
C11#
C11#
C11#
C11#
Notice that the trac leaves via the R&E networks, but then enters AS40 through their commercial
ISP.
The same happens with trac coming back to you from other NRENs. How might you inuence
another ASes best path selection so that trac towards you enters via your NREN (say)?
We will now use a technique called AS path prepending, which consists of adding extra fake hops to
a path using our ASN multiple times.
http://workshops.nsrc.org/dokuwiki/
2016/01/17 04:05
7/22
Ask remote groups (connected to the other NRENs), to verify that their paths towards you do not
traverse the commercial ISPs.
BGP Communities
Now let's reect on our initial outbound policy. Since our NREN carries commodity Internet prexes in
addition to R&E prexes, we decided to use the Local Preference attribute to send everything via the
NREN.
In reality this may not be optimal, because the NREN may not always have the best paths towards the
rest of the Internet and also because we're not taking advantage of our dual connections to loadbalance our outbound trac.
What we really need is a way to tell which prexes are originated from the R&E community, so
that we prefer the NREN link when sending to those prexes only, and let the rest be decided by the
regular BGP selection process. This is where BGP Communities are useful.
Last update:
2016:preginet-bgp:3-lab-bgp-policy http://workshops.nsrc.org/dokuwiki/doku.php?id=2016:preginet-bgp:3-lab-bgp-policy
2016/01/17 03:37
in
in
in
in
NREN2:
ip bgp-community new-format
http://workshops.nsrc.org/dokuwiki/
2016/01/17 04:05
9/22
!
route-map set-RE-comm permit 10
description Tag what we get from RE customer
set community 102:99
!
ip community-list 1 permit 100:99
!
route-map set-RE-lpref permit 10
description Look for RE routes from RREN
match community 1
set local-preference 150
route-map set-RE-lpref permit 20
description Other routes are untouched
!
router bgp 102
address-family ipv4
neighbor 100.102.1.2 send-community
neighbor 100.102.1.2 route-map set-RE-comm in
neighbor 100.102.1.6 send-community
neighbor 100.102.1.6 route-map set-RE-comm in
neighbor 100.102.1.10 send-community
neighbor 100.102.1.10 route-map set-RE-comm in
neighbor 100.100.1.5 send-community
neighbor 100.100.1.5 route-map set-RE-lpref in
address-family ipv6
neighbor 2001:12:0:10::1 send-community
neighbor 2001:12:0:10::1 route-map set-RE-comm
neighbor 2001:12:0:11::1 send-community
neighbor 2001:12:0:11::1 route-map set-RE-comm
neighbor 2001:12:0:12::1 send-community
neighbor 2001:12:0:12::1 route-map set-RE-comm
neighbor 2001:10:0:11:: send-community
neighbor 2001:10:0:11:: route-map set-RE-lpref
!
in
in
in
in
The regional REN (RREN) connects multiple NRENs, so they replace communities in the R&E routes
learned from NRENs with their own community:
RREN:
ip bgp-community new-format
!
ip community-list 1 permit 101:99
ip community-list 1 permit 102:99
!
route-map set-RE-comm permit 10
match community 1
set community 100:99
set local-preference 150
route-map set-RE-comm permit 20
!
Workshops - http://workshops.nsrc.org/dokuwiki/
Last update:
2016:preginet-bgp:3-lab-bgp-policy http://workshops.nsrc.org/dokuwiki/doku.php?id=2016:preginet-bgp:3-lab-bgp-policy
2016/01/17 03:37
2016/01/17 04:05
11/22
Last update:
2016:preginet-bgp:3-lab-bgp-policy http://workshops.nsrc.org/dokuwiki/doku.php?id=2016:preginet-bgp:3-lab-bgp-policy
2016/01/17 03:37
null0
null0
null0
null0
ISP2:
ip prefix-list v4-commodity-1 permit 172.20.0.0/16
ip prefix-list v4-commodity-2 permit 172.21.0.0/16
ip prefix-list v4-commodity-3 permit 172.22.0.0/16
ip prefix-list v4-commodity-4 permit 172.23.0.0/16
!
ipv6 prefix-list v6-commodity-1 permit 2001:dbc::/32
ipv6 prefix-list v6-commodity-2 permit 2001:dbd::/32
ipv6 prefix-list v6-commodity-3 permit 2001:dbe::/32
ipv6 prefix-list v6-commodity-4 permit 2001:dbf::/32
!
route-map set-prepend-commodity permit 10
match ip address prefix-list v4-commodity-1
set as-path prepend 65005
route-map set-prepend-commodity permit 20
match ip address prefix-list v4-commodity-2
set as-path prepend 65006
route-map set-prepend-commodity permit 30
match ip address prefix-list v4-commodity-3
set as-path prepend 65007
route-map set-prepend-commodity permit 40
match ip address prefix-list v4-commodity-4
set as-path prepend 65008
route-map set-prepend-commodity permit 50
!
route-map set-prepend-v6commodity permit 10
match ipv6 address prefix-list v6-commodity-1
set as-path prepend 65005
route-map set-prepend-v6commodity permit 20
match ipv6 address prefix-list v6-commodity-2
set as-path prepend 65006
route-map set-prepend-v6commodity permit 30
match ipv6 address prefix-list v6-commodity-3
set as-path prepend 65007
http://workshops.nsrc.org/dokuwiki/
2016/01/17 04:05
13/22
Last update:
2016:preginet-bgp:3-lab-bgp-policy http://workshops.nsrc.org/dokuwiki/doku.php?id=2016:preginet-bgp:3-lab-bgp-policy
2016/01/17 03:37
Set local preference ONLY on the R&E routes (marked with the R&E community) learned from the
NREN. Notice that your NREN is also passing you the communities set by the regional REN, so you
need to match either one.
Also notice that we (should) still have the route-map which sets the local preference to 200 on the
prexes originated by our bi-lateral peers.
On B11:
ip bgp-community new-format
!
ip community-list 1 permit 100:99
ip community-list 1 permit 101:99
!
route-map set-lpref-nren permit 10
description Look for RE routes
match community 1
set local-preference 150
route-map set-lpref-nren permit 20
description The rest are Commodity routes
set local-preference 70
!
router bgp 10
address-family ipv4
neighbor 100.101.1.1 route-map set-lpref-nren in
address-family ipv6
neighbor 2001:11:0:10:: route-map set-lpref-nren in
!
Refresh to/from your neighbours:
clear ip bgp external in
clear bgp ipv6 unicast external in
Verify that communities are being set and transmitted by the NREN - for example on B11:
B11# show ip bgp 100.68.20.0
B11# show ip bgp 100.68.40.0
Also, look at all the prexes which have community set in them. This is a good way of checking that
everything is working properly.
show ip bgp community
show bgp ipv6 unicast community
Do you see all the R&E routes now?
Question: Why do some have the best path and others do not?
Now we set all the prexes transited by the ISP to us to local preference 80, as per the earlier table.
Here is an example conguration:
http://workshops.nsrc.org/dokuwiki/
2016/01/17 04:05
15/22
On B12:
ip as-path access-list 1 permit ^[0-9]+$
!
route-map set-lpref-isp permit 10
description Look for ISP originated routes
match as-path 1
!
route-map set-lpref-isp permit 20
description All ISP routes
set local-preference 80
!
router bgp 10
address-family ipv4
neighbor 100.121.1.1 route-map set-lpref-isp in
address-family ipv6
neighbor 2001:18:0:10:: route-map set-lpref-isp in
!
Refresh to/from your neighbours:
clear ip bgp external in
clear bgp ipv6 unicast external in
Check your BGP routes again.
show
show
show
show
ip bgp
ip route
bgp ipv6 unicast
ipv6 route
The result should be that you now prefer the NREN path for any prex originated by an R&E member.
For all other prexes, including the ones from the commercial Internet, your routers will choose based
on BGP defaults.
Last update:
2016:preginet-bgp:3-lab-bgp-policy http://workshops.nsrc.org/dokuwiki/doku.php?id=2016:preginet-bgp:3-lab-bgp-policy
2016/01/17 03:37
trac will leave through the NREN. Similarly, if the NREN link fails, the ISP will route all our outbound
trac.
This has the advantage of reducing our routing table size, and therefore convergence time. The
disadvantage is that we may not always follow the best paths, but it might be a good compromise.
We are going to ask the NREN to only send us R&E routes, plus the default route:
NREN1:
ip community-list 1 permit 100:99
ip community-list 1 permit 101:99
!
route-map send-RE-only permit 10
match community 1
!
router bgp 101
address-family ipv4
neighbor 100.101.1.2 route-map send-RE-only out
neighbor 100.101.1.2 default-originate
neighbor 100.101.1.6 route-map send-RE-only out
neighbor 100.101.1.6 default-originate
neighbor 100.101.1.10 route-map send-RE-only out
neighbor 100.101.1.10 default-originate
address-family ipv6
neighbor 2001:11:0:10::1 route-map send-RE-only out
neighbor 2001:11:0:10::1 default-originate
neighbor 2001:11:0:11::1 route-map send-RE-only out
neighbor 2001:11:0:11::1 default-originate
neighbor 2001:11:0:12::1 route-map send-RE-only out
neighbor 2001:11:0:12::1 default-originate
!
NREN2:
ip community-list 1 permit 100:99
ip community-list 1 permit 102:99
!
route-map send-RE-only permit 10
match community 1
!
router bgp 102
address-family ipv4
neighbor 100.102.1.2 route-map send-RE-only out
neighbor 100.102.1.2 default-originate
neighbor 100.102.1.6 route-map send-RE-only out
neighbor 100.102.1.6 default-originate
neighbor 100.102.1.10 route-map send-RE-only out
neighbor 100.102.1.10 default-originate
address-family ipv6
neighbor 2001:12:0:10::1 route-map send-RE-only out
http://workshops.nsrc.org/dokuwiki/
2016/01/17 04:05
neighbor
neighbor
neighbor
neighbor
neighbor
17/22
2001:12:0:10::1
2001:12:0:11::1
2001:12:0:11::1
2001:12:0:12::1
2001:12:0:12::1
default-originate
route-map send-RE-only out
default-originate
route-map send-RE-only out
default-originate
!
Similarly, we will ask the ISP to only send us a default route:
ISP1:
ip prefix-list default permit 0.0.0.0/0
ipv6 prefix-list ipv6-default permit ::/0
!
router bgp 121
address-family ipv4
neighbor 100.121.1.2 default-originate
neighbor 100.121.1.2 prefix-list default out
neighbor 100.121.1.6 default-originate
neighbor 100.121.1.6 prefix-list default out
neighbor 100.121.1.10 default-originate
neighbor 100.121.1.10 prefix-list default out
address-family ipv6
neighbor 2001:18:0:10::1 default-originate
neighbor 2001:18:0:10::1 prefix-list ipv6-default out
neighbor 2001:18:0:11::1 default-originate
neighbor 2001:18:0:11::1 prefix-list ipv6-default out
neighbor 2001:18:0:12::1 default-originate
neighbor 2001:18:0:12::1 prefix-list ipv6-default out
!
ISP2:
ip prefix-list default permit 0.0.0.0/0
ipv6 prefix-list ipv6-default permit ::/0
!
router bgp 122
address-family ipv4
neighbor 100.122.1.2 default-originate
neighbor 100.122.1.2 prefix-list default out
neighbor 100.122.1.6 default-originate
neighbor 100.122.1.6 prefix-list default out
neighbor 100.122.1.10 default-originate
neighbor 100.122.1.10 prefix-list default out
address-family ipv6
neighbor 2001:19:0:10::1 default-originate
neighbor 2001:19:0:10::1 prefix-list ipv6-default out
neighbor 2001:19:0:11::1 default-originate
neighbor 2001:19:0:11::1 prefix-list ipv6-default out
neighbor 2001:19:0:12::1 default-originate
neighbor 2001:19:0:12::1 prefix-list ipv6-default out
Workshops - http://workshops.nsrc.org/dokuwiki/
Last update:
2016:preginet-bgp:3-lab-bgp-policy http://workshops.nsrc.org/dokuwiki/doku.php?id=2016:preginet-bgp:3-lab-bgp-policy
2016/01/17 03:37
!
Check what you are now receiving from your NREN and your ISP:
B11#
B11#
B11#
B11#
show
show
show
show
B12#
B12#
B12#
B12#
show
show
show
show
At this point you should see that each of your routers has a default route pointing to its upstream
peer.
Check your default route on both routers:
show ip bgp 0.0.0.0 0.0.0.0
show ip route 0.0.0.0 0.0.0.0
show bgp ipv6 uni ::/0
show ipv6 route ::/0
Also, check your BGP routing table. Has it shrunk?
show ip bgp
show bgp ipv6 unicast
Conrm that you now see a default route from your ISP, with local-preference 100. And you should
also see a default-route from your NREN, with local-preference 70 (based on the communities set in
the previous exercise).
Summary
What have we achieved here? We have connected our end-site to a local peer, an NREN and an ISP.
The best path for for our local (bi-lateral) peer is over our peering link. The best path for all REN
routes is via the NREN. The best path for all other routes is via the ISP.
Should the link to the ISP fail, we will get backup via the NREN to access the commodity
networks.
Should the link to the NREN fail, we will get backup via the ISP to access R&E networks.
How did we achieve this?
We tagged all routes from our bi-lateral peer with local-preference of 200.
We looked for REN routes from our NREN tagged with the REN community and set localpreference of 150.
http://workshops.nsrc.org/dokuwiki/
2016/01/17 04:05
19/22
We heard the default route from our NREN, and tagged it with low local-preference of 70.
We heard the default route from our ISP, and left it with default local-preference of 100.
Discuss with the lab instructors about testing the failure modes of your group's network connectivity.
Next Hop
100.68.60.1
100.68.60.1
150
100.68.60.1
150
100.68.60.2
100.68.60.1
100.68.60.2
100.68.60.1
0.0.0.0
100.68.60.1
100.68.60.1
100.68.60.1
100.68.60.1
100.68.60.2
0
0
0
0
0
0
0
0
0
0
200
200
100
100
150
150
200
150
200
0
0
0
0
32768
0
0
0
0
0
40 i
50 i
i
i
i
102 100 i
102 100 101 i
102 i
102 100 121 i
122 i
Last update:
2016:preginet-bgp:3-lab-bgp-policy http://workshops.nsrc.org/dokuwiki/doku.php?id=2016:preginet-bgp:3-lab-bgp-policy
2016/01/17 03:37
*
10 i
*
*>
*
*>
*
*>
*
*>
*>
*>
*
*
*>
*
*
*>
*
*
*>
*>
*
*
*>
Network
100.68.10.0/24
100.68.20.0/24
100.68.30.0/24
100.68.40.0/24
100.68.50.0/24
100.68.60.0/24
100.100.0.0/16
100.101.0.0/16
100.102.0.0/16
100.121.0.0/16
100.122.0.0/16
Next Hop
100.127.1.2
100.127.1.3
100.101.2.1
100.121.1.2
100.101.2.1
100.121.1.6
100.101.2.1
100.121.1.10
100.127.1.2
100.127.1.2
100.127.1.2
100.101.2.1
100.127.1.2
100.127.1.3
100.127.1.2
100.127.1.3
100.101.2.1
100.101.2.1
100.127.1.3
100.127.1.2
0.0.0.0
100.101.2.1
100.127.1.3
100.127.1.2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
32768
0
0
0
100 101 10 i
101 10 i
10 10 10 i
101 20 i
20 20 20 i
101 30 i
30 30 30 i
122 102 40 i
122 102 50 i
122 102 60 i
101 100 i
122 100 i
100 i
122 100 101 i
100 101 i
101 i
101 100 102 i
100 102 i
122 102 i
i
101 100 122 i
100 122 i
122 i
2016/01/17 04:05
21/22
*>i
* i
* i
*>
*>i
*>i
40 i
*>i
50 i
*>i
60 i
*>i
*>i
*>i
*>i
*>i
*>i
*>i
*>i
*>i
*>i
i
*>i
i
*>i
i
*>i
i
Network
100.68.10.0/24
100.68.20.0/24
100.68.30.0/24
100.68.40.0/24
Next Hop
100.68.20.1
100.68.20.2
100.68.20.1
0.0.0.0
100.68.20.2
100.68.20.1
100.68.50.0/24
100.68.20.1
150
100.68.60.0/24
100.68.20.1
150
100.100.0.0/16
100.101.0.0/16
100.102.0.0/16
100.121.0.0/16
100.122.0.0/16
172.16.0.0
172.17.0.0
172.18.0.0
172.19.0.0
172.20.0.0
100.68.20.1
100.68.20.1
100.68.20.1
100.68.20.2
100.68.20.2
100.68.20.2
100.68.20.2
100.68.20.2
100.68.20.2
100.68.20.2
0
0
0
0
0
0
0
0
0
0
150
150
150
100
80
80
80
80
80
80
0
0
0
0
0
0
0
0
0
0
172.21.0.0
100.68.20.2
80
172.22.0.0
100.68.20.2
80
172.23.0.0
100.68.20.2
80
101
101
101
121
121
121
121
121
121
121
100 i
i
100 102 i
i
122 i
65001 i
65002 i
65003 i
65004 i
122 65005
Next Hop
Workshops - http://workshops.nsrc.org/dokuwiki/
Last update:
2016:preginet-bgp:3-lab-bgp-policy http://workshops.nsrc.org/dokuwiki/doku.php?id=2016:preginet-bgp:3-lab-bgp-policy
2016/01/17 03:37
r>i
* i
* i
*>
*>i
*>i
*>i
40 i
*>i
50 i
*>i
60 i
*>i
*>i
*>i
0.0.0.0
100.68.10.0/24
0
0
0
0
0
0
0
100
100
100
100.68.20.0/24
100.68.30.0/24
100.68.40.0/24
100.68.10.2
100.68.10.1
100.68.10.2
0.0.0.0
100.68.10.2
100.68.10.1
100.68.10.1
100.68.50.0/24
100.68.10.1
150
100.68.60.0/24
100.68.10.1
150
100.100.0.0/16
100.101.0.0/16
100.102.0.0/16
100.68.10.1
100.68.10.1
100.68.10.1
0
0
0
150
150
150
0 101 100 i
0 101 i
0 101 100 102 i
200
200
150
0
0
0
32768
0
0
0
121 i
i
i
i
20 i
30 i
101 100 102
From:
http://workshops.nsrc.org/dokuwiki/ - Workshops
Permanent link:
http://workshops.nsrc.org/dokuwiki/doku.php?id=2016:preginet-bgp:3-lab-bgp-policy
Last update: 2016/01/17 03:37
http://workshops.nsrc.org/dokuwiki/