Thursday, December 5, 2013

Get a 'grep' on your config

I search configs a lot via the CLI. This saves time and sometimes downloading a config and searching it in Notepad++ is not an option.
When looking for particular pieces of a config you can use the UNIX style "grep" command to filter output, for example:

# show | grep      
  set ip

Great. Now we know that there is a line that contains the IP address. But where in the config is it? In FortiOS 5.0 the "FortiOS context" switch was introduced which helps in tracking this down.

# show | grep -f
config system interface
    edit "port10"
        set vdom "root"
        set ip <---
        set type physical
        set snmp-index 10

Notice that when using the -f switch the firewall shows the entire "context" that the string is used in. Also there's a handy little arrow on the right which points out where in the context the string exists.

1 comment:

Anonymous said...