系统相关
首页 > 系统相关> > Linux 操作系统防火墙配置(centos)

Linux 操作系统防火墙配置(centos)

作者:互联网

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. 防火墙iptables

* 即时生效

iptables -A INPUT -s 192.168.11.125 -j DROP
iptables -D INPUT 1 删除序号1

*永久生效

编辑/etc/sysconfig/iptables 配置文件
保存
service iptables save
Usage: iptables {start|stop|reload|restart|condrestart|status|panic|save}

3. 防火墙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
[root@RAC etc]# firewall-cmd --list-rich-rules
rule family="ipv4" source address="192.168.0.0/16" port port="5601" protocol="tcp" accept

标签:centos,firewall,cmd,防火墙,tcp,permanent,5601,Linux,port
来源: https://blog.csdn.net/Gavinqq/article/details/106902303