我如何在firewalld中添加两条规则以便
在这种情况下,我要说的是SSH端口- 22。
我正在使用CentOS 7和firewalld。
发布于 2016-03-13 08:32:20
您可以使用
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" \
source address="1.2.3.4/32" \
port protocol="tcp" port="22" accept"只需将IP替换为您希望允许的ssh。
发布于 2016-03-13 10:38:37
检查哪个区域当前处于活动状态,默认情况下用于连接,
# firewall-cmd --get-active-zones
work
interfaces: work-vpn
home
interfaces: enp0s25例如,在上面的输出中,我有两个活动区域,每个接口一个。
然后您需要列出特定区域的活动服务,
# firewall-cmd --list-services --zone=public
dhcpv6-client mdns ssh因此,在上述情况下,公共区域有允许ssh进入的规则。因此,如果您希望允许来自spesifc地址的访问,那么首先需要删除ssh服务,以及上面提到的富规则。
# firewall-cmd
--permanent # this will add the rule permanently, su make sure not to run it on a remote host, until you verified it!
--zone=public # to which zone add the rule, make sure is the one you actively/currently using.https://unix.stackexchange.com/questions/269424
复制相似问题