iptables移植到开发板
2015-04-17 15:31
676 查看
1、iptables的移植
到netfilter官方网站(http://www.netfilter.org/)下载iptables最新源码并解压,编译方法具体可以参考iptables目录下的INSTALL文件。
./configure –host=arm-linux-gnueabi –prefix=/home/iptables –enable-static –disable-shared –with-ksource=./../../linux-2.6.30/
make
make install
arm-linux-gnueabi-strip /home/iptables/sbin/xtables-multi
将指定目录下/home/ipables/sbin的可执行程序拷贝到开发板的/usr/sbin下
(拷贝的时候要注意,所有的命令都是软链接到xtables-multi,因此一般的拷贝cp会将整个复制一遍,导致整个工具变大,正确的做法①先压缩,拷贝压缩文件后解压,②直接拷贝xtables-multi,像iptables、iptables-save工具使用软链接sudo cp -s xtables-multi iptables-save直接创建)
-–host: 指定交叉编译工具,一般为arm-none-linux-gnueabi、arm-linux-gnueabihf、arm-linux等,具体要和目标板用的交叉编译工具对应。
–-prefix: 指定安装目录,编译后的文件会全部放在安装目录中。必须是绝对路径!
–-enable-static:使用静态编译。
–-disable-shared:禁止动态编译。
–-with-ksource:指定目标板的内核目录。如果不指定,可能会提示:/usr/sbin/iptables: line 1: syntax error: unexpected “)”错误。当然,因为这个是可选项,如果没有提示错误,也可以不加这一项
2、内核的配置
为了使用iptables工具,需要配置内核来支持该工具,其实iptables工具主要是调用到内核里面的netfilter代码功能。这次是采用编译进内核的方式,当然也可以使用编译成模块的方式。
配置如下:
Networking —->
Networking options —->
[*] Network packet filtering (replaces ipchains) —>
[*]Advanced netfilter configuration
Core Netfilter Configuration —>
<*> Netfilter connection tracking support
<*> Netfilter Xtables support (required for ip_tables)
<*>”iprange” address range match support
<*>”multiport” Multiple port match support
<*>”state” match support
IP: Netfilter Configuration —>
<*> IPV4 connection tracking (required for masq/NAT)
[*]proc/sysctl compatibility with old connection tracking
<*> IP tables support (required for filtering/masq/NAT)
<*> IP range match support
<*> Packet filtering
<*> REJECT target support
<*> raw table support(required for NOTRACK/TRACE)
<*> Full NAT
说明:
1)若是不清楚,可以全部选中。
Networking —>
Networking options —>
Network packet filtering (replaces ipchains) —>(mini2440的内核版本稍高,选项不是这样的,但大同小异)
Core Netfilter Configuration —> 可以全选为build in (*)也可以全选为modules(M)
IP: Netfilter Configuration —> 可以全选为build in(*) 也可以全选为modules(M)
2)如果在开发板上执行 iptable -L -n出现以下信息,那么就需要重新配置和编译内核:
iptables v1.4.2: can’t initialize iptables table `filter’: Table does not exist (do you need to insmod?)Perhaps iptables or your kernel needs to be upgraded.
3)串口一直打印nf_conntrack:table full, dropping packet错误
在开发板的/etc/sysctl.conf中添加如下
net.netfilter.nf_conntrack_max = 655350
net.netfilter.nf_conntrack_tcp_timeout_established = 1200
到netfilter官方网站(http://www.netfilter.org/)下载iptables最新源码并解压,编译方法具体可以参考iptables目录下的INSTALL文件。
./configure –host=arm-linux-gnueabi –prefix=/home/iptables –enable-static –disable-shared –with-ksource=./../../linux-2.6.30/
make
make install
arm-linux-gnueabi-strip /home/iptables/sbin/xtables-multi
将指定目录下/home/ipables/sbin的可执行程序拷贝到开发板的/usr/sbin下
(拷贝的时候要注意,所有的命令都是软链接到xtables-multi,因此一般的拷贝cp会将整个复制一遍,导致整个工具变大,正确的做法①先压缩,拷贝压缩文件后解压,②直接拷贝xtables-multi,像iptables、iptables-save工具使用软链接sudo cp -s xtables-multi iptables-save直接创建)
-–host: 指定交叉编译工具,一般为arm-none-linux-gnueabi、arm-linux-gnueabihf、arm-linux等,具体要和目标板用的交叉编译工具对应。
–-prefix: 指定安装目录,编译后的文件会全部放在安装目录中。必须是绝对路径!
–-enable-static:使用静态编译。
–-disable-shared:禁止动态编译。
–-with-ksource:指定目标板的内核目录。如果不指定,可能会提示:/usr/sbin/iptables: line 1: syntax error: unexpected “)”错误。当然,因为这个是可选项,如果没有提示错误,也可以不加这一项
2、内核的配置
为了使用iptables工具,需要配置内核来支持该工具,其实iptables工具主要是调用到内核里面的netfilter代码功能。这次是采用编译进内核的方式,当然也可以使用编译成模块的方式。
配置如下:
Networking —->
Networking options —->
[*] Network packet filtering (replaces ipchains) —>
[*]Advanced netfilter configuration
Core Netfilter Configuration —>
<*> Netfilter connection tracking support
<*> Netfilter Xtables support (required for ip_tables)
<*>”iprange” address range match support
<*>”multiport” Multiple port match support
<*>”state” match support
IP: Netfilter Configuration —>
<*> IPV4 connection tracking (required for masq/NAT)
[*]proc/sysctl compatibility with old connection tracking
<*> IP tables support (required for filtering/masq/NAT)
<*> IP range match support
<*> Packet filtering
<*> REJECT target support
<*> raw table support(required for NOTRACK/TRACE)
<*> Full NAT
说明:
1)若是不清楚,可以全部选中。
Networking —>
Networking options —>
Network packet filtering (replaces ipchains) —>(mini2440的内核版本稍高,选项不是这样的,但大同小异)
Core Netfilter Configuration —> 可以全选为build in (*)也可以全选为modules(M)
IP: Netfilter Configuration —> 可以全选为build in(*) 也可以全选为modules(M)
2)如果在开发板上执行 iptable -L -n出现以下信息,那么就需要重新配置和编译内核:
iptables v1.4.2: can’t initialize iptables table `filter’: Table does not exist (do you need to insmod?)Perhaps iptables or your kernel needs to be upgraded.
3)串口一直打印nf_conntrack:table full, dropping packet错误
在开发板的/etc/sysctl.conf中添加如下
net.netfilter.nf_conntrack_max = 655350
net.netfilter.nf_conntrack_tcp_timeout_established = 1200
相关文章推荐
- WinCE5.0 SMDK2410 BSP在GEC2410开发板上的移植(10)-FAT分区在Nand上的实现
- 嵌入式Qt开发环境搭建及移植到开发板----Qt学习笔记
- Qt-Embedded-4.5.2移植到s3c2440开发板
- linux-2.6.32在mini2440开发板上移植之RTC移植(4)
- 移植openssh至arm9嵌入式开发板
- 移植无线网卡驱动至开发板(PXA16x)
- x210v3开发板u-boot-2012.10移植之一---uboot版本选择
- U-Boot 在44B0X 开发板上的移植以及代码分析
- S3C6410移植linux-2.6.39 笔记(一)-搭建开发板环境
- u-boot在s3c2410开发板上移植(NAND Flash Boot)过程
- x210v3开发板u-boot-2012.10移植之七---六步轻松搞定串口初始化
- x210v3开发板u-boot-2012.10移植之十二---启动内核
- Qt4.7.4和tslib移植到开发板
- 向嵌入式linux开发板移植openSSH
- qt移植到s3c2440开发板上
- MPlayer移植到mini2440开发板
- 珠海鼎芯科技imx6开发板 tslib1.4的移植
- linux-2.6.32在mini2440开发板上移植(16)之LED 驱动程序移植
- u-boot-2009.11移植(适用于TQ2440和MINI2440)第一篇:建立开发板文件,测试编译环境
- 2440开发板linux系统移植3G拨号上网收发短(二)