假设我们有两台服务器 A 和 B 具有“真实”和外部 IP,我们可以切换所谓的“故障转移 ip”(WXYZ)以指向 A 或 B 的特定外部 IP。这从“外部”工作并且是很容易做到。作为背景:故障转移 ip 配置为 /etc/network/interfaces 中的新条目:
auto eth0:0
iface eth0:0 inet static
address W.X.Y.Z
netmask 255.255.255.224
现在让我们假设 WXYZ 被动态配置为使用硬件 A。现在我从 B 调用“curl domain.com”,它使用正确的故障转移 ip WXYZ,但随后以某种方式解析为错误的外部 IP B(或本地主机?)而不是使用配置的一个 A:
Trying W.X.Y.Z ...
* connect to W.X.Y.Z port 443 failed: Connection refused
* Failed to connect to domain.com port 443: Connection refused
* Closing connection 0
curl: (7) Failed to connect to domain.com port 443: Connection refused
当我启动本地 nginx 时,它可以成功 curl domain.com
我是否需要以某种方式在本地配置 DNS?如何找到有关 DNS 链的更多信息?
如果从服务器 B 尝试,使用mtr只会打印 domain.com
这与这个问题有关吗?
The failover IP is W.X.Y.Z and is also the A record of domain.com
The /etc/hosts file for both nodes serverA and serverB looks like:
127.0.0.1 localhost
127.0.1.1 luminarhost
xxx serverA
xxx serverB
The /etc/network/interfaces of serverA
### Hetzner Online AG - installimage
# Loopback device:
auto lo
iface lo inet loopback
# device: eth0
auto eth0
iface eth0 inet static
address xxx
broadcast xxx
netmask xxx
gateway xxx
# default route to access subnet
up route add -net xxx netmask 255.255.255.224 gw xxx eth0
iface eth0 inet6 static
address xxx
netmask xxx
gateway xxx
# failover ip
auto eth0:0
iface eth0:0 inet static
address W.X.Y.Z
netmask 255.255.255.224
and of serverB it is:
### Hetzner Online AG - installimage
# Loopback device:
auto lo
iface lo inet loopback
# device: eth0
auto eth0
iface eth0 inet static
address xxx
broadcast xxx
netmask xxx
gateway xxx
# default route to access subnet
up route add -net xxx netmask 255.255.255.192 gw xxx eth0
iface eth0 inet6 static
address xxx
netmask xxx
gateway xxx
# failover ip
auto eth0:0
iface eth0:0 inet static
address W.X.Y.Z
netmask 255.255.255.224