Where to specify firewall rules in code?

I’m looking into enabling the firewall and customizing the rules.

I expect that I’ll be able to manually experiment by running iptables commands on the host. Once the experimentation phase is over, I’ll have a set of rules I want to apply to every device in my fleet. Is there a place I can put that in code, in the dashboard, or maybe in the supervisor API?

(or today is it only possible to run iptables manually, one device at a time?)

After experimenting further, it’s looking like the answer to “where do I put my iptables commands?” is “in a container with network_mode: host and privileged: true”.

Note also that you may need to use iptables-legacy, which can be aliased to iptables with update-alternatives --set iptables /usr/sbin/iptables-legacy (which is important if you access iptables via another tool like ufw).