FreeBSD 6.2 中配置 防火墙 IPFILTER

防火墙的选择:
需求:
1.可限制IP访问WEB服务
2.不限制对外部的访问(特别是用ports在线升级)
3.配置简单

IPF(IPFILTER)是首选了

配置:
# 启用IPF:
vi /etc/rc.conf
# 添加:
ipfilter_enable=”YES”
ipfilter_rules=”/etc/ipf.rules”
ipmon_enable=”YES”
ipmon_flags=”-Ds”
# 详细意义见手册:http://cnsnap.cn.freebsd.org/doc/zh_CN.GB2312/books/handbook/firewalls-ipf.html

# 初始化防火墙规则:
touch /etc/ipf.rules

# 不重启系统激活配置:
cd /etc && sh rc
# 参考:http://wiki.scivoid.net/index.cgi/FreebsdTips

# 禁止某个IP:
block in log first quick proto tcp/udp from 192.168.0.102 to any port = 80
#(解封:清除规则则可)
# 192.168.0.102 会被转换为 192.168.0.102/32,32是掩码的十进制数,用来指定子网范围。根据掩码计算子网范围:http://jodies.de/ipcalc
# 192.168.0.1/24 表示禁止整个网段。
# 启用设置:
ipf -Fa -f /etc/ipf.rules

# 看log first规则被匹配的次数:
ipfstat -hio

# 查看某个IP的block次数
ipfstat -hi | grep “192.168.0.112” | awk ‘{print $1}’

FreeBSD IPFILTER (IPF) 防火墙使用手册

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据