Chinaunix首页 | 论坛 | 博客
  • 博客访问: 108109
  • 博文数量: 21
  • 博客积分: 1657
  • 博客等级: 上尉
  • 技术积分: 245
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-10 16:20
文章分类

全部博文(21)

文章存档

2017年(1)

2014年(3)

2013年(1)

2012年(1)

2011年(9)

2010年(1)

2009年(1)

2008年(3)

2006年(1)

分类: LINUX

2009-11-13 17:15:26

rpm -qa|grep iptables 查看版本,再下载这个版本的源代码

wget

tar xjf pathc-o-matic-ng-20091112.tar.bz2

path/iptables-src

#cd path/patch-o-matic-ng-20091112
#./runme --download

内核源代码 /usr/src/kernel/{uname -r 版本号}
iptables源代码 /path/iptables-src

#./runme connlimit

开始编译模块:
#cd /usr/src/kernels/{uname -r 版本号}
#make oldconfig

提示新加入了connlimit的选项,问是否需要编译进入内核的时候,输入“m”,编译为模块。
#make modules_prepare
#mv net/ipv4/netfilter/Makefile net/ipv4/netfilter/Makefile.orig      ####备份原来的Makefile,里面包含了原始的编译信息,直接编译会无法通过。

创建新的Makefile
#vi net/ipv4/netfilter/Makefile
obj-m := ipt_connlimit.o

KDIR := /lib/modules/$(shell uname -r)/build
PWD   := $(shell pwd)

default:
    $(MAKE) -C $(KDIR) M=$(PWD) modules

然后编译该模块:
#make M=net/ipv4/netfilter/

将生成的ko模块copy到目标地址,并设置权限
#cp net/ipv4/netfilter/ipt_connlimit.ko /lib/modules/{uname -a 版本号}/kernel/net/ipv4/netfilter/
#chmod 744 /lib/modules/{uname -r 版本号}/kernel/net/ipv4/netfilter/ipt_connlimit.ko

到这里,模块编译完成。

测试并应用新的模块
用depmod –a 测试connlimit模块是否兼容
# depmod –a
加载connlimit模块
#modprobe ipt_connlimit
# lsmod |grep ip

/sbin/iptables -A INPUT -i eth0 -p tcp --tcp-flags SYN,RST,ACK SYN -m connlimit --connlimit-above 19 -j REJECT


阅读(1685) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~