How to add an iptables rule to open a port in Debian

  bash, hardware, linux
# be root
sudo su
 
# note: port 13666 is for LCDd (apt-get install LCDd)

iptables -I INPUT -p tcp --dport 13666 -j ACCEPT
iptables-save


# list rules
iptables -L
 
# save to config
/sbin/iptables-save > /etc/iptables.conf


nano /etc/rc.local


# add this line before exit, to reload the rules in every reboot
iptables-restore < /etc/iptables.conf
 
shutdown -r now