1. hosts.allow和 host.deny:
文件路径/etc/hosts.allow 和 /etc/hosts.deny
当hosts.allow和 host.deny相冲突时,以hosts.allow设置为准。
配置如下
#服务:IP:动作
sshd: 192.168.88.*: ALLOW
sshd:ALL: DENY
2. 防火墙firewalld
firewall-cmd --list-all 查看防火墙状态策略情况
[root@RAC ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: dhcpv6-client ssh
ports: 5601/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
rule family="ipv4" source address="192.168.0.0/16" port port="5601" protocol="tcp" accept
*即时生效
firewall-cmd --add-port=5601/tcp
firewall-cmd --remove-port=5601/tcp
*永久生效–permanent
- 端口方式
firewall-cmd --permanent --zone=public --add-port=5601/tcp
firewall-cmd --permanent --zone=public --add-port=5601/tcp
firewall-cmd --permanent --add-port=5601/tcp
firewall-cmd --permanent --remove-port=5601/tcp
注:以上配置都需要重新加载才能生效
firewall-cmd --reload - rich-rules
firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.0.0/16” port protocol=“tcp” port=“5601” accept’
firewall-cmd --permanent --add-rich-rule="rule family=“ipv4” source address=“192.168.0.0/16” port protocol=“tcp” port=“5601” reject
firewall-cmd --permanent --remove-rich-rule=‘rule family=“ipv4” source address=“192.168.0.0/16” port protocol=“tcp” port=“22” accept’
注:以上配置都需要重新加载才能生效
firewall-cmd --reload
查看rich-rules
[root@RAC etc]# firewall-cmd --list-rich-rules
rule family="ipv4" source address="192.168.0.0/16" port port="5601" protocol="tcp" accept
suse配置详见:https://blog.csdn.net/ZhouGuo520/article/details/107333402