Iptables
Show ip rules
sudo iptables -L --line-numbers
# shows port numbers instead of text
sudo iptables -L --line-numbers -n
Delete Rule
# delete rule
sudo iptables -D INPUT 6
Add Rule
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
Delete ALL rules (VERY UNSAFE, BACKUP FIRST)
# F for flush I assume
iptables -F
Restore iptables config (after saving using iptables-save
)
sudo iptables-restore < /etc/iptables.rules
Permanently enable iptables rrules
sudo yum install iptables-services -y
# restore/change iptables (make sure it works and can ssh)
sudo systemctl start iptables
sudo systemctl enable iptables
sudo systemctl status iptables
sudo systemctl disable firewalld.service
sudo systemctl stop firewalld.service
Login to root then:
iptables-save >/etc/sysconfig/iptables