【问题标题】:What kind of a thing is the "_gateway" variable in CentOS/RHEL? [closed]CentOS/RHEL 中的“_gateway”变量是什么东西? [关闭]
【发布时间】:2021-08-11 03:43:18
【问题描述】:

我已经知道 CentOS/RHEL 中的“_gateway”变量(我认为最多 7 个它只是“网关”,没有 _ 符号)。今天我在我的家庭实验室中设置了 AdGuard DNS 服务器,在同一台机器上是一个反向代理来提供一些内部服务,我在主机上添加了第二个 IP,因为我需要多个 HTTP 端口。没关系,我在 adguard 上设置了一个通配符 DNS 条目。像这样:*.mydomain.com 172.16.20.60(就是上面提到的反向代理的IP)——我不想手动添加所有服务,所以我选择了通配符方式。

几个小时后,我注意到托管 dns 服务器和反向代理的机器无法连接到互联网。

我做了一个跟踪路由,发现它试图通过 _gateway.mydomain.com 访问互联网(这导致机器本身)。

_gateway.mydomain.com 上的 ping 返回了机器 IP,所以我记得我的 dns 服务器上的通配符 dns 条目。我将 _gateway.mydomain.com 添加到它的正确 IP,然后它按预期工作。

我的问题是这种环境变量“_gateway”/“gateway”是怎么回事——为什么 RedHat 会这样做?我想知道为什么网络试图通过 dns 名称访问它的网关? 我无法找到有关此的任何信息,也没有找到机器本身的任何设置来禁用此行为。

这是一些输出:

ping _gateway
PING _gateway.mydomain.com (172.16.20.10) 56(84) bytes of data.
64 bytes from _gateway (172.16.20.10): icmp_seq=1 ttl=64 time=0.112 ms
64 bytes from _gateway (172.16.20.10): icmp_seq=2 ttl=64 time=0.285 ms
64 bytes from _gateway (172.16.20.10): icmp_seq=3 ttl=64 time=0.190 ms
64 bytes from _gateway (172.16.20.10): icmp_seq=4 ttl=64 time=0.284 ms
host _gateway
_gateway.mydomain.com has address 172.16.20.10

有什么想法吗?

谢谢

【问题讨论】:

    标签: dns centos rhel centos8 rhel8


    【解决方案1】:

    因为似乎没有人知道我的意思,所以我自己解决了这个问题。 我在 Ubuntu 上看到了同样的事情,这让我得出结论,它可能与 systemd 有关系……是的,宾果游戏!

    根据https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html 所说:

    The hostname "_gateway" is resolved to all current default routing gateway addresses, ordered by their metric. This assigns a stable hostname to the current gateway, useful for referencing it independently of the current network configuration state.
    

    我没有进行更多调查来禁用此行为,反正我知道这个 s*it 来自哪里,感谢 systemd ...

    【讨论】:

      猜你喜欢
      • 2013-05-21
      • 2011-08-28
      • 2013-10-11
      • 2017-07-12
      • 2011-10-20
      • 2020-04-02
      • 1970-01-01
      • 1970-01-01
      • 2020-06-26
      相关资源
      最近更新 更多