iptables学习笔记之编译内核和iptables及安装l7proto


            编译内核和iptables及安装l7proto

一、环境介绍

操作系统:Redhat5.8_64bit

需要软件包:

linux-2.6.28.10.tar.gz

netfilter-layer7-v2.22.tar.gz

l7-protocols-2009-05-28.tar.gz

iptables-1.4.6.tar.bz2

安装步骤:

1)、给内核打补丁,并重新编译内核

2)、给iptables源码打补丁,并重新编译iptables

3)、安装l7proto

1、给内核打补丁并重新编译内核

[[email protected] ~]# uname -r   //Redhat5.8自带内核版本是2.6.18

2.6.18-308.el5

# tar zxvf  linux-2.6.28.10.tar.gz  -C  /usr/src   //解压linux-2.6.28

# tar zxvf netfilter-layer7-v2.22.tar.gz -C /usr/src  //解压netfilter-layer7

# cd /usr/src/

# ln -s linux-2.6.28 linux

# cd /usr/src/linux/

# patch -p1 < ../netfilter-layer7-v2.22/kernel-2.6.25-2.6.28-layer7-2.22.patch

patching file net/netfilter/Kconfig

patching file net/netfilter/Makefile

patching file net/netfilter/xt_layer7.c

patching file net/netfilter/regexp/regexp.c

patching file net/netfilter/regexp/regexp.h

patching file net/netfilter/regexp/regmagic.h

patching file net/netfilter/regexp/regsub.c

patching file net/netfilter/nf_conntrack_core.c

patching file net/netfilter/nf_conntrack_standalone.c

patching file include/net/netfilter/nf_conntrack.h

patching file include/linux/netfilter/xt_layer7.h

# cp /boot/config-2.6.18-308.el5 /usr/src/linux/.config

# make  menuconfig

提示:make  menuconfig之前确保下面开发环境安装好了:

Development Libraries

Development Tools

执行:make menuconfig如下错误提示:

scripts/kconfig/mconf arch/x86/Kconfig

.config:1365:warning: symbol value ‘m‘ invalid for FIXED_PHY

.config:1671:warning: symbol value ‘m‘ invalid for ISDN

.config:2789:warning: symbol value ‘m‘ invalid for RTC_INTF_SYSFS

.config:2790:warning: symbol value ‘m‘ invalid for RTC_INTF_PROC

.config:2791:warning: symbol value ‘m‘ invalid for RTC_INTF_DEV

.config:2813:warning: symbol value ‘m‘ invalid for DMA_ENGINE

Your display is too small to run Menuconfig!

It must be at least 19 lines by 80 columns.

make[1]: *** [menuconfig] Error 1

make: *** [menuconfig] Error 2

原因:终端窗口大小了,导致的。


General setup  ---> ()Local version - append to kernel release -->输入:-layer7 -->OK --> Exit

Processor type and features  ---> Processor family (Generic-x86-64)  ---> (X) Core 2/newer Xeon

Networking support → Networking Options →Network packet filtering framework →Core Netfilter Configuration

<M>  Netfilter connection tracking support

<M>  “layer7” match support

<M>  “string” match support

<M>  “time”  match support

<M>  “iprange”  match support

<M>  FTP protocol support

<M>   Connection tracking netlink interface

<M>  “connlimit”  match support

<M>  “state”  match support

<M>  “conntrack”  connection  match support

<M>  “mac”  address  match support

<M>   "multiport" Multiple port match support


Networking support → Networking Options →Network packet filtering framework → IP: Netfilter Configuration

<M> IPv4 connection tracking support (required for NAT)

<M>   Full NAT

<M>     MASQUERADE target support

<M>     NETMAP target support

<M>     REDIRECT target support

# screen  //防止make时候中断

# make

# make modules_install

# make install

2、编译新版本iptables

# cp /etc/init.d/iptables ~/iptables

# cp /etc/sysconfig/iptables-config ~/

# cp /etc/sysconfig/iptables ~/iptables.rules

# service iptables stop

# chkconfig iptables off

# rpm  -e  iptables-ipv6  iptables  iptstate  --nodeps

# tar jxvf iptables-1.4.6.tar.bz2 –C  /usr/src

# cd /usr/src/iptables-1.4.6

# cp ../netfilter-layer7-v2.22/iptables-1.4.3forward-for-kernel-2.6.20forward/libxt_layer7.*   ./extensions/

# ./configure  --prefix=/usr  --with-ksource=/usr/src/linux

# make

# make install

# which iptables

/usr/sbin/iptables

# vim ~/iptables  -->修改如下内容

if [ ! -x /usr/sbin/$IPTABLES ]; then

echo -n $"/usr/sbin/$IPTABLES does not exist."; warning; echo

exit 0

fi

# cp ~/iptables  /etc/init.d/

# chkconfig --add iptables

# cp ~/iptables-configs /etc/sysconfig/

# service iptables start

Applying iptables firewall rules:                          [  OK  ]

Loading additional iptables modules: ip_nat_ftp ip_conntrac[  OK  ]

3、安装l7-protocols

# tar zxvf l7-protocols-2009-05-28.tar.gz

# cd l7-protocols-2009-05-28

# make install

mkdir -p /etc/l7-protocols

cp -R * /etc/l7-protocols

# service iptables restart


时间: 2024-08-24 01:56:54

iptables学习笔记之编译内核和iptables及安装l7proto的相关文章

linux之iptables学习笔记

iptables原理: firewall:防火墙,是一种隔离工具,工作于主机或网络的边缘,对于进出本机或本网络的报文根据事先定义好的检查规则做匹配检测,对于能够被规则所匹配到的报文做出相应处理的组件,因此根据其作用的范围分为两类: 主机防火墙:对进出本主机的数据包进行规制匹配,并作出相应的处理动作. 网络防火墙:对流经本网络的数据包进行规制匹配,并作出相应的处理动作,工作在网络出口处,一般作为网关防火墙. 注意:防火墙规则匹配顺序机制:自上而下,对于中间匹配到的规则则按规则规定的处理动作进行处理

编译内核启用iptables及netfilter

在Network Packet Filtering Framework(Netfilter)一节中还有两个额外的配置节--Core Netfilter Configuration(核心Netfilter配置)和IP:Netfilter Configuration(IP:Netfilter配置). 1. 核心Netfilter配置 核心Netfilter配置节中包含的一些重要选项都应该被启用: l    Comment match support(comment匹配支持): l    FTP su

Linux学习笔记&lt;十八&gt;——内核编译

内核由核心和内核模块两部分组成 核心:/boot/vmlinuz-version 内核模块(ko):/lib/modules/version/ 查看内核版本 uname -r 主版本号.次版本号(偶数表示稳定版本,奇数表示测试版本).修订版本号(修订的次数) 用户空间访问.监控内核是通过访问修改/proc,/sys目录下的文件(即设定内核的参数值)实现的 /proc/sys:此目录中的文件很多是可读写的 /sys:某些文件可写 设定内核参数值的方法: 1.echo VALUE > /proc/s

(转)redis 学习笔记(1)-编译、启动、停止

redis 学习笔记(1)-编译.启动.停止 一.下载.编译 redis是以源码方式发行的,先下载源码,然后在linux下编译 1.1 http://www.redis.io/download 先到这里下载Stable稳定版,目前最新版本是2.8.17 1.2 上传到linux,然后运行以下命令解压 tar xzf redis-2.8.17.tar.gz 1.3 编译 cd redis-2.8.17make 注:make命令需要linux上安装gcc,若机器上未安装gcc,redhat环境下,如

DuiLib学习笔记1——编译运行demo

c++中皮肤问题比较麻烦,MFC自带的太难用.DirectUI界面库就比较强大了,之前像skin++之类的基于DirectUI收费昂贵.DuiLib是基于DirectUI的界面库,可以将用户界面和处理逻辑彻底分离,极大地提高用户界面的开发效率. duilib的SVN地址:http://duilib.googlecode.com/svn/trunk 下载后运行DuiLib.sln 编译时可能会遇到几个报错. 0.开发环境本身有问题,比如用win7没有装win7sdk之类的. 1. TestApp1

【学习笔记】编译原理-有限自己主动机

一.定义: 不确定的有限自己主动机(NFA): 一种数学模型 (1) 一个有限的状态集合S (2) 一个输入符号集合∑(不包括ε) (3) 一个转换函数move: S X (∑ U {ε}) -> P(S) (4) 状态s0是唯一的開始状态 (5) 状态集合F是接受状态集合,S包括F 确定的有限自己主动机(DFA): 是NFA的特殊情况 (1) 不论什么状态都没有ε转换 (2) 对于不论什么状态s和不论什么输入符号a,最多仅仅有一条标记为a的边离开,即转换函数move: S X ∑-> S能够

【学习笔记】编译原理-有限自动机

一.定义: 不确定的有限自动机(NFA): 一种数学模型 (1) 一个有限的状态集合S (2) 一个输入符号集合∑(不包含ε) (3) 一个转换函数move: S X (∑ U {ε}) -> P(S) (4) 状态s0是唯一的开始状态 (5) 状态集合F是接受状态集合,S包含F 确定的有限自动机(DFA): 是NFA的特殊情况 (1) 任何状态都没有ε转换 (2) 对于任何状态s和任何输入符号a,最多只有一条标记为a的边离开,即转换函数move: S X ∑-> S可以是一个部分函数. 二.

gcc 学习笔记(一) - 编译C程序 及 编译过程

一. C程序编译过程 编译过程简介 : C语言的源文件 编译成 可执行文件需要四个步骤, 预处理 (Preprocessing) 扩展宏, 编译 (compilation) 得到汇编语言, 汇编 (assembly) 得到机器码, 连接 (linking) 得到可执行文件; -- 查看每个步骤的编译细节 : "-E" 对应 预处理, "-S" 对应 编译, "-c" 对应 汇编, "-O" 对应 连接; -- 每个步骤对应的工

NFC学习笔记——三(在windows操作系统上安装libnfc)

本篇翻译文章: 这篇文章主要是说明如何在windows操作系统上安装.配置和使用libnfc. 一.基本信息 1.操作系统: Windows Vista Home Premium SP 2 2.硬件信息: System: Dell Inspiron 1720 Processor: Intel Core 2 Duo CPU T9300 @ 2.5GHz 2.5GHz System type: 32-bit Operating System 3.所需软件: 在windows操作系统上安装软件需要下列