linux编译内核,使其支持iptables recent模块【Enable IPTABLES support in Linux Kernel】

本文介绍了一种解决iptables配置问题的方法,特别是在遇到No chain/target/match by that name错误时。通过重新编译内核并启用特定的Netfilter模块,如recent模块,可以实现更复杂的防火墙规则,例如限制短时间内对特定端口的访问次数。

参考地址:http://blog.serverbuddies.com/enable-iptables-support-in-linux-kernel/


公司交给我配置一个简单的安全模块任务,想着用iptables命令弄个防止端口扫描,命令如下

iptables -P INPUT ACCESS
iptables -I INPUT -i br-wan -p tcp -m state --state NEW -m recent --name portscan --set
iptables -I INPUT -i br-wan -p tcp -m state --state NEW -m recent --update --seconds 60 --hitcount 10 --name portscan -j DROP

 

就是60秒之内访问wan口超过10次的就拉黑60s,由于鄙人太菜了,等到把iptables基础搞明白已经被经理催了很多遍交任务了=-=,然后赶紧上板子测试,结果爆出:iptables:No chain/target/match by that name

这就触及到我的知识盲区了,百度上东搜西搜关于这个报错全是docker的,然而docker我也不懂,好吧只有偷偷摸摸谷歌,然后就说是linux内核没有配置iptables相应模块,之前测试过state模块是没问题的,那么应该是recent模块死活不行。

内核也还没碰过,不敢乱搞,跑去问经理,经理让我用make menuconfig自己搞,学学。好吧又去百度上搜怎么内核怎么配置iptables模块,可惜也没有看到让我搞得懂的答案,又去外网,才搜了个直白明了粗暴的

 

Enable IPTABLES support in Linux Kernel

You need to recompile kernel to enable IPTABLES support. I am giving the steps to enable IPTABLES support during kernel recompilation.

Get into the kernel source directory:

# cd /usr/local/src/kernel
# make menuconfig

Select the following option (not as a loadable module)

Networking >> Networking options >> Network packet filtering (replaces ipchains) >> Core Netfilter Configuration >> Netfilter Xtables support (required for ip_tables) and select the all following options as modules.

Networking >> Networking options >> Network packet filtering (replaces ipchains) >> IP: Net Filter configurationS >> IP Tables support

# make
# make modules
# make modules_install
# make install

 

完美解决!

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值