Chinaunix首页 | 论坛 | 博客
  • 博客访问: 88058
  • 博文数量: 8
  • 博客积分: 1591
  • 博客等级: 上尉
  • 技术积分: 380
  • 用 户 组: 普通用户
  • 注册时间: 2005-10-19 19:55
文章分类
文章存档

2011年(1)

2008年(7)

我的朋友
最近访客

分类: LINUX

2008-03-16 22:42:26

FC4源码下载地址:

然后用#rpmbuild  -bp --target $(uname -m) /usr/src/redhat/SPEC/iptables.spec  用于创建iptables源码

kernel源码也同样创建。然后修改内核源码的Makefile,修改成和uname -r一致

[code]VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 11
EXTRAVERSION = -1.1369_FC4
[/code]

下载connlimit模块补丁

wget

解压后打入补丁## KERNEL_DIR=/usr/src/linux IPTABLES_DIR=/usr/src/iptables ./runme connlimit

然后make menuconfig选择上新增的Connections/IP limit match support模块,保存退出。

[code]make menuconfig 出現下列錯誤

...
In file included from scripts/kconfig/lxdialog/checklist.c:24:
scripts/kconfig/lxdialog/dialog.h:31:20: error: curses.h: No such file or directory
In file included from scripts/kconfig/lxdialog/checklist.c:24:
scripts/kconfig/lxdialog/dialog.h:128: error: syntax error before 'use_colors'
scripts/kconfig/lxdialog/dialog.h:128: warning: type defaults to 'int' in declaration of 'use_colors'
scripts/kconfig/lxdialog/dialog.h:128: warning: data definition has no type or storage class
scripts/kconfig/lxdialog/dialog.h:129: error: syntax error before 'use_shadow'
...


原因為缺少 ncurses devel 套件 (name "libncurses5-dev" in Ubuntu),安裝後即可
$ sudo apt-get install libncurses5-dev

如果是FC系列,是安装yum -y install ncurses-devel[/code]

make modules_prepare
make M=net/ipv4/netfilter
然后会生成ipt_connlimit.ko文件,chmod +x ipt_connlimit.ko
然后拷贝到/lib/modules/相对应的iptables目录模块下。
 
限制每个IP最多10个连接。
#iptables -A INPUT -p tcp -m connlimit --connlimit-above 10 -j REJECT
 
[quote]
前面提到connlimit补丁是针对2.6.11以后的内核版本涉及的,若直接编译会失败,所以我们必须先修改一下ipt_connlimit.c的部分代码。
补丁下载:
打补丁:

# cd /usr/src/linux-2.6.9-42.7AX/net/ipv4/netfilter
# bzip2 -dc /root/iptable_update/ipt_connlimit_by_qk.patch.bz2 |patch -p1
patching file ipt_connlimit.c
[/quote]
阅读(1354) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~