Networking Requirements
Figure 1. Networking diagram for configuring OSPF route import and export
As shown in Figure 1, on Switch A, export the static route (88.88.88.0/24 and 88.88.89.0/24) from RIB to OSPF, and OSPF advertises the route (88.88.88.0/24 and 88.88.89.0/24) to Switch B. On Switch B, implementing OSPF import a policy to add only the route 88.88.88.0/24 to RIB.
To achieve the above results, follow the configuration roadmap below to complete the configuration.
- Configure static routes and basic OSPF functions on Switch A.
- On Switch A, introduce the static route (network 88.88.0.0/16) into OSPF by using OSPF export, and then OSPF will advertise the routes to the neighbor Switch B via the OSPF routing protocol.
- Configure basic OSPF functions on Switch B.
- Configure OSPF import a policy on Switch B to filter static routes received from Switch A, eventually add only network 88.88.88.0/24 to the local RIB.
Procedure
SwitchA
Step1 Configure VLANs and VLAN interfaces.
admin@SwitchA# set vlan-interface interface vlan20 vif vlan20 address 20.20.20.10 prefix-length 24 admin@SwitchA# set vlan-interface interface vlan30 vif vlan30 address 30.30.30.30 prefix-length 24 admin@SwitchA# set vlans vlan-id 20 l3-interface vlan20 admin@SwitchA# set vlans vlan-id 30 l3-interface vlan30 admin@SwitchA# set interface gigabit-ethernet ge-1/1/1 family ethernet-switching native-vlan-id 30 admin@SwitchA# set interface gigabit-ethernet ge-1/1/2 family ethernet-switching native-vlan-id 20
Step2 Enable IP routing.
admin@SwitchA# set ip routing enable true
Step3 Configure the static route entries.
admin@SwitchA# set protocols static route 88.88.88.0/24 next-hop 20.20.20.20 admin@SwitchA# set protocols static route 88.88.89.0/24 next-hop 20.20.20.20 admin@SwitchA# set protocols static route 88.99.2.0/24 next-hop 20.20.20.20
Step4 Configure a routing policy named ex1 to match protocol static and network 88.88.0.0/16
admin@SwitchA# set policy policy-statement ex1 term 1 from protocol static admin@SwitchA# set policy policy-statement ex1 term 1 from network4 88.88.0.0/16 admin@SwitchA# set policy policy-statement ex1 term 1 then accept admin@SwitchA# set policy traceoptions flag all disable false
Step5 Configure an OSPF instance and apply the export routing policy “ex1”.
admin@SwitchA# set protocols ospf4 router-id 10.1.1.1 admin@SwitchA# set protocols ospf4 area 0.0.0.0 interface vlan30 vif vlan30 address 30.30.30.30 admin@SwitchA# set protocols ospf4 area 0.0.0.0 interface vlan20 vif vlan20 address 20.20.20.10 admin@SwitchA# set protocols ospf4 export ex1 admin@SwitchA# set protocols ospf4 traceoptions flag all disable false
Step6 Commit the configurations.
admin@SwitchA# commit
SwitchB
Step1 Configure VLANs and VLAN interfaces.
admin@SwitchB# set vlan-interface interface vlan20 vif vlan20 address 20.20.20.20 prefix-length 24 admin@SwitchB# set vlan-interface interface vlan10 vif vlan10 address 10.10.10.10 prefix-length 24 admin@SwitchB# set vlan-interface traceoptions flag rib disable false admin@SwitchB# set vlans vlan-id 10 l3-interface vlan10 admin@SwitchB# set vlans vlan-id 20 l3-interface vlan20 admin@SwitchB# set interface gigabit-ethernet ge-1/1/2 family ethernet-switching native-vlan-id 20 admin@SwitchB# set interface gigabit-ethernet ge-1/1/3 family ethernet-switching native-vlan-id 10
Step2 Enable IP routing.
admin@SwitchB# set ip routing enable true
Step3 Configure a routing policy named im1 to match network 88.88.88.0/24.
admin@SwitchB# set policy policy-statement im1 term 1 from network4 88.88.88.0/24 admin@SwitchB# set policy policy-statement im1 term 1 then accept admin@SwitchB# set policy policy-statement im1 then reject
Note that the last configured policy action “reject” is required, because the default action is “accept”. If a route does not match any rule of the routing policy when applied in the OSPF routing import or export, the route can still be received or advertised normally.
Step4 Configure an OSPF instance and apply an export routing policy “im1”.
admin@SwitchB# set protocols ospf4 router-id 10.2.2.2 admin@SwitchB# set protocols ospf4 area 0.0.0.0 interface vlan10 vif vlan10 address 10.10.10.10 admin@SwitchB# set protocols ospf4 area 0.0.0.0 interface vlan20 vif vlan20 address 20.20.20.20 admin@SwitchB# set protocols ospf4 import im1 admin@SwitchB# set protocols ospf4 traceoptions flag all disable false
Step5 Commit the configurations.
admin@SwitchB# commit
Step6 After finishing all the above configurations, you can check the routing table on Switch A,
You will see that RIB export the routes (route 88.88.88.0/24 next-hop 20.20.20.20 and route 88.88.89.0/24 next-hop 20.20.20.20) to OSPF. Check the routing table on Switch B, you will see that only the route 88.88.88.0/24 next-hop 20.20.20.20 has been added to the RIB.