ubuntu操作系统下的ufw防火墙配置(一)

韵味老鸟 2024-08-23 14:59:01

ubuntu 操作系统下的ufw 防火墙配置

1)查看状态

ufw status

2)启用防火墙

root@meng:~# ufw enable

Command may disrupt existing ssh connections. Proceed with operation (y|n)? y

Firewall is active and enabled on system startup

root@meng:~# ufw status

Status: active

3)允许ssh连接

ufw allow ssh

root@meng:~# ufw status

Status: active

root@meng:~# ufw allow ssh

Rule added

Rule added (v6)

root@meng:~# ufw status

Status: active

To Action From

22/tcp ALLOW Anywhere

22/tcp (v6) ALLOW Anywhere (v6)

4)允许特定端口(如80端口)

ufw allow 80/tcp

5)拒绝特定IP地址的访问

ufw deny from 192.168.1.100

6)重置规则

ufw reset

root@meng:~# ufw status

Status: active

To Action From

22/tcp ALLOW Anywhere

80/tcp ALLOW Anywhere

Anywhere DENY 192.168.1.100

22/tcp (v6) ALLOW Anywhere (v6)

80/tcp (v6) ALLOW Anywhere (v6)

root@meng:~# ufw reset

Resetting all rules to installed defaults. This may disrupt existing ssh

connections. Proceed with operation (y|n)? y

Backing up 'user.rules' to '/etc/ufw/user.rules.20240815_141221'

Backing up 'before.rules' to '/etc/ufw/before.rules.20240815_141221'

Backing up 'after.rules' to '/etc/ufw/after.rules.20240815_141221'

Backing up 'user6.rules' to '/etc/ufw/user6.rules.20240815_141221'

Backing up 'before6.rules' to '/etc/ufw/before6.rules.20240815_141221'

Backing up 'after6.rules' to '/etc/ufw/after6.rules.20240815_141221'

root@meng:~# ufw status

Status: inactive

root@meng:~# ufw enable

Command may disrupt existing ssh connections. Proceed with operation (y|n)? y

Firewall is active and enabled on system startup

root@meng:~# ufw status

Status: active

0 阅读:0

韵味老鸟

简介:感谢大家的关注