Migrating from IPChains to Netfilters?
lodn asks: "I've been using a Linux gateway for some time now. It's a simple kernel 2.2.18 install with IP forwarding. Thanks to the great HOWTO on IPchains I was able to configure it with no problems. Now I'd like to upgrade to kernel 2.4, however I have not been able to find a HOWTO for Netfilters! Does anyone know where such can be found?" Anyone know of any IPchain-to-Netfilter migration utilities? I must admit, I haven't been able to find much information about Netfilter usage either when I went looking into 2.4, however my firewall is also still 2.2. Time to upgrade, methinks.
This is a helpful page, as is this one. There probably isn't a tool to convert from one to the other, but Firestarter is handy to create firewalls. Any more questions?
(PS. posting first is irrelevant in these quiet sections.)
None are more hopelessly enslaved than those who falsely believe they are free. Johann Wolfgang von Goethe.
I have not been able to find a HOWTO for Netfilters!
There is a HOWTO for netfilter. It's at http://netfilter.samba.org/unreliable-guides/, and it's called the Linux 2.4 Packet Filtering HOWTO. Also look at the Linux 2.4 NAT HOWTO while you're there.
Does my bum look big in this?
Simply hitting Google and entering "netfilter howto" ?
All of the top 5 hits are directly relevant, and 2 of them are to the "Linux 2.4 packet filtering howto" and the "Linux 2.4 NAT howto"
*sigh* Another day, another totally unresearched "ask slashdot". You'd think the editors would bother spending 2 minutes checking if the question is trivial.
Directly converting your ipchains rulesets to ipchains isn't such a good
idea. Iptables/netfilter is *much* more flexible, and chances are, you
can cut your ruleset in half *with* added security. Personaly, I find
it's stateful features, and ability to match "related" packets quite
useful. My firewall machine used to run 2.2/ipchains, and my ruleset was
about 60 lines long, with iptables/netfilter it is less than 20, and is
much easier to maintain.
In order to avoid psychological problems and other traumatisms, US Authorities have decided to ban the word 'Down' due to mottos like 'another plane down'.
Unfortunately, the key 'Page Down' has been removed from all keyboards in united states and moreover, users cannot 'Scroll Down'.
As the link to the HOWTO is not at hte top of the netfilter homepage, it is not possible for users in the US to reach it.
#include "coucou.h"
In the Howto's only the basics are mentioned.
In the manpage, lots of options are explained.
For examples you will want to search freshmeat.net.
A few of my bookmarks:
http://www.lysator.liu.se
http://64.39.18.129
http://www.linuxsecurity.com
And some example scripts you might not find on freshmeat.net:
http://nerdfest.org
http://chaosmongers.org
Well, don't worry about that. We can get you back before you leave. (Dr. Who)
1. IP-Masquerading HOWTO is the promary source of information, not IP-Chains HOWTO.
2. Netfilter emulates ipchains and ipfwadm. There is no need to rewrite the rules.
This months SysAdmin magazine has an article on Netfilter. Link to article
What I did is simply use the ipchains support that is present in the 2.4 kernel, and use my existing ruleset. Works like a charm. When I feel the need, THEN I can rewrite it specifically for iptables. But for now, why bother?
I struggled with the conversion too and on a fluke I tried `man iptables`. There are diference but from the admin's point of view it's mostly syntax.
Here is what I suggest: Get a list of your ipchains, preferablye the command lines. Then view/print the iptables man page then one by one write the new iptables command lines. It isn't that hard and you'll learn a bit.
Get the bastille firewall toolkit. You can configure your rules by editing one very well documented file, and it can generate the rulesets for IPChains or IPTables (depending on your kernel version). It's available at:
http://www.tux.org/~peterw/#fwall
I've used it for IPChains and then migrated right to IPTables - it does a great job, IMO (well, none of the systems I've configured it on have been hacked, so I suppose that's a good sign). You may still want to review the rules once it's complete, but it's an excellent starting point
... but where's the negative side to all this? The one that makes you say conversion is a bad idea?
Slightly OT, since I didn't upgrade, but rolled a new firewall into service. gShield is very nice for configuring your ruleset. It uses a configuration file that is very easy to read, and very well commented.
--
"Outlook not so good." That magic 8-ball knows everything! I'll ask about Exchange Server next.
iptables -L will list the tables in the default chain. Then there is iptables -L -t nat and iptables -l -t mangle
The best guide I found was http://netfilter.filewatcher.org/unreliable-guides /packet-filtering-HOWTO/index.html
This explains how packet travers the filters which I though was easier than ipchains to learn. It also talks about using the ipchains module in 2.4 which means you can upgrade you kernel and keep your old firewall rules. It also goes over some of the basic options. This guide is mainly geared for using ip masquarading or now know as nat, but it is a great place to start. Also pick up a copy of last months Linux journal as they had an article on iptables.
However I must warn you that once you go to iptables you may find it difficult to want to ever think of ipchains again. I know I do.
Only 'flamers' flame!
http://www.linuxguruz.org/iptables/
Fedor G. Pikus, a member of the Portland Linux Unix Group, gave an excellent presentation on 1 Nov that's basically a detailed, step-by-step guide to creating an iptables-based firewall.
The slides are available on his site.
--Bruce
There are 10 kinds of people in the world: those who understand binary, and those who don't.
I've heard rumors that with Netfilter you can have a firewall+NAT that allows external people to FTP in? Is that true? Something about stateless? I know this is possible with ipfilter but it is a pain in the ass. Would this also allow other programs that need to get in from the outside like certain instant messenger clients work?
That's the kind of stuff that is interesting...
Bastille Linux's Webpage has a nice 2.4 Netfilter Firewalling document... I also used this GUI which can create rulesets for ipchains and iptables/netfilter. And, yes, if you upgrade your kernel to 2.4, netfilter can still read your ipchains rulesets, so its not necessary to immediately rewrite your rulesets for ipchains/netfilter.
Slight mistake - should read: