Jun 2

[原]编译IMQ(中介队列设备)模块 雷阵雨

linuxing , 14:33 , 基础知识 » RPM , 评论(0) , 引用(0) , 阅读(55258) , Via 本站原创 | |

三、为iptables增加IMQ支持
激活IMQ设备后,需要由iptables对数据包打上标记,所以还需要让iptables增加IMQ支持。
1、准备工作
iptables的Makefile默认使用/usr/src/linux作为核心源码目录,为方便,做个软链接:

# cd /usr/src
# ln -s linux-2.6.9-42.7AX/ linux

把下面文件这几行注释掉:
引用
# vi /usr/src/linux/include/linux/config.h
//#if !defined (__KERNEL__) && !defined(__KERNGLUE__)
//#error including kernel header in userspace; use the glibc headers instead!
//#endif

否则在编译的时候,会报错退出的。
2、编译iptables
为保持与原系统的兼容性,这里以DC Server带的1.2.11版本进行说明,使用iptables-1.2.11-3.1.RHEL4.src.rpm源码包,最终生成rpm文件。

# rpm -ivh iptables-1.2.11-3.1.RHEL4.src.rpm

拷贝补丁:

# cd /usr/src/asianux/SOURCES/
# cp /root/iptables-1.2.9-imq1.diff ./iptables-1.2.9-imq1.patch

修改spec文件:
引用
# cd ../SPECS
# vi iptables.spec
在适当的地方加入:
Patch10: iptables-1.2.9-imq1.patch
%prep
# IMQ support
%patch10 -p1
chmod +x ./extensions/.IMQ-test*
以及修改所有KERNEL_DIR=/usr,为KERNEL_DIR=/usr/src/linux,即:
make COPT_FLAGS="$OPT" KERNEL_DIR=/usr/src/linux LIBDIR=/%{_lib}
make COPT_FLAGS="$OPT" KERNEL_DIR=/usr/src/linux LIBDIR=/%{_lib} iptables-save iptables-restore
make COPT_FLAGS="$OPT" KERNEL_DIR=/usr/src/linux LIBDIR=/%{_lib} ip6tables-save ip6tables-restore

然后编译及安装:

# rpmbuild -bb iptables.spec
# rpm -Uvh ../RPMS/i386/iptables-* --force

这方式适用于对现有iptables扩展模块,也可参考附录中给iptables添加模块的方法编译。

修改后的spec文件下载:

※实际上,修改spec的操作是实现了下面的工作:
引用
cd /iptables源码
patch -p1 <../../iptables-1.2.9-imq1.diff  #打补丁
chmod +x extensions/.IMQ-test*  #激活IMQ模块
make KERNEL_DIR=/linux核心源码路径  #必须指向已打上IMQ补丁的kernel源码路径
cp extensions/*IMQ* /lib/iptables/  #拷贝IMQ模块到系统适当的位置
chmod +x /lib/iptables/*IMQ*
内文分页: [1] [2] [3]
Tags: , , , ,
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]