- 论坛徽章:
- 0
|
我的系统是rh9,选择全部安装,已经有源码了,命令uname-r显示:2.4.20-8 安装如下步骤进行:
获取最新iptables :wget http://www.netfilter.org/files/iptables-1.3.1.tar.bz2
解压:tar xjvf iptables-1.3.1.tar.bz2
获取最新patch-o-matic-ng的地址:ftp://ftp.netfilter.org/pub/patch-o-matic-ng/snapshot/
[root@kindgeorge src] wget ftp://ftp.netfilter.org/pub/patc ... ng-20050918.tar.bz2
解压: tar xjvf patch-o-matic-ng-20050918.tar.bz2
在下面操作之前可以把源码先保存一下
cd /usr/src
ls -al
scp -rp linux-2.4.20-8 kernel
(一).处理内核源码.
1. [root@kindgeorge src]# cd /usr/src/linux-2.4
2. [root@kindgeorge linux-2.4]# vi Makefile,
VERSION = 2
PATCHLEVEL = 4
SUBLEVEL = 20
EXTRAVERSION = -8custom
将“EXTRAVERSION = -8custom”改为“EXTRAVERSION = -8”
即:
VERSION = 2
PATCHLEVEL = 4
SUBLEVEL = 20
EXTRAVERSION = -8
3. [root@kindgeorge linux-2.4]# make mrproper
4. [root@kindgeorge linux-2.4]# make menuconfig ,什么都不做,直接保存退出.
为了生成.config 文件,否则以后会有问题
给netfilter打补丁
cd /usr/src/patch-o-matic-ng-20050918
KERNEL_DIR=/usr/src/linux-2.4 IPTABLES_DIR=/usr/src/iptables-1.3.1 ./runme string
执行后,会测试是否已经应用和提示你是否应用该模块,按"y"应用.然后继续下一个,默认是N
KERNEL_DIR=/usr/src/linux-2.4 IPTABLES_DIR=/usr/src/iptables-1.3.1 ./runme time
KERNEL_DIR=/usr/src/linux-2.4 IPTABLES_DIR=/usr/src/iptables-1.3.1 ./runme iprange
KERNEL_DIR=/usr/src/linux-2.4 IPTABLES_DIR=/usr/src/iptables-1.3.1 ./runme ipp2p
上面全部完成后,
cd /usr/src/linux-2.4
make menuconfig,确认
选择 code maturity level options->
*Prompt for development and/or incomplete code/drivers要选中
然后进入Networking options
再进入IP:Netfilter Configuration,会看到增加很多模块,每个新增的后面都会出现"NEW",把其想要的选中为模块"M"
保存、退出,至此,给netfilter打补丁工作完成
(三).编译netfilter模块
1.这里只需要编译netfilter,不需要编译整个内核和模块.这里我只需要ipv4的,ipv6我还没用到,所以不管了
cd /usr/src/linux-2.4
head -n4 Makefile
确认信息和uname -r 的版本一致,否则编译的模块不能被现有内核使用
make dep
make modules SUBDIRS=net/ipv4/netfilter
2.建立一个新目录备份原来模块,以防万一:
mkdir /usr/src/netfilter
cp /lib/modules/2.4.20-8/kernel/net/ipv4/netfilter/*.o??/usr/src/netfilter/
3.应用新的模块
cp -f /usr/src/linux-2.4/net/ipv4/netfilter/*.o /lib/modules/2.4.20-8/kernel/net/ipv4/netfilter/
4.更新你的modules.dep
depmod -a
当出现这个时,可以不用理会,因为ipchains, ipfwadm模块都没用,也可以把出错的删除.
depmod: *** Unresolved symbols in /lib/modules/2.4.20-8/kernel/net/ipv4/netfilter/ipchains_core.o
depmod: *** Unresolved symbols in /lib/modules/2.4.20-8/kernel/net/ipv4/netfilter/ipfwadm_core.o
rm -rf /lib/modules/2.4.20-8/kernel/net/ipv4/netfilter/ipchains_core.o
rm -rf /lib/modules/2.4.20-8/kernel/net/ipv4/netfilter/ipfwadm_core.o
depmod -a 再次执行后将会出现如下显示
depmod: *** Unresolved symbols in /lib/modules/2.4.20-8/kernel/net/ipv4/netfilter/ip_fw_compat.o
rm -rf /lib/modules/2.4.20-8/kernel/net/ipv4/netfilter/ip_fw_compat.o
再次执行depmod -a 直到没有错误提示。
(四).编译安装新的iptables
解压后有目录iptables-1.3.1
cd /usr/src/iptables-1.3.1
export KERNEL_DIR=/usr/src/linux-2.4
export IPTABLES_DIR=/usr/src/iptables-1.3.1
make BINDIR=/sbin LIBDIR=/lib MANDIR=/usr/share/man install
iptables -V 显示版本信息
三.安装完成,测试及应用
iptables -A FORWARD -m iprange --src-range 192.168.1.5-192.168.1.124 -j ACCEPT
iptables -A OUTPUT -m time --timestart 8:00 --timestop 18:00 -j ACCEPT
iptables -A FORWARD -m string --string "sex" -j DROP
iptables -A FORWARD -m ipp2p --edk --bit -j DROP
iptables -nL
正常,用命令iptables -L显示iptables-1.3.1 |
|