我只是偶然发现了这个问题,现在已经很晚了,所以我现在不能再想清楚了。尽管如此,这还是很简单的事情,所以我并没有真正看到我错过了什么,只是在这里发疯了:
我正在设置一个服务器,我只用于运行码头容器。我从一个MariaDB容器开始,这里一切都好,我决定连接到它,只是为了确保所有的工作。
因此,现在我想连接到运行MariaDB的服务器,并且由于我落后于firewalld,我首先通过在防火墙-cmd中添加一个新区域来配置它,添加服务和源代码:
firewall-cmd --permanent --new-zone=test-from-home
firewall-cmd --reload
firewall-cmd --permanent --zone=test-from-home --add-service=mysql
firewall-cmd --permanent --zone=test-from-home --add-source=XX.XX.XX.XX/32
firewall-cmd --reload我用mysql -u root -p -h host连接得很好!
运行firewall-cmd --get-active-zones返回:
[root@nd01 latest]# firewall-cmd --get-active-zones
test-from-home
sources: XX.XX.XX.XX/32
public
interfaces: eth0因此,就因为有时我记得做了这些测试以确保一切正常工作,我连接到另一台机器,我成功地从另一个IP连接。
firewall-cmd --zone=test-from-home --list-all
test-from-home (active)
target: default
icmp-block-inversion: no
interfaces:
sources: XX.XX.XX.XX/32
services: mysql
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: ssh dhcpv6-client
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:为什么我能从随机机器连接?我遗漏了什么?谢谢
发布于 2019-02-14 10:36:23
今天我找到了答案,
与此同时,我发现FirewallD和Docker不合作。根据Docker文档,避免这种情况的方法是禁用IPTables:- 码头工人和iptables
正如它从第一立场上说的:
在Linux上,Docker操纵
iptables规则来提供网络隔离。这是一个实现细节,您不应该修改iptables策略中插入的规则。
这可不是我建议的第一招。
所以我做了更多的调查,我找到了一个页面,它给了我答案,任何有这个问题的人都可以从它那里获得一些想法,这是一个很好的方法,通过在DOCKER-用户链中添加配置。
https://serverfault.com/questions/953810
复制相似问题