Iptables
From James's Wiki
to save firewall rules use:
sudo dpkg-reconfigure iptables-persistent
or (stretch):
sudo dpkg-reconfigure iptables-persistent
allow ssh:
sudo iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
sudo iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT
delete by number:
sudo iptables -L --line-numbers
sudo iptables -D INPUT 3
references: