跳至主要內容

ubuntu20.04防火墙基本操作

zhengcog...小于 1 分钟linuxubuntu防火墙

ubuntu20.04版本默认防火墙配置工具是ufw,主要为简化 iptables 防火墙配置而开发

安装

# 更新包
sudo apt update
# 安装
sudo apt install ufw

基本使用

# 查看防火墙状态,默认关闭
ufw status
# 查看更详细状态
ufw status verbose
# 查看编号格式
ufw status numbered
# 开启防火墙
ufw enable
# 关闭防火墙
ufw disable
# 重启防火墙
ufw reload
# 开放端口 22
ufw allow 22
# 允许特定主机访问端口
ufw allow proto tcp from 192.168.1.0/24 to any port 3306
ufw alow proto udp from 192.168.1.0/24 to any port 1234
# 关闭端口
ufw deny 22
# 拒绝特定主机或网络访问端口
ufw deny proto tcp from 192.168.1.0/24 to any port 3306
# 查看所有开放端口
netstat -aptn
上次编辑于:
贡献者: Hyman
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v2.15.5