Ubuntu install and configure firewall

foreword

There are a lot of messy things in ufw that we need to install manually.

Install and configure

If no super user is set (ubantu defaults to the default password),

First sudo passwd root, first let you continuously enter the password of your login user.

Again, let you set the root password.

First switch to, su - root to switch to the super user.

# 其实,通过apt安装之后,会默认注册成被systemctl指令管控的一个服务。

apt install ufw               # 安装ufw
ufw enable                    # 启动ufw
ufw status                    # 查看防火墙策略配置
ufw default deny              # 默认拒绝一切ip访问
ufw allow from 192.1.23.3     # 允许这个ip访问
ufw allow 80/tcp              # 允许使用tcp协议连接80端口,不想限定协议就去除tcp

ufw delete allow 80/tcp       # 删除允许绑定tcp协议访问80端口的策略


# 下面的语句将设置在tcp协议下拒绝192.168.1.66访问主机的端口22

ufw deny proto tcp from 192.168.1.66 to 192.168.1.242 port 22

Guess you like

Origin blog.csdn.net/Qhx20040819/article/details/131481753