In this post, we are going to take a brief look at FortiGate and Python from a beginner’s point of view.  Today’s networks almost require some knowledge of  automation and Python is becoming the de facto standard. Also, it’s becoming more and more prudent for today’s engineers to get a decent grasp of some basic techniques involved with python programming.  This will not only make their jobs easier, but to make themselves more marketable.  Below we are going to touch on a few introductory examples of how to use Python (specifically the “pyFG” library) with your local FortiGate firewall.

 

Installation and general Python programming

This post won’t necessarily get into the specifics of installing Python and/or pip, there are many better guides for that.  Also, this post will assume you have a very basic knowledge of Python.  If not, I highly suggest getting Zed Shaw’s book “Learn Python the Hard Way” and working through that.  It is an excellent primer for Python.

Moving on, let’s install the pyFG library.  To get the pyFG library on your local machine (Linus and/or MacOS), run:

brandon@echobase:~$ pip install pyFG

Then verify it is installed with:

brandon@echobase:~$ pip list
-- edited --
pyfg (0.50)

Alright, now we are ready to start playing around with Python and FortiGates.  If you have Windows or are using Anaconda, use the Anaconda package manager to download pyFG.

Read More