5

ufw 禁用端口未生效

 1 year ago
source link: https://www.cnblogs.com/hujingnb/p/15579099.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

系统: debian 10

安装ufw防火墙:

apt install ufw
ufw default deny
ufw allow 22
ufw enable

此时查看ufw状态, 可以看到只允许22端口:

使用docker启动了25143端口的服务, 此时发现, telent 25143端口仍然可以连接, 防火墙没生效???

通过命令iptables-save查看防火墙状态:

发现docker自动在防火墙列表中添加了开放端口的规则. 所以根本就没走到ufw端口就被放行了.

那么, 如果不希望docker映射的端口对外开放怎么办呢?

docker 不修改防火墙#

第一步

修改docker的配置文件/etc/docker/daemon.json(若没有就新建一个), 添加如下内容:

{
  "iptables": false
}

第二步

重启docker:

systemctl restart docker

完成, 此时再启动docker容器, 就不会修改防火墙了.

完毕!!!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK