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(
ipaddr="127.0.0.1",
vdom="vdom",
access_token="token",
)
firewall = FortigateFirewall("fw01", api)
firewall.login()
firewall.get_all_objects()
address = FortigateIpMask()
address.name = "Test Address"
address.subnet = ipaddress.ip_network("127.0.0.1/32")
firewall.create_firewall_address(address)
for address in firewall.addresses:
print(address.name)
Contributing
See Contributing.
License
GPLv3