Can not save iptables

Issues related to configuring your network
Post Reply
Romario Picari
Posts: 4
Joined: 2018/09/10 09:10:49

Can not save iptables

Post by Romario Picari » 2019/01/04 08:15:31

Hello i have used iptables command but it does not save the command.
Every time i restart server i have to write command again.

iptables -A OUTPUT -o lo -j ACCEPT
iptables -A OUTPUT -d 192.168.1.0/24 -j ACCEPT
iptables -P OUTPUT DROP

iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -s 192.168.1.0/24 -j ACCEPT
iptables -A INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT
iptables -P INPUT DROP

I use iptable-save command
Help please !!

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: Can not save iptables

Post by hunter86_bg » 2019/01/04 11:54:24

Either use the firewall-cmd or disable firewalld and install (and enable) iptables.service and ip6table.service.
Firewalld will remove any entry that is not inside it's configuration.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Can not save iptables

Post by TrevorH » 2019/01/04 13:15:26

I use iptable-save command
That doesn't save the rules, it only prints them. To save the rules you need to run service iptables save
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

MartinR
Posts: 714
Joined: 2015/05/11 07:53:27
Location: UK

Re: Can not save iptables

Post by MartinR » 2019/01/05 11:10:51

Or as the man page says:
Use I/O-redirection provided by your shell to write to a file.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Can not save iptables

Post by TrevorH » 2019/01/05 12:53:36

You can do that but service iptables save makes a backup copy of the old file for you first and probably does other stuff behind the scenes.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Post Reply