【Linux】Firewall 防火墙
个人电脑倒没什么,如国内,很少有个人电脑有公网 IP 的。但服务器不同,24 小时运行 + 公网 IP + 诸多网站、数据库等信息,防火墙还是要开一个的。 主要内容:基本操作,端口开启关闭,安全组 环境:CentOS 7 常见的 Linux 防火墙有两种:iptables 和 firewall,不过呢,虽然他们是一种东西,但是 firewall 其实是通过调用 iptables 来实现功能的,firewall 对比起 iptables 多提供了一些桌面程序接口,实质上两者是一样的。 这里我们禁用 iptables systemctl stop iptables systemctl disable iptables 基本操作 # 启动 systemctl start firewalld # 关闭 systemctl stop firewalld # 查看状态 systemctl status firewalld # 重启 systemctl restart firewalld # 开机自启 systemctl enable firewalld # 禁用开机自启 systemctl disable firewalld 端口开启 & 关闭 # 查看端口监听 netstat -ntlp # 查看 Firewall 已经开放的端口 firewall-cmd --list-ports # 开启端口 firewall-cmd --zone=public --add-port=19999/tcp --permanent # 关闭端口 firewall-cmd --zone=public --remove-port=19999/tcp --permanent # 使设置生效 systemctl restart firewalld 关于安全组 开了防火墙端口还是无法访问?八成是添加安全组规则。 ...