https://github.com/telekom-mms/fortilib
fortilib - a Python Library to interact with Fortigate Firewalls
https://github.com/telekom-mms/fortilib
api fortigate python
Last synced: about 2 months ago
JSON representation
fortilib - a Python Library to interact with Fortigate Firewalls
- Host: GitHub
- URL: https://github.com/telekom-mms/fortilib
- Owner: telekom-mms
- License: gpl-3.0
- Created: 2022-08-17T11:42:16.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2025-04-05T16:34:17.000Z (about 2 months ago)
- Last Synced: 2025-04-13T04:11:45.552Z (about 2 months ago)
- Topics: api, fortigate, python
- Language: Python
- Homepage:
- Size: 667 KB
- Stars: 3
- Watchers: 4
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# fortilib - a Python Library to interact with Fortigate Firewalls
This Python module contains the ability to get and configure following object on [Fortigate Firewalls](https://www.fortinet.com/products/next-generation-firewall):
* 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:
* [httpx](https://www.python-httpx.org/)Simply install fortilib via pip:
```
> pip install fortilib
```## Quickstart
```python
import ipaddressfrom fortilib.firewall import FortigateFirewall
from fortilib.fortigateapi import FortigateFirewallApi
from fortilib.address import FortigateIpMaskapi = FortigateFirewallApi(
ipaddr="127.0.0.1", # firewall ip
vdom="vdom", # use "root" if you dont have vdoms activated
access_token="token",
# username="username", # alternative login with username
# password="password", # and password
)
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](CONTRIBUTING.md).
## License
GPLv3