Avatar of onlinede
onlinede asked on

iptables-save

Hi all,

I've managed to save all my ip tables using

iptables-save
iptables-save -c > /etc/iptables-save

When I rebbot my linux box all the iptables are restored to default. I can recover them using

cat /etc/iptables-save | iptables-restore -c

What I need to do is create a scipr that can be run on bootup that will load my saved iptables.

Can anyone help?

Thanx in advance

Mk
Linux Security

Avatar of undefined
Last Comment
omarfarid

8/22/2022 - Mon
omarfarid

you may put this script in /etc/rc3.d for example and the script name should start with S and the script should be executable. You full path name to the command and files
ASKER
onlinede

Can you give me an example?

Mk
omarfarid

create a script in /etc/rc3.d say S99mpiptables that contains

/sbin/iptables-restore -c -n < /etc/iptables-save

then make it executable

chmod +x S99mpiptables
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER
onlinede

Hi

This has still not worked. What could it be?

Mk
ASKER CERTIFIED SOLUTION
Gabriel Orozco

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
omarfarid

why ?
Gabriel Orozco

omarfarid your solution is good

but the script need to go on /etc/init.d with proper start/stop control

then synlink that script as you say, S99firewall, and also for the unload K99firewall

in its current form its best suited for being called from rc.local, which is designed for this purpose.

Still your script is the answer in my point of view :-)
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
omarfarid

Thank you Redimido :)