Debian/Ubuntu ufw防火墙
ufw 备忘
关于apt与apt-get:
dpkg是幕后英雄☠️,负责实际的安装工作。apt-get提供了完整的dpkg接口😈,功能强大但略显繁琐。apt是更友好、更易用的apt-get版本,功能略有精简💀。
apt和apt-get不仅仅是dpkg的接口,还能完dpkg无法做到的事情,比如从软件库获取文件。选择使用哪一个,取决于你的具体需求和使用场景,简单来说,apt更适合日常使用,而apt-get更受脚本开发者青睐。
apt-get update
apt-get upgrade ⛑️UFW 防火墙
⚜️安装
apt-get install ufw -y✅️开放端口
在启动前开启22端口 允许SSH连接
# 开启https服务需要端口 OpenSSH=22
ufw allow OpenSSH
# 开启https服务需要端口
ufw allow https
# 可以使用端口号443代替https配置文件
ufw allow 443/tcp❎️关闭端口
ufw deny 80🟢启动
ufw enable
# Command may disrupt existing ssh connections. Proceed with operation (y|n)?
# Firewall is active and enabled on system startup🔶关闭
ufw disable⛓️💥查看状态
ufw status
ufw status verbose⛓️允许特定的IP地址
ufw allow from 115.127.62.61
# 允许特定IP访问前提条件下,允许其访问特定端口
ufw allow from 115.127.62.61 to any port 22🪤拒绝连接
ufw deny from 23.24.25.0/24
# 拒绝从23.24.25.0/24访问端口80和443
ufw deny from 23.24.25.0/24 to any port 80
ufw deny from 23.24.25.0/24 to any port 443🧹删除UFW规则
ufw status numbered
# 输出类似如下:
Status: active
To Action From
-- ------ ----
[ 1] 22/tcp ALLOW IN Anywhere
[ 2] 80/tcp ALLOW IN Anywhere
[ 3] 8080/tcp ALLOW IN Anywhere
# 删除规则号3
sudo ufw delete 3🧽重启防火墙
ufw reload🧿重置UFW
ufw reset
