Network automation in practice lab 4 of 11
Firewall policy as code - FortiOS REST and PAN-OS XML API
Keep Fenwick Rail's monitoring rule in one YAML file and make a FortiGate and a Palo Alto Networks firewall hold exactly that, through their own APIs: FortiOS REST with a session login, PAN-OS XML with an API key, a candidate configuration and a commit job. Every object is read before it is written, so the second run changes nothing and commits nothing.
Run this lab
It needs Standard: its 3 nodes are set to 4 vCPU and 9,728 MB in total. It is ready about 17 minutes after you start it. It starts already set up, with nothing to paste before the first task.
In your workspace: Shared, then Network Automation in Practice - multi-vendor professional guided labs, then 04 - Firewall policy as code - FortiOS REST and PAN-OS XML API
Run it on Standard from £5 a day
- About 17 min to be ready
- About 75 min of tasks
- Level
- Advanced
- How you work
- CLI-led
- Nodes need
- 4 vCPU, 9,728 MB
- Smallest plan
- Standard
The scenario
Fenwick Rail runs two firewall vendors: a FortiGate at the depots and a Palo Alto Networks firewall in the York data centre. The monitoring server (10.20.0.10) needs HTTPS on port 8443 to the new freight-booking servers (10.60.0.0/24) through both. In the past someone clicked it into each GUI, slightly differently each time. From today the rule lives in rules.yaml, and fwpolicy.py makes both firewalls hold exactly that.
fwapi.py already talks to both APIs. Two pieces are missing: the logic that decides whether an object needs writing, and the PAN-OS commit.
Start-up and waits. Click Start all. fgt1 is ready in about a minute. pa1 boots from its bootstrap disk, which sets its management address, the
netopslogin and the zonesinsideandservers: its web interface and API answer after about 8 to 10 minutes, and a commit then takes 2 to 6 minutes on this virtual firewall. Do Tasks 1 and 2 on fgt1 while pa1 boots. Measured on our servers: the whole lab was ready for its first task about 17 minutes after Start all, with every device booted.
What you’ll practise
- Sign in to FortiOS's REST API and PAN-OS's XML API from Python
- Read, create and replace address objects, services and security rules on both
- Compare objects in one neutral shape so the same policy logic drives two vendors
- Commit PAN-OS only when its candidate has pending changes, and follow the commit job
- Prove idempotence: a second run reports 0 changes and no commit
The tasks
- Talk to both APIs by hand
- Decide what to write
- Commit only when there is something to commit
- Apply, then look
- Prove it
The Lab Tasks pane has the scenario, these tasks, the checks to run, hints and the full solution.
Topology and devices
The network as it opens in EVE-NG, drawn from the lab’s own canvas, and the image each node runs.
Every link, as text
- devbox
eth0to Mgmt (network) - fgt1
port1to Mgmt (network) - pa1
mgmtto Mgmt (network)
| Node | Device | Image in Add Node | Set to |
|---|---|---|---|
| devbox | CloudLabBox code workstation (Docker) | CloudLabBox’s own workstation image, with a browser code editor | 1 vCPU, 2,048 MB |
| fgt1 | Fortinet FortiGate | fortinet-FGT-v7.0.17.M-build0682 | 1 vCPU, 2,048 MB |
| pa1 | Palo Alto Networks VM-Series (PAN-OS) | paloalto-11.2.5 | 2 vCPU, 5,632 MB |
How to open this lab
Sign in to your workspace at
lab.cloudlabbox.com.In File Manager, open Shared, then the folder
Network Automation in Practice - multi-vendor professional guided labs.Open
04 - Firewall policy as code - FortiOS REST and PAN-OS XML APIand start its nodes, then open Lab Tasks for the scenario and the steps.
The lab is read-only. You can start the nodes and configure the devices, but changes to the topology can’t be saved. To change it, rebuild it in your own folder.
More Network automation in practice labs
All Network automation in practice labs
Related labs in other courses
CloudLabBox is independent of Arista Networks, Cisco, Fortinet, Juniper Networks and Palo Alto Networks. The lab follows exam topics and isn’t vendor training material; vendor names identify the exams and the images in the workspace.