FortiGate
FortiGate Next Generation Firewall utilizes purpose-built security processors and threat intelligence security services from FortiGuard labs to deliver top-rated protection and high performance, including encrypted traffic.
ppatel
Staff
Staff
Article Id 191525

Description

 

This article describes how to filter static routes which will be redistributed to OSPF domain.
It approaches the problem step-by-step with problem explanation and final result verification.
Also, it illustrates how to change the metric type of the redistributed static route from default E2 to E1.


Solution

 

Starting status:


At the beginning of this example there are two static routes in the routing table:

 

cluster-a # get router info routing-table all
path=router, objname=info, tablename=(null), size=0
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
       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, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default

S*      0.0.0.0/0 [10/0] via 192.168.196.254, port1
S       192.168.10.0/24 [10/0] is directly connected, port2
S       192.168.33.0/24 [10/0] is directly connected, port2
C       192.168.112.0/24 is directly connected, port2
C       192.168.196.0/24 is directly connected, port1

 

The objective is to distribute only 192.168.33.0/24.

The static routes are not distributed by default. In next step the redistribution will be enabled.

 

config redistribute "static"
    set status enable
end

 

Both of them will now be redistributed.

 

cluster-a # get router info ospf database brief
path=router, objname=info, tablename=(null), size=0

                Router Link States (Area 0.0.1.47)

Link ID         ADV Router      Age  Seq#     CkSum Flag Link count
0.0.3.2         0.0.3.2         103  80000004 0564  0031 1

                AS External Link States

Link ID         ADV Router      Age  Seq#     CkSum Flag Route              Tag
192.168.10.0    0.0.3.2         142  80000001 064a  0021 E2 192.168.10.0/24 0
192.168.33.0    0.0.3.2         142  80000001 0831  0021 E2 192.168.33.0/24 0

cluster-a #

 

This is not what is required. Three steps are needed to change the behavior.

 

  1. Prepare access-list.
  2. Prepare route-map using the access-list.
  3. Use the route-map.

    Step 1: Prepare access-list.

config router access-list
   
edit "wanted-static-routes"
        config rule
            edit 1
                set prefix 192.168.33.0/24
                set exact-match enable
                set action permit
            next
        end
end
end

 

Step 2: Prepare route-map using the access-list:

config router route-map
   
edit "static-to-ospf"
        config rule
            edit 1
                set match-ip-address "wanted-static-routes"
             next
        end

end
end

 

Step 3: Use the route-map.

 

config router ospf
    config redistribute "static"
        set status enable
        set routemap "static-to-ospf"
    end
end

 

Verification of Configuration and Troubleshooting:

Now the behavior should be as expected.

 

cluster-a # get router info ospf database brief
path=router, objname=info, tablename=(null), size=0

                Router Link States (Area 0.0.1.47)

Link ID         ADV Router      Age  Seq#     CkSum Flag Link count
0.0.3.2         0.0.3.2         9    80000006 0166  0021 1

                AS External Link States

Link ID         ADV Router      Age  Seq#     CkSum Flag Route              Tag
192.168.33.0    0.0.3.2         14   80000002 0632  0021 E2 192.168.33.0/24 0

 

As per the above output, OSPF shows the default Metric-Type 2 (E2) for redistributed static route 192.168.33.0/24.

To change the metric type from default E2 to E1 then run the below command.

 

config router ospf
    config redistribute "static"
        set status enable
        set routemap "static-to-ospf"

        set metric-type 1
    end
end

 

Related Article:

Technical Note : How to control (filter) OSPF route redistribution with access-list and route-map