当前位置:首页 > linux > 正文

linux怎么关闭防火墙(linux怎么关闭防火墙命令)

  • linux
  • 2024-03-15 17:58:31
  • 6087
如何关闭 Linux 防火墙
要素 1: 确定防火墙类型
iptables: 基于规则的防火墙,通常在较旧的 Linux 发行版中使用。
firewalld: 功能更丰富的防火墙,支持区域和服务的概念。
要素 2: 关闭 iptables
sh
sudo systemctl disable iptables
sudo systemctl stop iptables
要素 3: 关闭 firewalld
sh
sudo systemctl disable firewalld
sudo systemctl stop firewalld
要素 4: 确认防火墙已关闭
iptables:
sh
sudo iptables -L
firewalld:
sh
sudo firewall-cmd --state
输出应显示防火墙已关闭或未运行。
要素 5: 持久化更改
要使更改在重启后生效,请执行:
iptables:
sh
sudo iptables-save
firewalld:
sh
sudo systemctl enable firewalld
示例:
使用 iptables 关闭防火墙
sh
sudo systemctl disable iptables
sudo systemctl stop iptables
sudo iptables -L
使用 firewalld 关闭防火墙
sh
sudo systemctl disable firewalld
sudo systemctl stop firewalld
sudo firewall-cmd --state