Help - Search - Members - Calendar
Full Version: getting iptables working under debian
The Planet Forums > Operating Systems > Others
Lukey48911
I just thought I would share this info on how to get iptables working under Debian.

Just for reference, the kernel I built using these procedures was with the following hardware configuration:

CODE
Dell  1600SC Dual Xeon MB  DAT54AMB8C2

Intel  P4 Xeon 2.4Ghz  533mhz FSB Socket604

Transcend  1GB  DDR266 ECC Registered

Unknown  Onboard  IDE

Seagate  80GB:IDE:7200RPM Barracuda  ST380011a


Step 1:

Install wget.

CODE
apt-get install wget


Step 2:

Download the latest kernel sources from kernel.org. I'm not sure if the 2.6.X kernel releases will work with this little howto, so I would grab the latest 2.4.X release to ensure the kernel actually boots and is fully functional. The 2.6 kernels should work though but you are on your own in that case. icon_razz.gif The latest version right now is 2.4.30, so we would do:

CODE
cd /usr/src

wget http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.30.tar.gz

tar -xzvf linux-2.4.30.tar.gz

cd linux-2.4.30


Step 3:

Install the debian kernel building utils:

CODE
apt-get install kernel-package


Step 4:

Browse this site:

http://wiki.osuosl.org/display/LNX/Debian%...0Dell%20Servers

Notice it has a link to a kernel config with iptables enabled in the comments. Here's that link.

http://www.erikin.com/index/Docs/linux/deb.../kernel/.config

Make sure you are in the /usr/src/linux-2.4.30 directory and wget that file.

CODE
wget http://www.erikin.com/index/Docs/linux/debian/dell/1750/kernel/.config


Step 5:

Run make menuconfig:

CODE
make menuconfig


Go to Networking Options ---> IP: Netfilter Configuration --->

You should see that most of the options are set to be built as modules. Just what we need! icon_biggrin.gif I would suggest against changing anything in the kernel config unless you know exactly what you are doing or you'll leave yourself with a botched system.

Exit out of the kernel configuration. Save the kernel configuration when it asks.

NOTE: If you have the same system configuration you shouldn't need to change anything.

Step 6:

Run make-kpkg clean:

Lets just make sure everything is "tidy" for the kernel build:

CODE
make-kpkg clean



Step 7:

Build the kernel package:

CODE
make-kpkg kernel_image


Step 8:

Install the kernel package:

Assuming the kernel built, and there is no reason it shouldn't if you are following these instructions, there should be a new .deb package placed in /usr/src. Lets go install it!

CODE
cd /usr/src

dpkg -i kernel-image-2.4.30_10.00.Custom_i386.deb


If you are using a kernel revision other than 2.4.30 than the file may be named slightly different, ie 2.4.29, etc. If you are using the 2.4.30 kernel it should have that filename for the .deb package.

When you are installing, you'll be asked a few questions. You don't want to make a boot floppy, so say no to that. Also, if it asks to install to the boot block and run lilo (sorry, forget exactly what it says) say yes.

Step 9:

Verify that the kernel is installed correctly. Do the following:

CODE
ls -la /


Take notice of these lines:

CODE
lrwxrwxrwx    1 root     root           19 Apr 18 03:29 vmlinuz -> boot/vmlinuz-2.4.30

lrwxrwxrwx    1 root     root           25 Apr 18 01:45 vmlinuz.old -> boot/vmlinuz-2.4.26-bf2.4


vmlinuz.old can be booted with the LinuxOld entry in lilo when the server gets rebooted. It will default to the "Linux" lilo option though which is our new kernel.

Step 10:

Verify that our lilo.conf file isn't botched and rerun lilo.

Lets open /etc/lilo.conf. You can use vi or nano. I usually use nano myself though, so that's what this example shows. icon_razz.gif

CODE
lba32

boot=/dev/hda

root=/dev/hda3

install=/boot/boot.b

map=/boot/map

vga=normal

delay=100



image=/vmlinuz

       label=Linux

       read-only

       append = "console=ttyS0,9600n8"

image=/vmlinuz.old

       label=LinuxOLD

       read-only

       optional

       append = "console=ttyS0,9600n8"


NOTE: If you haven't cleaned up the lilo.conf file it is going to have a ton of comments in it. So, you are likely not to see anything remotely resembling the lilo.conf I use. lol

I wouldn't get into changing too many options if it doesn't look exactly the same. Just verify that the image=/vmlinuz and image=/vmlinuz.old are there. Take note that the append = "console=ttyS0,9600n8" is for the remote console access. Check out the Debian ROD/Remote Console How To for info on enabling that. If you haven't done that yet, do so now. icon_smile.gif

That should do it. Rerun lilo and reboot to use the new kernel.

CODE
lilo


Running lilo should show you the following if successful:

CODE
Added Linux *

Added LinuxOLD


Now you can reboot to use the new kernel with iptables support. Just type reboot in your console. I would definitely suggest having the rod/remote console working in case iptables ends up locking you out upon reboot

That should do it! You are on your own setting up iptables, but just make sure you allow the proper ip ranges in your firewall script so servermatrix/theplanet can monitor your server.
klaude
Thanks for this!

*post stickied*
Lukey48911
No problem. I'll build the kernel-headers, kernel-source, and kernel-image .deb packages and link them here. icon_smile.gif
Lukey48911
I put the deb packages at http://debian.littlelukey.com for anybody that wants them.
Guspaz
iptables is part of the linux kernel and is the linux routing/firewall/etc solution. Why would it not be in Debian? I don't understand. It's in kernels by default.

EDIT: 2000th post! 500 to go.
Lukey48911
The kernel "vmlinuz-2.4.26-bf2.4" that came with the ded. box didn't have the modules built in. I'm kind of assuming the Debian install was done with a debian installer like the one here: http://wiki.osuosl.org/display/LNX/Debian%...0Dell%20Servers If so they don't include iptables as a module or compiled into the kernel for some really odd reason. It really makes you wonder what was going through their head when they decided to do that...
chyne
And what about the 2.4.* kernel images included in Debian? Can you not just do:
CODE
apt-get install kernel-image-2.4

My deb servers all have iptables running, including the *conn_track* modules, and I normally install my kernels directly from official Debian packages.
Lukey48911
I tried that, even tried a couple kernels from backports.org. Each time I tried I had to open a reboot ticket and have them reboot it to the old kernel. From what they said the one time it complained about some driver and it would give a kernel panic. I wish it was as easy as installing with apt-get, but building my own kernel was the only way that worked flawlessly and would actually boot the server...plus be fully functional.
chyne
My recipe for remote reboots after kernel changes:

1. Keep the old kernel as the default (i.e. vmlinuz.old).
2. Put "panic=5" in the 'append=' line of lilo.conf (when the kernel panics, it will reboot after 5 seconds).
3. Run lilo to save your configuration.
4. Run lilo again, this time with the '-R LinuxNew' (this tells lilo to boot the new kernel on the next boot only, replace 'LinuxNew' with label of your new kernel).
5. Reboot.

Here's the sequence of events:

1. Lilo loads the new kernel (because of lilo -R LinuxNew, if it boots correctly, change lilo.conf to make the new kernel the default).
2. If the new kernel panics, the panic=5 should reboot it.
3. On the reboot, it should load the default kernel as specified in lilo.conf (lilo -R no longer in effect).
4. Now you're back in the old kernel, check syslog to see why the new kernel panic'd and adjust.

I've done this to servers in 4-5 DC over the years, and the only time I've ever had to call tech support after a kernel upgrade reboot was the one time here at SM where I chose not to follow my own advice (there was also an issue with the old kernel the e1000 driver not being loaded at boot, so I would have had problems either way).
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.