Skip to main content
biltjc
New Member
October 28, 2014
Question

Show Policy in CLI

  • October 28, 2014
  • 12 replies
  • 72573 views

Hello,

 

I used with Juniper to show a policy list based on search criterias.

I'd like to do the same with my fortigate but I don't find how to do.

 

I'm doing : get firewall policy

But the result is only ID's.

 

Is there a way to get policy ?

    12 replies

    ede_pfau
    SuperUser
    SuperUser
    October 28, 2014

    Try 'show firewall policy | grep <something>' or even 'show full firewall policy | grep <something>'.

    With newer versions of FortiOS grep can take options:

    gate # show | grep -X
    grep: invalid option -- X
    Usage: grep [-invcABC] PATTERN
    Options:
            -i      Ignore case distinctions
            -n      Print line number with output lines
            -v      Select non-matching lines
            -c      Only print count of matching lines
            -A      Print NUM lines of trailing context
            -B      Print NUM lines of leading context

            -C      Print NUM lines of output context

    biltjc
    biltjcAuthor
    New Member
    October 28, 2014

    Thank you for your reply.

     

    grep find some lines in the policy but I only have 'set dstaddr server_A' by example.

    How could I show the whole policy containing that server ?

    Maybe is it impossible ?

    ede_pfau
    SuperUser
    SuperUser
    October 28, 2014

    'grep' is not context sensitive - it doesn't know about how many lines belong to a policy. The best you can do is to use 'grep -C  20' or so to show 20 lines around the match.

     

    If you need detailed inspection I recommend to download the config and load it in an editor. But that is not context aware neither.

    biltjc
    biltjcAuthor
    New Member
    October 28, 2014

    I know what I can do or not now.

    It's a pity there is no CLI function to get policy.

     

    Thanks a lot for your help.

     

    norouzi
    New Member
    October 28, 2014

    Do not compare Fortinet and Juniper ;)

    Just kidding

     

    In the CLI you can use "?" whenever you want.

    show firewall policy

    or:

     

    config firewall policy

    show

    end

     

    biltjc
    biltjcAuthor
    New Member
    October 28, 2014

    Thank you for the tip norouzi

    emnoc
    New Member
    October 29, 2014

    And if you the exact policy id# than you can do a "show firewall policy <the #>" . Yes it's similar to a juniper  but does not have the display set or match capabilities.

    SgtMalicious
    New Member
    October 30, 2014

    I had the same problem as you coming from ScreenOS. You may be interested in this: [link]https://forum.fortinet.com/tm.aspx?m=104633[/link]

    amitkor
    New Member
    October 31, 2014

    On the other hand, fortigate has better GUI ^^

    Dave_Hall
    New Member
    November 1, 2014

    Latest FortiOS firmware updated grep to include context (option -f) setting.

     

    i.e. show firewall policy | grep -f wan1

     

     

    emnoc
    New Member
    November 1, 2014

    And one more thing to go along with the show for any part of the cfg tree. If you use the "show full" you will get the full cfg details.

     

     

    e.g of usage

     

    show full-configuration firewall policy 12

     

    or

     

    config firewall policy

       show full-configuration

     

     

    Thought Leadership Security Summit. Outpace New Threats with AI - enhanced defense. Tuesday, Septmeber 15, 8:30 AM - 2:30 PM PT. The Golf Club at Newcastle, WA.
    Fortinet Flag the Hack. Wednesday, August 26, 9:00 AM - 5:00 PM ET, COSM, Atlanta, GA.