1、 Ubuntu
Ubuntu 一般自带 UFW 防火墙,常用命令如下:
关闭防火墙:ufw disable
开启防火墙:ufw enable
查看防火墙状态:ufw status
禁用防火墙并删除所有防火墙规则:ufw reset

2、Debian
Debian 一般自带 iptables 防火墙,常用命令如下:
查看已添加的iptables规则
iptables -L -n
开放所有端口:
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F

强制删除 iptables
rm -rf /etc/iptables && reboot

有些发行版自带了 netfilter-persistent,也可以强制删除:
apt purge netfilter-persistent && reboot


3、CentOS
CentOS 一般自带 firewall 防火墙,常用命令如下:

启动防火墙: systemctl start firewalld

禁用防火墙: systemctl stop firewalld

设置开机启动: systemctl enable firewalld

停止并禁用开机启动: sytemctl disable firewalld

重启防火墙: firewall-cmd --reload

查看状态: systemctl status firewalld

有些 CentOS 发行版还自带了 SELinux,关闭命令如下:

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config

最后重启一下 /sbin/reboot

以上命令如果不是 root 用户,自行在前面加上 sudo 权限命令

Leave a Reply

Your email address will not be published. Required fields are marked *