红联Linux门户
Linux帮助

在FC Linux4操作系统中给iptables打补丁的具体方法

发布时间:2006-12-09 15:24:30来源:红联作者:sindex
=======================================================================================================

1.安装FC4的时候把把编辑工具选上

=======================================================================================================

2.在http://www.kernel.org/pub/linux/kernel/v2.6/下载linux-2.6.11.1.tar.bz2内核
http://ftp.netfilter.org/pub/iptables/下载iptables-1.3.3.tar.bz2
http://ftp.netfilter.org/pub/patch-o-matic-ng/snapshot/下载patch-o-matic-ng-20060206.tar.bz2

cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.11.1.tar.bz2
wget http://ftp.netfilter.org/pub/iptables/iptables-1.3.3.tar.bz2
wget http://ftp.netfilter.org/pub/patch-o-matic-ng/snapshot/patch-o-matic-ng-20060206.tar.bz2

=======================================================================================================

3.解压他们

cd /usr/src
tar -jxvf linux-2.6.11.1.tar.bz2 && tar -jxvf iptables-1.3.3.tar.bz2 && tar -jxvf patch-o-matic-ng-20060206.tar.bz2

=======================================================================================================

4.先删除(因为原来的内核代码有问题)

rm -rf /usr/src/kernels/2.6.11-1.1369_FC4-i686
mv /usr/src/linux-2.6.11.1 /usr/src/2.6.11-1.1369_FC4-i686

=======================================================================================================

5.删除无用的*.o和*.ko修改Makefile,建立软连接

cd /usr/src
ln -s /usr/src/kernels/2.6.11-1.1369_FC4-i686 linux
cd /usr/src/linux
uname -r
make mrproper
make menuconfig (什么都不做,保存退出)

修改Makefile文件

vi Makefile
______________________________
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 11
EXTRAVERSION = -1

修改成

VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 11
EXTRAVERSION = -1.1369_FC4
______________________________

=======================================================================================================

6.给内核打补丁

cd /usr/src/patch-o-matic-ng-20060206

KERNEL_DIR=/usr/src/linux IPTABLES_DIR=/usr/src/iptables-1.3.3 ./runme comment
KERNEL_DIR=/usr/src/linux IPTABLES_DIR=/usr/src/iptables-1.3.3 ./runme connlimit
KERNEL_DIR=/usr/src/linux IPTABLES_DIR=/usr/src/iptables-1.3.3 ./runme iprange
KERNEL_DIR=/usr/src/linux IPTABLES_DIR=/usr/src/iptables-1.3.3 ./runme geoip
KERNEL_DIR=/usr/src/linux IPTABLES_DIR=/usr/src/iptables-1.3.3 ./runme nth
KERNEL_DIR=/usr/src/linux IPTABLES_DIR=/usr/src/iptables-1.3.3 ./runme ipp2p
KERNEL_DIR=/usr/src/linux IPTABLES_DIR=/usr/src/iptables-1.3.3 ./runme quota
KERNEL_DIR=/usr/src/linux IPTABLES_DIR=/usr/src/iptables-1.3.3 ./runme time(好像也有点问题,如果要编辑成模块的话就不成功,在2.4内核上没又这个问题)
KERNEL_DIR=/usr/src/linux IPTABLES_DIR=/usr/src/iptables-1.3.3 ./runme string(有问题)

也可以用
KERNEL_DIR=/usr/src/linux IPTABLES_DIR=/usr/src/iptables-1.3.3 ./runme base
KERNEL_DIR=/usr/src/linux IPTABLES_DIR=/usr/src/iptables-1.3.3 ./runme extra
建议不要把所有的模块都打上,只选择你有用的模块

=======================================================================================================

7.编辑模块

cd /usr/src/linux
make menuconfig
选择 Code maturity level options --->
Prompt for development and/or incomplete code/drivers

Select only drivers expected to compile cleanly

在这里选择你要用的模块:

Device Drivers --->Networking support --->Networking options --->
Network packet filtering (replaces ipchains) --->IP: Netfilter Configuration --->

编辑完,保存退出

make modules_prepare
make M=net/ipv4/netfilter
cp /usr/src/linux/net/ipv4/netfilter/*.ko /lib/modules/2.6.11-1.1369_FC4/kernel/net/ipv4/netfilter
depmod -a

=======================================================================================================

8.安装iptables-1.3.3

cd /usr/src/iptables
export KERNEL_DIR=/usr/src/linux
export IPTABLES_DIR=/usr/src/iptables-1.3.3
make BINDIR=/sbin LIBDIR=/lib MANDIR=/usr/share/man install

=======================================================================================================

9.所有的工作都完成了,现在开始你的测试了

iptables -V
iptables -m 模块名字 --help

=======================================================================================================

10.更新ipp2p模块,使他支持更多的协议

http://www.ipp2p.org/downloads/下载ipp2p-0.8.1_rc1.tar.gz

cd /usr/src
wget http://www.ipp2p.org/downloads/ipp2p-0.8.1_rc1.tar.gz
tar -zxvf ipp2p-0.8.1_rc1.tar.gz
cd /usr/src/ipp2p-0.8.1_rc1

修改Makefile文件,应该在第36行
vi Makefile
_____________________________________________

IPTABLES_SRC = /usr/src/iptables-1.2.9
改为
IPTABLES_SRC = /usr/src/iptables-1.3.3
_________________________________________

make
cp /usr/src/ipp2p-0.8.1_rc1/libipt_ipp2p.so /lib/iptables
depmod -a

iptables -m ipp2p --help
已经为0.8.1_rc1了
iptables -A FORWARD -m ipp2p --ipp2p -j DROP
iptables -t mangle -m ipp2p --ipp2p -j MARK --set-mark 1
文章评论

共有 0 条评论