The following steps show how to store iptables rules to survive across OS reboots. In some cases like patching iptables package can be reinstalled. In that case, having a backup of iptables rules can be very handy.
1. Make sure firewalld is down and disabled. If they are not down/disabled, please run:
# systemctl stop firewalld # systemctl disable firewalld
2. Install iptables-services package and start/enable iptables service, as follows:
# yum install -y iptables-services.x86_64 # systemctl start iptables # systemctl enable iptables
3. Add your rules:
The following is just and example of how to add a rule
# iptables -I INPUT 1 -p tcp -m tcp --dport 7003 -j ACCEPT
4. Save rules to make them persistent across reboots or even OSMS patching.
# service iptables save
5. You can also list your rules to make sure rules were successfully saved in file:
# cat /etc/sysconfig/iptables # iptables -L