Skip to main content

fortilib - a Python Library to interact with Fortigate Firewalls

Project description

fortilib - a Python Library to interact with Fortigate Firewalls

This Python module contains the ability to get and configure following object on Fortigate Firewalls:

  • Addresses
  • Address Groups
  • Interfaces
  • IPPools
  • Policies
  • Proxy Addresses
  • Proxy Address Groups
  • Proxy Policies
  • Routes
  • Services
  • Service Groups
  • Vips
  • Vip Groups

Installation

Python >= 3.8 is required.

Dependencies:

Simply install fortilib via pip:

> pip install fortilib

Quickstart

import ipaddress

from fortilib.firewall import FortigateFirewall
from fortilib.fortigateapi import FortigateFirewallApi
from fortilib.address import FortigateIpMask


api = FortigateFirewallApi(
    "127.0.0.1", # firewall ip
    "username",
    "password",
    "vdom", # use "root" if you dont have vdoms activated
)
firewall = FortigateFirewall("fw01", api)
firewall.login()

# load all objects from fortigate
firewall.get_all_objects()

# create an firewall address
address = FortigateIpMask()
address.name = "Test Address"
address.subnet = ipaddress.ip_network("127.0.0.1/32")

# add object to firewall
firewall.create_firewall_address(address)

# print all addresses on firewall
for address in firewall.addresses:
    print(address.name)

Contributing

See Contributing.

License

GPLv3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fortilib-1.0.2.tar.gz (31.9 kB view hashes)

Uploaded Source

Built Distribution

fortilib-1.0.2-py3-none-any.whl (40.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page