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

5100

被折叠的 条评论
为什么被折叠?



