PG1X

My Knowledge Base

User Tools

Site Tools


tech:network:cisco:bgp:bgp:local-pref:local-pref

BGP: LOCAL_PREF

Topology

Project name: ccna-bgp15-local-pref-topology

IP

  • R1
enable
configure terminal
!
hostname R1
no ip domain-lookup
line console 0
exec-timeout 0 0
logging synchronous
!
interface Loopback 1
ip address 1.1.1.1 255.255.255.255
no shutdown
exit
interface GigabitEthernet 0/0
ip address 100.1.6.1 255.255.255.0
no shutdown
exit
interface GigabitEthernet 0/1
ip address 100.1.3.1 255.255.255.0
no shutdown
exit
!
end
write
  • R2
enable
configure terminal
!
hostname R2
no ip domain-lookup
line console 0
exec-timeout 0 0
logging synchronous
!
interface Loopback 1
ip address 2.2.2.2 255.255.255.255
no shutdown
exit
interface GigabitEthernet 0/0
ip address 100.2.4.2 255.255.255.0
no shutdown
exit
interface GigabitEthernet 0/1
ip address 100.2.6.2 255.255.255.0
no shutdown
exit
!
end
write
  • R3
enable
configure terminal
!
hostname R3
no ip domain-lookup
line console 0
exec-timeout 0 0
logging synchronous
!
interface Loopback 1
ip address 3.3.3.3 255.255.255.255
no shutdown
exit
interface GigabitEthernet 0/0
ip address 100.1.3.3 255.255.255.0
no shutdown
exit
interface GigabitEthernet 0/1
ip address 10.3.5.3 255.255.255.0
no shutdown
exit
interface GigabitEthernet 0/2
ip address 10.3.4.3 255.255.255.0
no shutdown
exit
!
end
write
  • R4
enable
configure terminal
!
hostname R4
no ip domain-lookup
line console 0
exec-timeout 0 0
logging synchronous
!
interface Loopback 1
ip address 4.4.4.4 255.255.255.255
no shutdown
exit
interface GigabitEthernet 0/0
ip address 10.4.5.4 255.255.255.0
no shutdown
exit
interface GigabitEthernet 0/1
ip address 100.2.4.4 255.255.255.0
no shutdown
exit
interface GigabitEthernet 0/2
ip address 10.3.4.4 255.255.255.0
no shutdown
exit
!
end
write
  • R5
enable
configure terminal
!
hostname R5
no ip domain-lookup
line console 0
exec-timeout 0 0
logging synchronous
!
interface Loopback 1
ip address 5.5.5.5 255.255.255.255
no shutdown
exit
interface Loopback 2
ip address 30.0.0.5 255.255.0.0
no shutdown
exit
interface GigabitEthernet 0/0
ip address 10.3.5.5 255.255.255.0
no shutdown
exit
interface GigabitEthernet 0/1
ip address 10.4.5.5 255.255.255.0
no shutdown
exit
!
end
write
  • R6
enable
configure terminal
!
hostname R6
no ip domain-lookup
line console 0
exec-timeout 0 0
logging synchronous
!
interface Loopback 1
ip address 6.6.6.6 255.255.255.255
no shutdown
exit
interface Loopback 2
ip address 50.0.0.6 255.255.0.0
no shutdown
exit
interface GigabitEthernet 0/0
ip address 100.2.6.6 255.255.255.0
no shutdown
exit
interface GigabitEthernet 0/1
ip address 100.1.6.6 255.255.255.0
no shutdown
exit
!
end
write

Static Routing

Project name: ccna-bgp15-local-pref-static

  • R1
configure terminal
!
ip route 3.3.3.3 255.255.255.255 100.1.3.3
ip route 6.6.6.6 255.255.255.255 100.1.6.6
!
end
  • R2
configure terminal
!
ip route 4.4.4.4 255.255.255.255 100.2.4.4
ip route 6.6.6.6 255.255.255.255 100.2.6.6
!
end
  • R3
configure terminal
!
ip route 1.1.1.1 255.255.255.255 100.1.3.1
ip route 4.4.4.4 255.255.255.255 10.3.4.4
ip route 5.5.5.5 255.255.255.255 10.3.5.5
!
end
  • R4
configure terminal
!
ip route 2.2.2.2 255.255.255.255 100.2.4.2
ip route 3.3.3.3 255.255.255.255 10.3.4.3
ip route 5.5.5.5 255.255.255.255 10.4.5.5
!
end
  • R5
configure terminal
!
ip route 3.3.3.3 255.255.255.255 10.3.5.3
ip route 4.4.4.4 255.255.255.255 10.4.5.4
!
end
  • R6
configure terminal
!
ip route 1.1.1.1 255.255.255.255 100.1.6.1
ip route 2.2.2.2 255.255.255.255 100.2.6.2
!
end

Verification

  • R1
ping 3.3.3.3 source 1.1.1.1
ping 6.6.6.6 source 1.1.1.1
  • R2
ping 4.4.4.4 source 2.2.2.2
ping 6.6.6.6 source 2.2.2.2
  • R3
ping 1.1.1.1 source 3.3.3.3
ping 4.4.4.4 source 3.3.3.3
ping 5.5.5.5 source 3.3.3.3
  • R4
ping 2.2.2.2 source 4.4.4.4
ping 3.3.3.3 source 4.4.4.4
ping 5.5.5.5 source 4.4.4.4
  • R5
ping 3.3.3.3 source 5.5.5.5
ping 4.4.4.4 source 5.5.5.5
  • R6
ping 1.1.1.1 source 6.6.6.6
ping 2.2.2.2 source 6.6.6.6

Base BGP Configuration

Project name: ccna-bgp15-local-pref

OSPF

  • R3
configure terminal
!
router ospf 1
network 10.3.5.3 0.0.0.0 area 0
network 10.3.4.3 0.0.0.0 area 0
exit
!
end
  • R4
configure terminal
!
router ospf 1
network 10.4.5.4 0.0.0.0 area 0
network 10.3.4.4 0.0.0.0 area 0
exit
!
end
  • R5
configure terminal
!
router ospf 1
network 10.3.5.5 0.0.0.0 area 0
network 10.4.5.5 0.0.0.0 area 0
exit
!
end

BGP

  • R1
configure terminal
!
router bgp 1
neighbor 3.3.3.3 remote-as 3
neighbor 3.3.3.3 update-source Lo1
neighbor 3.3.3.3 ebgp-multihop 2
neighbor 6.6.6.6 remote-as 50
neighbor 6.6.6.6 update-source Lo1
neighbor 6.6.6.6 ebgp-multihop 2
exit
!
end
  • R2
configure terminal
!
router bgp 2
neighbor 4.4.4.4 remote-as 3
neighbor 4.4.4.4 update-source Lo1
neighbor 4.4.4.4 ebgp-multihop 2
neighbor 6.6.6.6 remote-as 50
neighbor 6.6.6.6 update-source Lo1
neighbor 6.6.6.6 ebgp-multihop 2
exit
!
end
  • R3
configure terminal
!
router bgp 3
neighbor IBGP-POL1 peer-group
neighbor IBGP-POL1 remote-as 3
neighbor IBGP-POL1 update-source Lo1
neighbor IBGP-POL1 next-hop-self
neighbor 4.4.4.4 peer-group IBGP-POL1
neighbor 5.5.5.5 peer-group IBGP-POL1
neighbor 1.1.1.1 remote-as 1
neighbor 1.1.1.1 update-source Lo1
neighbor 1.1.1.1 ebgp-multihop 2
exit
!
end
  • R4
configure terminal
!
router bgp 3
neighbor IBGP-POL1 peer-group
neighbor IBGP-POL1 remote-as 3
neighbor IBGP-POL1 update-source Lo1
neighbor IBGP-POL1 next-hop-self
neighbor 3.3.3.3 peer-group IBGP-POL1
neighbor 5.5.5.5 peer-group IBGP-POL1
neighbor 2.2.2.2 remote-as 2
neighbor 2.2.2.2 update-source Lo1
neighbor 2.2.2.2 ebgp-multihop 2
exit
!
end
  • R5
configure terminal
!
router bgp 3
neighbor IBGP-POL1 peer-group
neighbor IBGP-POL1 remote-as 3
neighbor IBGP-POL1 update-source Lo1
neighbor IBGP-POL1 next-hop-self
neighbor 3.3.3.3 peer-group IBGP-POL1
neighbor 4.4.4.4 peer-group IBGP-POL1
network 30.0.0.0 mask 255.255.0.0
exit
!
end
  • R6
configure terminal
!
router bgp 50
neighbor 1.1.1.1 remote-as 1
neighbor 1.1.1.1 update-source Lo1
neighbor 1.1.1.1 ebgp-multihop 2
neighbor 2.2.2.2 remote-as 2
neighbor 2.2.2.2 update-source Lo1
neighbor 2.2.2.2 ebgp-multihop 2
network 50.0.0.0 mask 255.255.0.0
exit
!
end

Verification

  • R5
show ip bgp
show ip route bgp
ping 50.0.0.6 source 30.0.0.5
traceroute 50.0.0.6 source 30.0.0.5
R5#sh ip bgp
BGP table version is 3, local router ID is 30.0.0.5
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
 *>  30.0.0.0/16      0.0.0.0                  0         32768 i
 * i 50.0.0.0/16      4.4.4.4                  0    100      0 2 50 i
 *>i                  3.3.3.3                  0    100      0 1 50 i
R5#sh ip ro 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
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      50.0.0.0/16 is subnetted, 1 subnets
B        50.0.0.0 [200/0] via 3.3.3.3, 03:26:42
R5#ping 50.0.0.6 source 30.0.0.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 50.0.0.6, timeout is 2 seconds:
Packet sent with a source address of 30.0.0.5 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/10/13 ms
R5#traceroute 50.0.0.6 source 30.0.0.5
Type escape sequence to abort.
Tracing the route to 50.0.0.6
VRF info: (vrf in name/id, vrf out name/id)
  1 10.3.5.3 4 msec 9 msec 5 msec
  2 100.1.3.1 6 msec 10 msec 7 msec
  3 100.1.6.6 9 msec 8 msec 8 msec
R5#sh ip bgp
BGP table version is 5, local router ID is 30.0.0.5
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
 *>  30.0.0.0/16      0.0.0.0                  0         32768 i
 *>i 50.0.0.0/16      4.4.4.4                  0    200      0 2 50 i
R5#traceroute 50.0.0.6 source 30.0.0.5
Type escape sequence to abort.
Tracing the route to 50.0.0.6
VRF info: (vrf in name/id, vrf out name/id)
  1 10.4.5.4 6 msec 6 msec 9 msec
  2 100.2.4.2 7 msec 8 msec 5 msec
  3 100.2.6.6 6 msec 8 msec 6 msec
R5#traceroute 50.0.0.6 source 30.0.0.5
Type escape sequence to abort.
Tracing the route to 50.0.0.6
VRF info: (vrf in name/id, vrf out name/id)
  1 10.4.5.4 8 msec 3 msec 3 msec
  2 100.2.4.2 6 msec 6 msec 7 msec
  3 100.2.6.6 7 msec 7 msec 7 msec
R5#ping 50.0.0.6 source 30.0.0.5      
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 50.0.0.6, timeout is 2 seconds:
Packet sent with a source address of 30.0.0.5 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 5/7/12 ms
R5#sh ip ro 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
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      50.0.0.0/16 is subnetted, 1 subnets
B        50.0.0.0 [200/0] via 4.4.4.4, 00:01:50

bgp default local-preference

  • R3
configure terminal
!
router bgp 3
bgp default local-preference 150
exit
!
end
  • R4
configure terminal
!
router bgp 3
bgp default local-preference 200
exit
!
end

Verification

  • R5
show ip bgp
show ip route bgp
ping 50.0.0.6 source 30.0.0.5
traceroute 50.0.0.6 source 30.0.0.5

as-path access-list

  • R3
configure terminal
!
ip as-path access-list 1 permit ^1_
!
route-map R-LP permit 10
match as-path 1
set local-preference 300
exit
route-map R-LP permit 20
exit
!
router bgp 3
neighbor 1.1.1.1 route-map R-LP in
exit
!
end
  • R4
configure terminal
!
ip as-path access-list 1 permit ^2_
!
route-map R-LP permit 10
match as-path 1
set local-preference 400
exit
route-map R-LP permit 20
exit

!
router bgp 3
neighbor 2.2.2.2 route-map R-LP in
exit
!
end
  • R{3,4}
clear ip bgp *

Verification

  • R{3,4}
show ip bgp
  • R5
show ip bgp
show ip route bgp
ping 50.0.0.6 source 30.0.0.5
traceroute 50.0.0.6 source 30.0.0.5

access-list

not AS_PATH ACL.

  • R3
configure terminal
!
access-list 1 permit 50.0.0.0 0.0.255.255
!
route-map R-LP permit 10
match ip address 1
set local-preference 500
exit
route-map R-LP permit 20
exit
!
router bgp 3
neighbor 1.1.1.1 route-map R-LP in
exit
!
end
  • R4
configure terminal
!
access-list 1 permit 50.0.0.0 0.0.255.255
!
route-map R-LP permit 10
match ip address 1
set local-preference 600
exit
route-map R-LP permit 20
exit

!
router bgp 3
neighbor 2.2.2.2 route-map R-LP in
exit
!
end
  • R{3,4}
clear ip bgp *

Verification

  • R{3,4}
show ip bgp
  • R5
show ip bgp
show ip route bgp
ping 50.0.0.6 source 30.0.0.5
traceroute 50.0.0.6 source 30.0.0.5

References

tech/network/cisco/bgp/bgp/local-pref/local-pref.txt · Last modified: 2019/01/06 18:54 by wnoguchi