亚马逊云科技

广告

安信SSL证书

广告

csf命令行选项

美国云服务器推荐

在初次配置和启动CSF之前,最好先通过:perl /etc/csf/csftest.pl

运行/etc/csf/csftest.pl 脚本。

该脚本可以测试所需的iptables模块是否在服务器上正常运行。如果它不能执行全部功能也没关系,只要该脚本没有报告任何致命的错误即可。

您可以通过使用# csf -h 查看csf命令行选项.

Usage: /usr/sbin/csf [option] [value]

用途: /usr/sbin/csf [选项] [值]

Option 选项 Meaning 含义

-h, –help Show this message 显示此消息

-l, –status List/Show iptables configuration 列出/显示iptables配置

-l6, –status6 List/Show ip6tables configuration列出/显示ip6ables配置

-s, –start Start firewall rules 启用防火墙规则

-f, –stop Flush/Stop firewall rules (Note: lfd may restart csf)清除/停止防火墙规则(注意:lfd可能重新启动csf)

-r, –restart Restart firewall rules重新启用防火墙规则

-q, –startq Quick restart (csf restarted by lfd)快速重启(lfd重启csf)

-sf, –startf Force CLI restart regardless of LF_QUICKSTART setting不顾 LF_QUICKSTART设置,强制CLI重新启动

-a, –add ip Allow an IP and add to /etc/csf.allow允许一个IP并添加至/etc/csf.allow

-ar, –addrm ip Remove an IP from /etc/csf.allow and delete rule从/etc/csf.allow 删除一个IP,删除规则

-d, –deny ip Deny an IP and add to /etc/csf.deny拒绝一个IP并添加至/etc/csf.deny

-dr, –denyrm ip Unblock an IP and remove from /etc/csf.deny解除对一个IP的阻止并从/etc/csf.deny里删除

-df, –denyf Remove and unblock all entries in /etc/csf.deny删除并解除对/etc/csf.deny里所有记录的阻止

-g, –grep ip Search the iptables rules for an IP match (incl. CIDR)查询与某IP匹配的iptables规则(包括 CIDR)

-t, –temp Displays the current list of temp IP entries and their TTL显示当前临时IP及其TTL的列表

-tr, –temprm ip Remove an IPs from the temp IP ban and allow list从临时禁止和允许IP列表删除IPs

-td, –tempdeny ip ttl [-p port] [-d direction]

Add an IP to the temp IP ban list. ttl is how long to 添加一个IP至临时禁止IP列表,

blocks for (default:seconds, can use one suffix of h/m/d)ttl是指端口的阻止时间(默认:秒,可以使用一个h/m/d后缀)

Optional port. Optional direction of block can be one of: 可选端口。阻止方向可以是以下任意一种:进入,传出或进出(默认:进入)

in, out or inout (default:in)

-ta, –tempallow ip ttl [-p port] [-d direction]

Add an IP to the temp IP allow list (default:inout) 添加一个IP至临时允许IP列表(默认:进出)

-tf, –tempf Flush all IPs from the temp IP entries 清除所有临时IP记录

-cp, –cping PING all members in an lfd Cluster PINGlfd群的所有成员

-cd, –cdeny ip Deny an IP in a Cluster and add to /etc/csf.deny 拒绝群里的某个IP,并添加到/etc/csf.deny

-ca, –callow ip Allow an IP in a Cluster and add to /etc/csf.allow 允许群里的某个IP,并添加到/etc/csf.allow

-cr, –crm ip Unblock an IP in a Cluster and remove from /etc/csf.deny 解除对群里某个IP的阻止,并从/etc/csf.deny 删除

-cc, –cconfig [name] [value]

Change configuration option [name] to [value] in a Cluster 将群里的配置选项[name]改为[value]

-cf, –cfile [file] Send [file] in a Cluster to /etc/csf/ 在群里发送[file]至/etc/csf/

-crs, –crestart Cluster restart csf and lfd 重新启动群csf和lfd

-m, –mail [addr] Display Server Check in HTML or email to [addr] if present在HTML显示服务器检查或发送邮件至[addr]地址,如果存在的话

-c, –check Check for updates to csf but do not upgrade 检查csf更新但不更新

-u, –update Check for updates to csf and upgrade if available检查csf更新并更新,如果可以的话

-uf Force an update of csf强制更新csf

-x, –disable Disable csf and lfd 禁用csf和lfd

-e, –enable Enable csf and lfd if previously disabled 启用之前禁用的csf和lfd

-v, –version Show csf version 显示csf版本

您可以通过这些选项方便快捷地控制和查看csf。所有的csf配置文件都在/etc/csf 里,包括:

csf.conf – 主要配置文件,它有说明每个选项用途的注释

csf.allow – 防火墙始终允许通过的IP和CIDR地址列表

csf.deny – 防火墙始终不允许通过的IP和CIDR地址列表

csf.ignore- lfd应忽略,并且发现后不阻止的IP和CIDR地址列表

csf.*ignore- 列出了lfd应忽略的文件,用户,IP地址的各种文件。具体参见每个文件。

如果修改上述任何文件,您要重新启动csf才能生效。如果您使用命令行选项添加或拒绝IP地址,csf会自动生效。

csf.allow 和csf.deny都可以在列出的IP地址后做评论。该评论必须和IP地址在同一行,否则csf.deny的IP轮换会将其删除。

如果直接编辑the csf.allow或csf.deny 文件,不论是从shell或WHM UI,您都要在IP地址与评论之间插入#,如下:

添加 11.22.33.44 # 因为我不喜欢它们

您也可以在使用the csf -a或csf -d命令时添加评论,不过不是插入 # ,而是:

添加csf -d 11.22.33.44 因为我不喜欢它们

如果您使用shell命令,则每行注释都要有时间戳。您还会发现,如果lfd阻止某IP地址,它也会添加一个描述性的评价以及时间戳。

如果已达到该行限制,您不想csf在csf.deny轮换某个IP,则可以添加 “do not delete” 至评价行,

e.g.:

添加 11.22.33.44 # 因为我不喜欢它们。do not delete

你还可以在csf.allow或csf.deny使用Include语句收入符合上述条件的其他文件。您必须给该文件指定完整的路径,e.g. in /etc/csf/csf.allow:

Include /etc/csf/csf.alsoallow

注意:所有从csf.allow或csf.deny添加或删除IP地址的csf命令均不能用于附加文件,它们被视作只读。

(本文由美国主机侦探原创,转载请注明出处“美国主机侦探”和原文地址!)

主机侦探企业微信

微信扫码加好友进群

主机优惠码及时掌握

主机侦探QQ群

QQ群号:938255063

主机优惠发布与交流

温馨提示:

1、本站部分图片来源于互联网,如有侵权请联系删除。邮箱:2942802716#qq.com(#改为@)

2、本文评论没有专人回复,如果您有问题请到美国主机侦探论坛提问!

3、美国主机侦探免费为您提供美国主机购买咨询。

RAKsmart美国服务器
lfd 原理
lfd命令行选项
返回顶部