Use iptables
to add or remove firewall rules imperitively. I’m fairly certain NixOS doesn’t automatically save/restore iptables rules, so any rules you create this way will not persist across reboots.
- List firewall rules:
sudo iptables -L
- Open port 8080:
sudo iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
- Identify firewall rule number:
sudo iptables -L INPUT --line-numbers
- Remove firewall rule:
sudo iptables -D INPUT <RULE_NUM>
I know of no method to alter firewall rules without root privileges.