How to Use iptables on Red Hat Linux 7

Just helped set up a Red Hat Enterprise Linux 7 server. The firewall is handled by firewalld on rhel 7 by default. To use your old iptables rules, you have to disable firewalld and enable iptables. Here are the steps.

  1. Disable firewalld
    systemctl stop firewalld.service
    systemctl disable firewalld.service
  2. Install iptables
    yum install iptables iptables-services
  3. Enable iptables
    systemctl start iptables.service
    systemctl enable iptables.service
  4. Apply the iptables rules
  5. Save the iptables rules
    service iptables save

If you use ip6tables, you can enable it as well.

systemctl start ip6tables.service
systemctl enable ip6tables.service
service ip6tables save