Let’s keep going and try to configure BGP local preference attribute using route-policy.
We can take full advantage of topology and configuration from the last post: “BGP default local preference in Huawei CLI“.
- Assure full connectivity based on the attached topology (look at the previous article).
- Configure Loopback 10 and Loopback 20 on router AR4.
- Import all Loopback interfaces of router AR4 to BGP.
After we configure locpref attributes:
- Traffic directed to network 111.111.111.111/32 is leaving AS100 through AR2 router.
- Traffic directed to network 222.222.222.222/32 is leaving AS100 through AR3 router.
- Keep local preference 100 for all other traffic.
Let’s come to the point.
Configure Loopbacks interfaces on AR4 router:
[AR4]dis current-configuration interface loopback # interface LoopBack0 ip address 4.4.4.4 255.255.255.255 # interface LoopBack10 ip address 111.111.111.111 255.255.255.255 # interface LoopBack20 ip address 222.222.222.222 255.255.255.255 #
Import configured networks into BGP:
[AR4]bgp 200 [AR4-bgp]import-route direct
Check IP and BGP routing tables of AR1 router:
[AR1]dis ip rout Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 20 Routes : 21 Destination/Mask Proto Pre Cost Flags NextHop Interface 1.1.1.1/32 Direct 0 0 D 127.0.0.1 LoopBack0 2.2.2.2/32 OSPF 10 1 D 10.1.1.2 GigabitEthernet0/0/0 3.3.3.3/32 OSPF 10 1 D 10.1.2.2 GigabitEthernet0/0/1 4.4.4.4/32 IBGP 255 0 RD 150.1.1.2 GigabitEthernet0/0/0 10.1.1.0/30 Direct 0 0 D 10.1.1.1 GigabitEthernet0/0/0 10.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0 10.1.1.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0 10.1.2.0/30 Direct 0 0 D 10.1.2.1 GigabitEthernet0/0/1 10.1.2.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/1 10.1.2.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/1 10.1.3.0/30 OSPF 10 2 D 10.1.2.2 GigabitEthernet0/0/1 OSPF 10 2 D 10.1.1.2 GigabitEthernet0/0/0 100.100.100.100/32 Direct 0 0 D 127.0.0.1 LoopBack100 111.111.111.111/32 IBGP 255 0 RD 150.1.1.2 GigabitEthernet0/0/0 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 150.1.1.0/30 OSPF 10 2 D 10.1.1.2 GigabitEthernet0/0/0 150.2.2.0/30 OSPF 10 2 D 10.1.2.2 GigabitEthernet0/0/1 222.222.222.222/32 IBGP 255 0 RD 150.1.1.2 GigabitEthernet0/0/0 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 [AR1]dis bgp routing-table BGP Local router ID is 1.1.1.1 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 9 Network NextHop MED LocPrf PrefVal Path/Ogn *>i 4.4.4.4/32 150.1.1.2 0 100 0 200? * i 150.2.2.2 0 100 0 200? *> 100.100.100.100/32 0.0.0.0 0 0 i *>i 111.111.111.111/32 150.1.1.2 0 100 0 200? * i 150.2.2.2 0 100 0 200? *>i 150.1.1.0/30 2.2.2.2 0 100 0 i *>i 150.2.2.0/30 3.3.3.3 0 100 0 i *>i 222.222.222.222/32 150.1.1.2 0 100 0 200? * i 150.2.2.2 0 100 0 200?
As you can see all traffic is leaving AS100 through AR2 router.
Configure 3 ACLs on AR2 and AR3 routers:
- The first one permits source IP of Loopback 10 of router AR4.
- The second one permits source IP of Loopback 20 of router AR4.
- The third one permits all other networks.
[AR2]acl number 2000 [AR2-acl-basic-2000] rule 5 permit source 111.111.111.111 0 [AR2]acl number 2500 [AR2-acl-basic-2500] rule 5 permit source 222.222.222.222 0 [AR2]acl number 2600 [AR2-acl-basic-2600] rule 5 permit [AR2-acl-basic-2600] [AR3]acl number 2000 [AR3-acl-basic-2000] rule 5 permit source 111.111.111.111 0 [AR3]acl number 2500 [AR3-acl-basic-2500] rule 5 permit source 222.222.222.222 0 [AR3]acl number 2600 [AR3-acl-basic-2600] rule 5 permit
Configure route-policy, named locpref, on AR2 and AR3 routers:
[AR2]route-policy locpref permit node 10 [AR2-route-policy] if-match acl 2000 [AR2-route-policy] apply local-preference 300 [AR2-route-policy]qu [AR2]route-policy locpref permit node 20 [AR2-route-policy] if-match acl 2500 [AR2-route-policy] apply local-preference 200 [AR2-route-policy]qu [AR2]route-policy locpref permit node 30 [AR2-route-policy] if-match acl 2600 [AR2-route-policy] apply local-preference 100 [AR2-route-policy] [AR3]route-policy locpref permit node 10 [AR3-route-policy] if-match acl 2000 [AR3-route-policy] apply local-preference 200 [AR3-route-policy]qu [AR3]route-policy locpref permit node 20 [AR3-route-policy] if-match acl 2500 [AR3-route-policy] apply local-preference 300 [AR3-route-policy]qu [AR3]route-policy locpref permit node 30 [AR3-route-policy] if-match acl 2600 [AR3-route-policy] apply local-preference 100 [AR3-route-policy]
Assign locpref route-policy to BGP peers on AR2 and AR3 routers:
[AR2]bgp 100 [AR2-bgp]peer 1.1.1.1 route-policy locpref export [AR3]bgp 100 [AR3-bgp]peer 1.1.1.1 route-policy locpref export
Let’s check IP and BGP routing tables of AR1 router again:
[AR1]dis ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 20 Routes : 21 Destination/Mask Proto Pre Cost Flags NextHop Interface 1.1.1.1/32 Direct 0 0 D 127.0.0.1 LoopBack0 2.2.2.2/32 OSPF 10 1 D 10.1.1.2 GigabitEthernet0/0/0 3.3.3.3/32 OSPF 10 1 D 10.1.2.2 GigabitEthernet0/0/1 4.4.4.4/32 IBGP 255 0 RD 150.1.1.2 GigabitEthernet0/0/0 10.1.1.0/30 Direct 0 0 D 10.1.1.1 GigabitEthernet0/0/0 10.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0 10.1.1.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0 10.1.2.0/30 Direct 0 0 D 10.1.2.1 GigabitEthernet0/0/1 10.1.2.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/1 10.1.2.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/1 10.1.3.0/30 OSPF 10 2 D 10.1.2.2 GigabitEthernet0/0/1 OSPF 10 2 D 10.1.1.2 GigabitEthernet0/0/0 100.100.100.100/32 Direct 0 0 D 127.0.0.1 LoopBack100 111.111.111.111/32 IBGP 255 0 RD 150.1.1.2 GigabitEthernet0/0/0 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 150.1.1.0/30 OSPF 10 2 D 10.1.1.2 GigabitEthernet0/0/0 150.2.2.0/30 OSPF 10 2 D 10.1.2.2 GigabitEthernet0/0/1 222.222.222.222/32 IBGP 255 0 RD 150.2.2.2 GigabitEthernet0/0/1 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 [AR1]dis bgp rout BGP Local router ID is 1.1.1.1 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 9 Network NextHop MED LocPrf PrefVal Path/Ogn *>i 4.4.4.4/32 150.1.1.2 0 100 0 200? * i 150.2.2.2 0 100 0 200? *> 100.100.100.100/32 0.0.0.0 0 0 i *>i 111.111.111.111/32 150.1.1.2 0 300 0 200? * i 150.2.2.2 0 200 0 200? *>i 150.1.1.0/30 2.2.2.2 0 100 0 i *>i 150.2.2.0/30 3.3.3.3 0 100 0 i *>i 222.222.222.222/32 150.2.2.2 0 300 0 200? * i 150.1.1.2 0 200 0 200?
Finally we did what we wanted to do. Our route-policy is working properly and traffic directed to Loopback 10 of AR4 router is going through AR2. Traffic directed to Loopback 20 of AR4 is going through AR3. For remaing traffic, local preference attribute is not to be taken into account for choosing the best path.