By applying route-policies, you can control the import of routes and set attributes for imported routes.
In Figure 1, Device A and Device B exchange routing information through OSPF; Device B and Device C exchange routing information through IS-IS.
It is required that Device B import IS-IS routes to OSPF and use the route-policy to set the cost of the route to 172.16.1.0/24 to 100 and set the tag of the route to 172.16.2.0/24 to 20.
When applying a route-policy to imported routes, note the following rules:
When configuring an IP prefix list, specify the IP prefix range as required.
The route-policy name is case sensitive.
The configuration roadmap is as follows:
Configure basic IS-IS functions on Device B and Device C.
Configure OSPF on Device A and Device B and import IS-IS routes.
Configure a routing policy on Device B, apply the route-policy when OSPF imports IS-IS routes, and check the routes.
To complete the configuration, you need the following data:
Area IDs, IS-IS levels, and system IDs of Device B and Device C
Area 0 (backbone area), in which Device A and Device B are located
ACL number, name of the IP prefix list, cost of the route to 172.16.1.0/24, and tag of the route to 172.16.2.0/24
# Configure Device C.
[~DeviceC] isis [*DeviceC-isis-1] is-level level-2 [*DeviceC-isis-1] network-entity 10.0000.0000.0001.00 [*DeviceC-isis-1] quit [*DeviceC] interface gigabitethernet 0/1/1 [*DeviceC-GigabitEthernet0/1/1] isis enable [*DeviceC-GigabitEthernet0/1/1] quit [*DeviceC] interface GigabitEthernet 0/1/0 [*DeviceC-GigabitEthernet0/1/0] isis enable [*DeviceC-GigabitEthernet0/1/0] quit [*DeviceC] interface GigabitEthernet 0/1/8 [*DeviceC-GigabitEthernet0/1/8] isis enable [*DeviceC-GigabitEthernet0/1/8] quit [*DeviceC] interface GigabitEthernet 0/1/16 [*DeviceC-GigabitEthernet0/1/16] isis enable [*DeviceC-GigabitEthernet0/1/16] commit [~DeviceC-GigabitEthernet0/1/16] quit
# Configure Device B.
[~DeviceB] isis [*DeviceB-isis-1] is-level level-2 [*DeviceB-isis-1] network-entity 10.0000.0000.0002.00 [*DeviceB-isis-1] quit [*DeviceB] interface gigabitethernet 0/1/8 [*DeviceB-GigabitEthernet0/1/8] isis enable [*DeviceB-GigabitEthernet0/1/8] commit [~DeviceB-GigabitEthernet0/1/8] quit
# Configure Device A and enable OSPF.
[~DeviceA] ospf [*DeviceA-ospf-1] area 0 [*DeviceA-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255 [*DeviceA-ospf-1-area-0.0.0.0] commit [~DeviceA-ospf-1-area-0.0.0.0] quit [*DeviceA-ospf-1] quit
# Configure Device B, enable OSPF, and import IS-IS routes.
[~DeviceB] ospf [*DeviceB-ospf-1] area 0 [*DeviceB-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255 [*DeviceB-ospf-1-area-0.0.0.0] quit [*DeviceB-ospf-1] import-route isis 1 [*DeviceB-ospf-1] commit [~DeviceB-ospf-1] quit
# Check the IP routing table on Device A to view the imported routes.
[~DeviceA] 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.16.1.0/24 1 Type2 1 192.168.1.2 192.168.1.2 172.16.2.0/24 1 Type2 1 192.168.1.2 192.168.1.2 172.16.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 Routing for NSSAs Destination Cost Type Tag NextHop AdvRouter Total Nets: 5 Intra Area: 1 Inter Area: 0 ASE: 4 NSSA: 0
# Configure an ACL numbered 2002 to import the route to 172.16.2.0/24.
[~DeviceB] acl number 2002 [*DeviceB-acl4-basic-2002] rule permit source 172.16.2.0 0.0.0.255 [*DeviceB-acl4-basic-2002] commit [~DeviceB-acl4-basic-2002] quit
# Configure an IP prefix list named prefix-a to import the route to 172.16.1.0/24.
[~DeviceB] ip ip-prefix prefix-a index 10 permit 172.16.1.0 24 [*DeviceB] commit
[~DeviceB] route-policy isis2ospf permit node 10 [*DeviceB-route-policy] if-match ip-prefix prefix-a [*DeviceB-route-policy] apply cost 100 [*DeviceB-route-policy] quit [*DeviceB] route-policy isis2ospf permit node 20 [*DeviceB-route-policy] if-match acl 2002 [*DeviceB-route-policy] apply tag 20 [*DeviceB-route-policy] quit [*DeviceB] route-policy isis2ospf permit node 30 [*DeviceB] commit [~DeviceB-route-policy] quit
# Configure Device B and apply the route-policy when routes are imported.
[~DeviceB] ospf [*DeviceB-ospf-1] import-route isis 1 route-policy isis2ospf [*DeviceB-ospf-1] commit [~DeviceB-ospf-1] quit
# Check the OSPF routing table on Device A. The command output shows that the cost of the route to 172.16.1.0/24 is 100, the tag of the route to 172.16.2.0/24 is 20, and that other route attributes remain unchanged.
[~DeviceA] 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.16.1.0/24 100 Type2 1 192.168.1.2 192.168.1.2 172.16.2.0/24 1 Type2 20 192.168.1.2 192.168.1.2 172.16.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 Routing for NSSAs Destination Cost Type Tag NextHop AdvRouter Total Nets: 5 Intra Area: 1 Inter Area: 0 ASE: 4 NSSA: 0
Device A configuration file
# sysname DeviceA # interface GigabitEthernet0/1/0 undo shutdown ip address 192.168.1.1 255.255.255.0 # ospf 1 area 0.0.0.0 network 192.168.1.0 0.0.0.255 # return
Device B configuration file
# sysname DeviceB # acl number 2002 rule 5 permit source 172.16.2.0 0.0.0.255 # isis 1 is-level level-2 network-entity 10.0000.0000.0002.00 # interface GigabitEthernet0/1/0 undo shutdown ip address 192.168.1.2 255.255.255.0 # interface GigabitEthernet0/1/8 undo shutdown ip address 192.168.2.2 255.255.255.0 isis enable 1 # 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.16.1.0 24 # return
Device C configuration file
# sysname DeviceC # isis 1 is-level level-2 network-entity 10.0000.0000.0001.00 # interface GigabitEthernet0/1/0 undo shutdown ip address 172.16.1.1 255.255.255.0 isis enable 1 # interface GigabitEthernet0/1/8 undo shutdown ip address 172.16.2.1 255.255.255.0 isis enable 1 # interface GigabitEthernet0/1/16 undo shutdown ip address 172.16.3.1 255.255.255.0 isis enable 1 # interface GigabitEthernet0/1/1 ip address 192.168.2.1 255.255.255.0 isis enable 1 # return