5
ufw 禁用端口未生效
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
容器, 就不会修改防火墙了.
完毕!!!
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK