BGP AS Path Prepending: Lab Topology
BGP AS Path Prepending: Lab Topology
PNETLAB Store
PNETLab.com
Lab Objective:
The objective of this lab exercise is for you to learn and understand how to configure BGP AS Path
Prepending.
Task:
Above we have 3 routers. R2 and R3 are both in AS 2 advertising the same network (8.8.8.8/32)
to R1. We can use AS Path prepending to make R1 prefer a certain path.
Solution
1
Download PNETLab Platform
PNETLAB Store
PNETLab.com
Basic Configuration:
Router R1 R2
Configuration interface Loopback0 interface Loopback0
no shutdown no shutdown
ip address 1.1.1.1 255.255.255.255 ip address 8.8.8.8 255.255.255.255
! !
interface Ethernet0/0 interface Ethernet0/0
no shutdown no shutdown
ip address 10.1.12.1 255.255.255.0 ip address 10.1.12.2 255.255.255.0
! !
interface Ethernet0/1 router bgp 2
no shutdown network 8.8.8.8 mask 255.255.255.255
ip address 10.1.13.1 255.255.255.0 neighbor 10.1.12.1 remote-as 1
! !
router bgp 1
network 1.1.1.1 mask
255.255.255.255
neighbor 10.1.12.2 remote-as 2
neighbor 10.1.13.3 remote-as 2
!
Router R3
Configuration interface Loopback0
no shutdown
ip address 8.8.8.8 255.255.255.255
!
interface Ethernet0/0
no shutdown
ip address 10.1.13.3 255.255.255.0
!
router bgp 2
network 8.8.8.8 mask
255.255.255.255
neighbor 10.1.13.1 remote-as 1
!
R1#show ip bgp
BGP table version is 3, local router ID is 1.1.1.1
2
Download PNETLab Platform
PNETLAB Store
PNETLab.com
In the table above you can see that it prefers 10.1.12.2 as its path. Because everything is the
same it boils down to the router ID. Let’s change the AS path so that we’ll use 10.1.13.3 as the
preferred path.
First create a route-map and use set as-path prepend to add your own AS number multiple
times. Don’t forget to add the route-map to your BGP neighbor configuration and since you are
sending this to your remote neighbor it should be outbound!
R1#show ip bgp
BGP table version is 4, local router ID is 1.1.1.1
Now we see that 10.1.13.3 is the next hop IP address that we use. You can also see that the AS Path
has become longer for the second entry.