Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
pj255
New Contributor

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 6
Carl_Wallmark
Valued Contributor

Hi, yes but it is very limted, and you need at least FortiOS 5.0 try with: diag ip address list | grep wan2

FCNSA, FCNSP
---
FortiGate 200A/B, 224B, 110C, 100A/D, 80C/CM/Voice, 60B/C/CX/D, 50B, 40C, 30B
FortiAnalyzer 100B, 100C
FortiMail 100,100C
FortiManager VM
FortiAuthenticator VM
FortiToken
FortiAP 220B/221B, 11C

FCNSA, FCNSP---FortiGate 200A/B, 224B, 110C, 100A/D, 80C/CM/Voice, 60B/C/CX/D, 50B, 40C, 30BFortiAnalyzer 100B, 100CFortiMail 100,100CFortiManager VMFortiAuthenticator VMFortiTokenFortiAP 220B/221B, 11C
emnoc
Esteemed Contributor III

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

PCNSE 

NSE 

StrongSwan  

PCNSE NSE StrongSwan
SgtMalicious
New Contributor III

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
Valued Contributor

thanks emnoc, I stand corrected ;)

FCNSA, FCNSP
---
FortiGate 200A/B, 224B, 110C, 100A/D, 80C/CM/Voice, 60B/C/CX/D, 50B, 40C, 30B
FortiAnalyzer 100B, 100C
FortiMail 100,100C
FortiManager VM
FortiAuthenticator VM
FortiToken
FortiAP 220B/221B, 11C

FCNSA, FCNSP---FortiGate 200A/B, 224B, 110C, 100A/D, 80C/CM/Voice, 60B/C/CX/D, 50B, 40C, 30BFortiAnalyzer 100B, 100CFortiMail 100,100CFortiManager VMFortiAuthenticator VMFortiTokenFortiAP 220B/221B, 11C
emnoc
Esteemed Contributor III

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

PCNSE 

NSE 

StrongSwan  

PCNSE NSE StrongSwan
pj255
New Contributor

Thanks guys !!!
Labels
Top Kudoed Authors