CentOS 7 放行指定端口操作步骤, 首先需要确定服务器使用的是 firewalld 还是 iptables来配置防火墙规则 if systemctl is-active --quiet firewalld; then echo "firewalld is active"; elif systemctl is-active --quiet iptables; then echo "iptables is active"; else echo "Neither firewalld nor iptables is active"; fi 使用firewalld 1. 检查 firewalld 状态 确保 firewalld 服务正在运行: sudo systemctl status firewalld 如果 firewalld 没有运行,可以启动它: sudo systemctl start firewalld 并设置为开机自启: sudo systemctl enable firewalld 2. 放行端口 使用以下命令来放行 你要放行的端口 比如123: sudo firewall-cmd --zone=public --add-port=123/tcp --permanent 这里 –zone=public 表示在 public 区域放行该端口, –permanent 表示永久生效。 3. 重新加载防火墙配置 要使更改立即生效,需要重新加载防火墙配置: sudo firewall-cmd --reload 4. 验证端口是否被放行 你可以使用以下命令来验证端口是否已经被放行: sudo firewall-cmd --zone=public --query-port=123/tcp 如果返回 yes,说明端口 123 已成功放行。 5. 列出所有开放的端口 【可选操作】 sudo firewall-cmd --zone=public --list-ports 6. 列出所有防火墙规则【可选操作】 sudo firewall-cmd --list-all 使用 iptables 如果你更喜欢使用 `iptables`,可以按以下步骤操作: 1. 放行端口 使用以下命令添加一条规则来放行 123 端口: sudo iptables -A INPUT -p tcp --dport 123 -j ACCEPT 2. 保存规则 为了确保规则在系统重启后仍然有效,需要保存规则。使用以下命令保存规则到文件: sudo service iptables save 3. 查看规则 你可以使用以下命令查看当前的 `iptables` 规则,确保端口 123 已被放行: sudo iptables -L -n 4. 查看所有 iptables 规则 sudo iptables -L -n -v
阿西吧 CentOS9 安装Docker 28 Linux安装Docker 28 安装包文件直接安装,CentOS RedHat Debian Ubuntu 等系统都支持安装 Linux安装Docker 28 安装包文件直接安装,CentOS RedHat D...