AS the BGP Local_Pref become popular with the IT industry. SPOTO will introduce it to the people who are interested in it. SPOTO is a leading IT training in the world and has made an excellent breakthrough in CCIE Data Center Lab and CCIE RS Lab certification. Now, you will know some details about the BGP Local_Pref.
The Local Preference Path (Local_Pref) path attribute of the Border Gateway Protocol gives the router the value of an autonomous system that can be set per-route and promotes the autonomous system inside the iBGP router so that all routers in the autonomous system agree which routers are destined to be the best exit point prefix.
A Path with the highest preference value is preferable. By default, the Local_pref value is 100 and the range is 0 to 4,294,967,295. Local preferences are well known discretionary attributes. It only advertises iBGP neighbors in the autonomous system.
let us see the configuration:-
Topology:
Goal:
configure the topology as per the diagram.
configure iBGP and eBGP peering using directly connected interfaces.
advertise all the networks as per the topology.
configure router 1 exit point for an autonomous system of 65111.
make sure router 2 reach all the network via router 1.
R1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 10.1.1.1 YES manual up up
Serial3/0 1.1.1.1 YES manual up up
Serial3/3 4.1.1.2 YES manual up up
Loopback0 11.0.0.1 YES manual up up
Loopback1 11.0.1.1 YES manual up up
Loopback2 11.0.2.1 YES manual up up
Loopback3 11.0.3.1 YES manual up up
R2#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 20.1.1.1 YES manual up up
Serial3/0 1.1.1.2 YES manual up up
Serial3/1 2.1.1.1 YES manual up up
Loopback0 12.0.0.1 YES manual up up
Loopback1 12.0.1.1 YES manual up up
Loopback2 12.0.2.1 YES manual up up
Loopback3 12.0.3.1 YES manual up up
R3#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 30.1.1.1 YES manual up up
Serial3/1 2.1.1.2 YES manual up up
Serial3/2 3.1.1.1 YES manual up up
Loopback0 13.0.0.1 YES manual up up
Loopback1 13.0.1.1 YES manual up up
Loopback2 13.0.2.1 YES manual up up
Loopback3 13.0.3.1 YES manual up up
R4#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 40.1.1.1 YES manual up up
Serial3/2 3.1.1.2 YES manual up up
Serial3/3 4.1.1.1 YES manual up up
Loopback0 14.0.0.1 YES manual up up
Loopback1 14.0.1.1 YES manual up up
Loopback2 14.0.2.1 YES manual up up
Loopback3 14.0.3.1 YES manual up up
R1(config)#router bgp 65111
R1(config-router)#neighbor 1.1.1.2 remote-as 65111
R1(config-router)#neighbor 4.1.1.1 remote-as 65444
R1(config-router)#neighbor 1.1.1.2 next-hop-self
R1(config-router)#network 10.0.0.0
R1(config-router)#network 1.0.0.0
R1(config-router)#network 4.0.0.0
R1(config-router)#network 11.0.0.0 mask 255.255.255.0
R1(config-router)#no auto-summary
R1(config-router)#no synchronization
R2(config)#router bgp 65111
R2(config-router)#neighbor 1.1.1.1 remote-as 65111
R2(config-router)#neighbor 2.1.1.2 remote-as 65333
R2(config-router)#neighbor 1.1.1.1 next-hop-self
R2(config-router)#network 20.0.0.
R2(config-router)#network 20.0.0.0
R2(config-router)#network 2.0.0.0
R2(config-router)#network 1.0.0.0
R2(config-router)#network 12.0.0.0 mask 255.255.255.0
R2(config-router)#no auto-summary
R2(config-router)#no synchronization
R3(config)#router bgp 65333
R3(config-router)#neighbor 2.1.1.1 remote-as 65111
R3(config-router)#neighbor 3.1.1.2 remote-as 65444
R3(config-router)#network 30.0.0.0
R3(config-router)#network 3.0.0.0
R3(config-router)#network 2.0.0.0
R3(config-router)#network 13.0.0.0 mask 255.255.255.0
R3(config-router)#no synchronization
R3(config-router)#no auto-summary
R4(config)#router bgp 65444
R4(config-router)#neighbor 3.1.1.1 remote-as 65333
R4(config-router)#neighbor 4.1.1.2 remote-as 65111
R4(config-router)#network 40.0.0.0
R4(config-router)#network 4.0.0.0
R4(config-router)#network 14.0.0.0 mask 255.255.255.0
R4(config-router)#network 3.0.0.0
R4(config-router)#no synchronization
R4(config-router)#no auto-summary
R1#show ip bgp
BGP table version is 14, local router ID is 11.0.3.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* i 1.0.0.0 1.1.1.2 0 100 0 i
*> 0.0.0.0 0 32768 i
*>i 2.0.0.0 1.1.1.2 0 100 0 i
*> 3.0.0.0 4.1.1.1 0 0 65444 i
* i 1.1.1.2 0 100 0 65333 i
* 4.0.0.0 4.1.1.1 0 0 65444 i
*> 0.0.0.0 0 32768 i
*> 10.0.0.0 0.0.0.0 0 32768 i
*> 11.0.0.0/24 0.0.0.0 0 32768 i
*>i 12.0.0.0/24 1.1.1.2 0 100 0 i
* 13.0.0.0/24 4.1.1.1 0 65444 65333 i
*>i 1.1.1.2 0 100 0 65333 i
*> 14.0.0.0/24 4.1.1.1 0 0 65444 i
*>i 20.0.0.0 1.1.1.2 0 100 0 i
* 30.0.0.0 4.1.1.1 0 65444 65333 i
Network Next Hop Metric LocPrf Weight Path
*>i 1.1.1.2 0 100 0 65333 i
*> 40.0.0.0 4.1.1.1 0 0 65444 i
R2#show ip bgp
BGP table version is 14, local router ID is 12.0.3.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.0.0.0 0.0.0.0 0 32768 i
* i 1.1.1.1 0 100 0 i
* 2.0.0.0 2.1.1.2 0 0 65333 i
*> 0.0.0.0 0 32768 i
* i 3.0.0.0 1.1.1.1 0 100 0 65444 i
*> 2.1.1.2 0 0 65333 i
*>i 4.0.0.0 1.1.1.1 0 100 0 i
*>i 10.0.0.0 1.1.1.1 0 100 0 i
*>i 11.0.0.0/24 1.1.1.1 0 100 0 i
*> 12.0.0.0/24 0.0.0.0 0 32768 i
*> 13.0.0.0/24 2.1.1.2 0 0 65333 i
* 14.0.0.0/24 2.1.1.2 0 65333 65444 i
*>i 1.1.1.1 0 100 0 65444 i
*> 20.0.0.0 0.0.0.0 0 32768 i
Network Next Hop Metric LocPrf Weight Path
*> 30.0.0.0 2.1.1.2 0 0 65333 i
* 40.0.0.0 2.1.1.2 0 65333 65444 i
*>i 1.1.1.1 0 100 0 65444 i
R1#show ip route bgp
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
+ - replicated route, % - next hop override
Gateway of last resort is not set
B 2.0.0.0/8 [200/0] via 1.1.1.2, 00:36:56
B 3.0.0.0/8 [20/0] via 4.1.1.1, 00:32:47
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.0.0 [200/0] via 1.1.1.2, 00:36:43
13.0.0.0/24 is subnetted, 1 subnets
B 13.0.0.0 [200/0] via 1.1.1.2, 00:34:45
14.0.0.0/24 is subnetted, 1 subnets
B 14.0.0.0 [20/0] via 4.1.1.1, 00:33:18
B 20.0.0.0/8 [200/0] via 1.1.1.2, 00:36:56
B 30.0.0.0/8 [200/0] via 1.1.1.2, 00:35:16
B 40.0.0.0/8 [20/0] via 4.1.1.1, 00:33:48
R1#traceroute 13.0.0.1
Type escape sequence to abort.
Tracing the route to 13.0.0.1
VRF info: (vrf in name/id, vrf out name/id)
1 1.1.1.2 32 msec 36 msec 8 msec
2 2.1.1.2 36 msec 64 msec 64 msec
R1#traceroute 30.1.1.1
Type escape sequence to abort.
Tracing the route to 30.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 1.1.1.2 12 msec 60 msec 24 msec
2 2.1.1.2 44 msec 52 msec 60 msec
R2#traceroute 13.0.0.1
Type escape sequence to abort.
Tracing the route to 13.0.0.1
VRF info: (vrf in name/id, vrf out name/id)
1 2.1.1.2 288 msec 60 msec 28 msec
R2#traceroute 30.1.1.1
Type escape sequence to abort.
Tracing the route to 30.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 2.1.1.2 76 msec 72 msec 60 msec
(To reach 30.1.1.1, 13.0.0.1 network router 1 and router 2 using 2.1.1.2 path because it has fewer numbers of an autonomous system. but as per our requirement, we need router use 4.1.1.1 interface to reach all the networks, to manipulate the path we use local_pref)
R1(config)#router bgp 65111
R1(config-router)#bgp default local-preference 5000
R1(config-router)#end
R1#clear ip BGP * soft
R1#traceroute 30.1.1.1
Type escape sequence to abort.
Tracing the route to 30.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 4.1.1.1 8 msec 52 msec 28 msec
2 3.1.1.1 [AS 65444] 80 msec 40 msec 64 msec
R1#traceroute 13.0.0.1
Type escape sequence to abort.
Tracing the route to 13.0.0.1
VRF info: (vrf in name/id, vrf out name/id)
1 4.1.1.1 24 msec 60 msec 68 msec
2 3.1.1.1 [AS 65444] 112 msec 72 msec 52 msec
R2#traceroute 30.1.1.1
Type escape sequence to abort.
Tracing the route to 30.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 1.1.1.1 4 msec 44 msec 28 msec
2 4.1.1.1 36 msec 60 msec 8 msec
3 3.1.1.1 [AS 65444] 60 msec 52 msec 44 msec
R2#traceroute 13.0.0.1
Type escape sequence to abort.
Tracing the route to 13.0.0.1
VRF info: (vrf in name/id, vrf out name/id)
1 1.1.1.1 8 msec 28 msec 36 msec
2 4.1.1.1 64 msec 116 msec 64 msec
3 3.1.1.1 [AS 65444] 72 msec 72 msec 52 msec
R1#show ip bgp
BGP table version is 21, local router ID is 11.0.3.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* i 1.0.0.0 1.1.1.2 0 100 0 i
*> 0.0.0.0 0 32768 i
*>i 2.0.0.0 1.1.1.2 0 100 0 i
*> 3.0.0.0 4.1.1.1 0 0 65444 i
* 4.0.0.0 4.1.1.1 0 0 65444 i
*> 0.0.0.0 0 32768 i
*> 10.0.0.0 0.0.0.0 0 32768 i
*> 11.0.0.0/24 0.0.0.0 0 32768 i
*>i 12.0.0.0/24 1.1.1.2 0 100 0 i
*> 13.0.0.0/24 4.1.1.1 0 65444 65333 i
*> 14.0.0.0/24 4.1.1.1 0 0 65444 i
*>i 20.0.0.0 1.1.1.2 0 100 0 i
*> 30.0.0.0 4.1.1.1 0 65444 65333 i
*> 40.0.0.0 4.1.1.1 0 0 65444 i
R2#show ip bgp
BGP table version is 22, local router ID is 12.0.3.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.0.0.0 0.0.0.0 0 32768 i
* i 1.1.1.1 0 5000 0 i
* 2.0.0.0 2.1.1.2 0 0 65333 i
*> 0.0.0.0 0 32768 i
*>i 3.0.0.0 1.1.1.1 0 5000 0 65444 i
* 2.1.1.2 0 0 65333 i
*>i 4.0.0.0 1.1.1.1 0 5000 0 i
*>i 10.0.0.0 1.1.1.1 0 5000 0 i
*>i 11.0.0.0/24 1.1.1.1 0 5000 0 i
*> 12.0.0.0/24 0.0.0.0 0 32768 i
*>i 13.0.0.0/24 1.1.1.1 0 5000 0 65444 65333 i
* 2.1.1.2 0 0 65333 i
* 14.0.0.0/24 2.1.1.2 0 65333 65444 i
*>i 1.1.1.1 0 5000 0 65444 i
Network Next Hop Metric LocPrf Weight Path
*> 20.0.0.0 0.0.0.0 0 32768 i
*>i 30.0.0.0 1.1.1.1 0 5000 0 65444 65333 i
* 2.1.1.2 0 0 65333 i
* 40.0.0.0 2.1.1.2 0 65333 65444 i
*>i 1.1.1.1 0 5000 0 65444 i
R2#show ip bgp 30.1.1.1
BGP routing table entry for 30.0.0.0/8, version 17
Paths: (2 available, best #1, table default)
Advertised to update-groups:
3
Refresh Epoch 2
65444 65333
1.1.1.1 from 1.1.1.1 (11.0.3.1)
Origin IGP, metric 0, localpref 5000, valid, internal, best
rx pathid: 0, tx pathid: 0x0
Refresh Epoch 1
65333
2.1.1.2 from 2.1.1.2 (13.0.3.1)
Origin IGP, metric 0, localpref 100, valid, external
rx pathid: 0, tx pathid: 0