Example for Applying a Routing Policy for Importing Routes
Networking Requirements
In Figure 10-5, SwitchB exchanges routing information with SwitchA through OSPF, and with SwitchC through IS-IS. A user wants SwitchB to import IS-IS routes into the OSPF network. The user also wants the route to 172.17.1.0/24 that is imported into the OSPF network to have a low preference and the route to 172.17.2.0/24 to have a tag, making it easy to reference by a routing policy.
Configuration Roadmap
The configuration roadmap is as follows:
Configure a routing policy on SwitchB, set the cost of the route to 172.17.1.0/24 to 100, and apply the routing policy when OSPF imports IS-IS routes. The routing policy allows the route to 172.17.1.0/24 to have a low preference.
Configure the routing policy on SwitchB, set the tag of the route to 172.17.2.0/24 to 20, and apply the routing policy when OSPF imports IS-IS routes. This allows the tag of the route to 172.17.2.0/24 to take effect, making it easy to reference by a routing policy.
Procedure
- Add interfaces to VLANs.
<HUAWEI> system-view [~HUAWEI] sysname SwitchA [*HUAWEI] commit [~SwitchA] vlan 10 [*SwitchA-vlan10] quit [*SwitchA] interface 10ge 1/0/1 [*SwitchA-10GE1/0/1] port link-type trunk [*SwitchA-10GE1/0/1] port trunk allow-pass vlan 10 [*SwitchA-10GE1/0/1] quit [*SwitchA] commit
The configurations of SwitchB and SwitchC are similar to the configuration of SwitchA, and are not described here.
- Assign IP addresses to VLANIF interfaces.
[~SwitchA] interface vlanif 10 [*SwitchA-Vlanif10] ip address 192.168.1.1 24 [*SwitchA-Vlanif10] quit [*SwitchA] commit
The configurations of SwitchB and SwitchC are similar to the configuration of SwitchA, and are not described here.
- Configure IS-IS.
# Configure SwitchC.
[~SwitchC] isis [*SwitchC-isis-1] is-level level-2 [*SwitchC-isis-1] network-entity 10.0000.0000.0001.00 [*SwitchC-isis-1] quit [*SwitchC] interface vlanif 20 [*SwitchC-Vlanif20] isis enable [*SwitchC-Vlanif20] quit [*SwitchC] interface vlanif 30 [*SwitchC-Vlanif30] isis enable [*SwitchC-Vlanif30] quit [*SwitchC] interface vlanif 40 [*SwitchC-Vlanif40] isis enable [*SwitchC-Vlanif40] quit [*SwitchC] interface vlanif 50 [*SwitchC-Vlanif50] isis enable [*SwitchC-Vlanif50] quit [*SwitchC] commit
# Configure Switch B.
[~SwitchB] isis [*SwitchB-isis-1] is-level level-2 [*SwitchB-isis-1] network-entity 10.0000.0000.0002.00 [*SwitchB-isis-1] quit [*SwitchB] interface vlanif 20 [*SwitchB-Vlanif20] isis enable [*SwitchB-Vlanif20] quit [*SwitchB] commit
- Configure OSPF and import routes.
# Configure SwitchA and enable OSPF.
[~SwitchA] ospf [*SwitchA-ospf-1] area 0 [*SwitchA-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255 [*SwitchA-ospf-1-area-0.0.0.0] quit [*SwitchA-ospf-1] quit [*SwitchA] commit
# Configure SwitchB, enable OSPF, and import IS-IS routes.
[~SwitchB] ospf [*SwitchB-ospf-1] area 0 [*SwitchB-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255 [*SwitchB-ospf-1-area-0.0.0.0] quit [*SwitchB-ospf-1] import-route isis 1 [*SwitchB-ospf-1] quit [*SwitchB] commit
# Check the OSPF routing table on SwitchA. You will see the imported routes.
[~SwitchA] display ospf routing OSPF Process 1 with Router ID 192.168.1.1 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 192.168.1.0/24 1 Stub 192.168.1.1 192.168.1.1 0.0.0.0 Routing for ASEs Destination Cost Type Tag NextHop AdvRouter 172.17.1.0/24 1 Type2 1 192.168.1.2 192.168.1.2 172.17.2.0/24 1 Type2 1 192.168.1.2 192.168.1.2 172.17.3.0/24 1 Type2 1 192.168.1.2 192.168.1.2 192.168.2.0/24 1 Type2 1 192.168.1.2 192.168.1.2 Total Nets: 5 Intra Area: 1 Inter Area: 0 ASE: 4 NSSA: 0
- Configure a filtering list.
# Set ACL 2002 to match 172.17.2.0/24.
[~SwitchB] acl number 2002 [*SwitchB-acl-basic-2002] rule permit source 172.17.2.0 0.0.0.255 [*SwitchB-acl-basic-2002] quit [*SwitchB] commit
# Configure the IP prefix list named prefix-a to match 172.17.1.0/24.
[~SwitchB] ip ip-prefix prefix-a index 10 permit 172.17.1.0 24 [*SwitchB] commit
- Configure a routing policy.
[~SwitchB] route-policy isis2ospf permit node 10 [*SwitchB-route-policy] if-match ip-prefix prefix-a [*SwitchB-route-policy] apply cost 100 [*SwitchB-route-policy] quit [*SwitchB] route-policy isis2ospf permit node 20 [*SwitchB-route-policy] if-match acl 2002 [*SwitchB-route-policy] apply tag 20 [*SwitchB-route-policy] quit [*SwitchB] route-policy isis2ospf permit node 30 [*SwitchB-route-policy] quit [*SwitchB] commit
- Apply the routing policy when routes are imported.
# Configure SwitchB and apply the routing policy when routes are imported.
[~SwitchB] ospf [*SwitchB-ospf-1] import-route isis 1 route-policy isis2ospf [*SwitchB-ospf-1] quit [*SwitchB] commit
# Check the OSPF routing table on SwitchA. You will see that the cost of the route to 172.17.1.0/24 is 100, the tag of the route to 172.17.2.0/24 is 20, and other route attributes remain unchanged.
[~SwitchA] display ospf routing OSPF Process 1 with Router ID 192.168.1.1 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 192.168.1.0/24 1 Stub 192.168.1.1 192.168.1.1 0.0.0.0 Routing for ASEs Destination Cost Type Tag NextHop AdvRouter 172.17.1.0/24 100 Type2 1 192.168.1.2 192.168.1.2 172.17.2.0/24 1 Type2 20 192.168.1.2 192.168.1.2 172.17.3.0/24 1 Type2 1 192.168.1.2 192.168.1.2 192.168.2.0/24 1 Type2 1 192.168.1.2 192.168.1.2 Total Nets: 5 Intra Area: 1 Inter Area: 0 ASE: 4 NSSA: 0
Configuration Files
- Configuration file of SwitchA
# sysname SwitchA # vlan batch 10 # interface Vlanif10 ip address 192.168.1.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # ospf 1 area 0.0.0.0 network 192.168.1.0 0.0.0.255 # return
- Configuration file of SwitchB
# sysname SwitchB # vlan batch 10 20 # acl number 2002 rule 5 permit source 172.17.2.0 0.0.0.255 # isis 1 is-level level-2 network-entity 10.0000.0000.0002.00 # interface Vlanif10 ip address 192.168.1.2 255.255.255.0 # interface Vlanif20 ip address 192.168.2.2 255.255.255.0 isis enable 1 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 20 # ospf 1 import-route isis 1 route-policy isis2ospf area 0.0.0.0 network 192.168.1.0 0.0.0.255 # route-policy isis2ospf permit node 10 if-match ip-prefix prefix-a apply cost 100 # route-policy isis2ospf permit node 20 if-match acl 2002 apply tag 20 # route-policy isis2ospf permit node 30 # ip ip-prefix prefix-a index 10 permit 172.17.1.0 24 # return
- Configuration file of SwitchC
# sysname SwitchC # vlan batch 20 30 40 50 # isis 1 is-level level-2 network-entity 10.0000.0000.0001.00 # interface Vlanif20 ip address 192.168.2.1 255.255.255.0 isis enable 1 # interface Vlanif30 ip address 172.17.1.1 255.255.255.0 isis enable 1 # interface Vlanif40 ip address 172.17.2.1 255.255.255.0 isis enable 1 # interface Vlanif50 ip address 172.17.3.1 255.255.255.0 isis enable 1 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 20 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 30 # interface 10GE1/0/3 port link-type trunk port trunk allow-pass vlan 40 # interface 10GE1/0/4 port link-type trunk port trunk allow-pass vlan 50 # return