RHEL 6 Iptables-Save

Hello everyone. I am somewhat new to administering Red Hat so please bear with me.

Here are the kernels I'm running-
Old RHEL     2.6.9-5.EL
New RHEL   2.6.32-131.6.1.el6.x86_64

I am in the process of replacing an our old RHEL server, and I need to migrate the iptables to the new server (I want the same exact setup). I tried saving a copy of iptables on the old server-
cd/etc/sysconfig/cp iptables iptables.bak1

And then I tried using the iptables-restore command on the new server, only to get "iptables-restore line 5 failed".

Is this because I'm not using the iptables-save command and just making a copy of the file? Can I run iptables-save without it affecting or messing anything up as this is our main router? OR is there no difference between doing a cp iptables and iptables-restore and I'm looking at a bigger problem here?

I'm open to any suggestions if someone has a better way to migrate iptables to a new machine.


Thanks.
Albert_WinfreyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PapertripCommented:
How are you invoking iptables-restore?
What is on line 5 of the iptables file?
0
PapertripCommented:
Can I run iptables-save without it affecting or messing anything up as this is our main router?
Yes, it just dumps the contents of iptables to STDOUT
is there no difference between doing a cp iptables and iptables-restore and I'm looking at a bigger problem here?
The output from iptables-save is the same format as /etc/sysconfig/iptables, so just copying that file should be fine, however you should run iptables-save first to dump any rules that may not be committed to disk.

On RHEL/CentOS, you can type 'service iptables save' and that will dump the contents and overwrite /etc/sysconfig/iptables.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.