需要下载内核源码

linux-2.6.18.tar.bz2

iptables源码

iptables-1.3.5.tar.bz2

内核补丁

patch-o-matic-ng-20080214.tar.bz2

把源码包解压到/usr/src 下

#cd /usr/src

#tar xvfj linux-2.6.18.tar.bz2

#tar xvfj iptables-1.3.5.tar.bz2

#tar xvfj patch-o-matic-ng-20080214.tar.bz2

为了方便,做软连接

#ln -s linux-2.6.18 linux

#ln -s iptables-1.3.5 iptables

更改内核源码Makefile 文件

#vim /usr/src/linux/Makefile

EXTRAVERSION = (当然内核版本)

#cd /usr/src/linux

#make menuconfig

退出(什么也不做。生成.config 文件)

#cd ../patch-o-matic-ng-20080214

#./runme --download

#./runme time

默认回车,提示添加模块按y

#cd /usr/src/linux

#make menuconfig

Networking ----Networking options ----Network packet filtering (replaces ipchains)------Core Netfiler Configuration

Time match support 选中 M

#make modules
HOSTCC scripts/basic/fixdep

  HOSTCC scripts/basic/split-include

  HOSTCC scripts/basic/docproc

  HOSTCC scripts/conmakehash

  HOSTCC scripts/kallsyms

  CC scripts/empty.o

  HOSTCC scripts/mk_elfconfig

  MKELF scripts/elfconfig.h

  HOSTCC scripts/file2alias.o

  HOSTCC scripts/modpost.o

  HOSTCC scripts/sumversion.o

  HOSTLD scripts/modpost

  HOSTCC scripts/pnmtologo

  HOSTCC scripts/bin2c

到这步就可以ctrl +c 终止了

#make modules SUBDIRS=net/ipv4/netfilter
#chmod +x /usr/src/linux/net/ipv4/netfilter/ipt_time.ko

#cp /usr/src/linux/net/ipv4/netfilter/ipt_time.ko /lib/modules/2.6.18-238.el5/kernel/net/ipv4/netfilter/
#depmod -a

编译iptables

#cd /usr/src/iptables

#make KERNEL_DIR=/usr/src/linux
#make install KERNEL_DIR=/usr/src/linux

#cp /usr/src/iptables/extensions/libipt_time.so /lib/iptables

测试

iptables -m time --help