How to save iptables configuration on Redhat Enterprise Server 7

I have a Redhat server (Red Hat Enterprise Linux Server release 7.2 (Maipo)) that resets iptable rules on re/boot.

According to the version 6 documentation, I execute:

/sbin/service iptables save

which returns:

The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

If I understand the message correctly, I attempted the following:

sudo systemctl iptables save

which returns:

Unknown operation 'iptables'.

I cannot locate the version 7 documentation on saving ip tables specifically, but previous versions support the same command.

What command should I run to save iptables config?

For reference:

firewall d satatus:

systemctl status firewalld
firewalld.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

Solution 1:

You should install iptables-services package.

Then service iptables save will work. Also these commands will work too:

# iptables-save > /etc/sysconfig/iptables
# ip6tables-save > /etc/sysconfig/ip6tables

AFAIK, systemctl doesn't have any option to save iptables-services' configuration.

Note: systemctl syntax is as follow : systemctl <operation> <unit>

Solution 2:

Here is link to Security Guide for Red Hat 7: using_firewalls

I use

# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.4 (Maipo)

And status of firewalld service:

# systemctl status firewalld
Active: active (running) since Fri 2018-04-13 10:00:18 CEST; 31min ago

So I think, you could also enable firewalld service:

systemctl start firewalld
systemctl enable firewalld

And change rules via firewall-config

  1. Press Super
  2. Type firewall,
  3. Select Permanent in drop down menu
  4. Put necessary settings