Skip to main content
pj255
New Member
August 11, 2014
Question

PIPE in Fortigate

Hi Is it possible to pipe the CLi output on a Fortigate FW? I want to run something along the lines of: " diag ip address list | include wan2" Is it possible from the FG CLI?

    6 replies

    Carl_Wallmark
    New Member
    August 11, 2014
    Hi, yes but it is very limted, and you need at least FortiOS 5.0 try with: diag ip address list | grep wan2
    emnoc
    New Member
    August 11, 2014
    yes but it is very limted, and you need at least FortiOS 5.0
    Not 100% correct, IIRC grep came along around MR3 or maybe as late as mid MR2. Also you can do inverse grep amongst other things. ( 4.0 Mr3 p16 ) show firewall policy | grep -v wan2 Here' s your options btw; 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 Command fail. Return code 9
    SgtMalicious
    New Member
    August 11, 2014
    There' s also a contextual option, -f, which I believe was new in 5
      # show | grep -f wacky-host  config firewall address      edit " wacky-host.blah.blah.blah"  <---      ...      next  end  config firewall policy      edit 1          ...          set srcaddr " wacky-host.blah.blah.blah"  <---          ...       next  end  
    Carl_Wallmark
    New Member
    August 11, 2014
    thanks emnoc, I stand corrected ;)
    emnoc
    New Member
    August 11, 2014
    yes -f came around later. Here 5.2GA options. Usage: grep [-invfcABC] PATTERN Options: -i Ignore case distinctions -n Print line number with output lines -v Select non-matching lines -f Print fortinet config context -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
    pj255
    pj255Author
    New Member
    August 12, 2014
    Thanks guys !!!
    Thought Leadership. Security Summit. Thursday, November 12th, PGA National Resort, Palm Beach Gardens, FL.
    Thought Leadership. Security Summit. Thursday, October 8th. Disney's Grand Californian Hotel & SPA, Anaheim, CA.
    Security Operations Summit: Modernize SecOps. Operate AI-Native.AMER: November 4 | 9:00 AM PST. India and SAARC: November 5 | 10:00 AM IST. EMEA: November 5 | 10:30 AM CET. APAC: November 5 | 11:00 AM SGT