如何通过辅助IP访问云主机?

如何通过辅助IP访问云主机?

Ubuntu 版本是 14.04,主机提供商是 1and1.com。我为主机配置了两个公网 IP,以下是我的 /etc/network/interfaces 文件的配置:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
auto eth0:0
iface eth0:0 inet static
name Ethernet alias LAN card
address {2nd IP address}
netmask 255.255.255.255
broadcast {2nd IP address}
network {2nd IP address ended with 0}

ifconfig -a 输出如下:

eth0      Link encap:Ethernet  HWaddr 00:50:56:12:68:8e
          inet addr:{Primary IP address}  Bcast:{Primary IP address} Mask:255.255.255.255
          inet6 addr: fe80::250:56ff:fe12:688e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1348 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1097 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:210260 (210.2 KB)  TX bytes:343976 (343.9 KB)

eth0:0    Link encap:Ethernet  HWaddr 00:50:56:12:68:8e
          inet addr:{2nd IP address}  Bcast:{2nd IP address} Mask:255.255.255.255
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

因此,根据配置,一切都应该没问题,但我无法从外部访问第二个 IP,ping 请求超时,而且如果我将第二个 IP 设置为任何域的 A 记录,则不起作用。我如何公开访问第二个 IP?

提前致谢。

答案1

问题已解决,实际上防火墙阻止了第二个 IP 的所有端口。我只是允许了。

相关内容