大网数据广告活动
服务器运维问答

How to block a small IP range in csf

· 52CE 我爱测

I'm looking for a way to block a small ip range in csf, e.g. 151.80.31.103 to 151.80.31.115 I know how to block each ip by issuing a cmmand csf -d IP , but it is a lot more effective to have a way to block a small set of ip range…

问题原文

原帖链接 · aye · CC BY-SA 3.0

I'm looking for a way to block a small ip range in csf, e.g. 151.80.31.103 to 151.80.31.115

I know how to block each ip by issuing a cmmand csf -d IP, but it is a lot more effective to have a way to block a small set of ip range, as the given example.

I have searched for a while, but not finding any relevant information.

Thanks for any hint!

已采纳解答

原帖链接 · David W · CC BY-SA 3.0

If you have SSH access, you can manually edit the file /etc/csf/csf.deny with vim or emacs or your favorite text editor.

Here's a portion of the top of that file with some comments:

# The following IP addresses will be blocked in iptables
# One IP address per line
# CIDR addressing allowed with a quaded IP (e.g. 192.168.254.0/24)
# Only list IP addresses, not domain names (they will be ignored)
#
# Note: If you add the text "do not delete" to the comments of an entry then
# DENY_IP_LIMIT will ignore those entries and not remove them

Given that information, use a subnet calculator (such as this one from MXtoolbox) to determine the smaller subnet. Given your criteria, one possible subnet suggested by mxtoolbox would be 151.80.31.96/27, which would filter everything from 151.80.31.96 through 151.80.31.127.

Make sure that you restart CSF afterwards with csf -r and then restart lfd with lfd -r.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-02-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。