我有一台带有1个IPv4(111.111.111.111)(和1个IPv6地址)的Ubuntu 13.10 VPS服务器。
我最近要求一个额外的IP地址(222.222.222.222),但我似乎无法弄清楚如何将新的IP地址添加到我的networkingconfiguration。
我目前的(默认?)networkingconfiguration:
/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 auto eth0 iface eth0 inet dhcp
从search后,我想到了,我需要添加新的IP地址,如下所示:
iface eth0:1 inet static address 222.222.222.222 netmask 255.255.255.0
但不幸的是,这不起作用,我觉得它与auto eth0的dhcp设置有关 – > iface eth0 inet dhcp但我不知道如何解决这个问题。
另外值得注意的是,IP 1的网关与IP 2的网关不同,这是否会导致任何问题?
我的感觉说我需要删除eth0的当前networkingconfiguration,并将其replace为:
iface eth0 inet static address 111.111.111.111 netmask 255.255.255.0 gateway xxx.xxx.xxx.xxx
所以最终的结果看起来像这样:
# 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 iface eth0 inet static address 111.111.111.111 netmask 255.255.255.0 gateway xxx.xxx.xxx.xxx iface eth0:1 inet static address 222.222.222.222 netmask 255.255.255.0
由于当前在这台服务器上有一些小型站点是活跃的,所以我不想冒着任何停机的风险去改变这些networkingconfiguration
我的目标是(请让我知道这是否可能)使用IP地址1(111.11 …)在端口80上的所有apache2请求。并使用IP地址2(222.22 …)通过所有请求通过而不是apache2(例如NodeJs),而且在端口80上。
如果两个地址都在同一个接口上,则build议的configuration看起来不错。 但是,您将需要以下几行来确保接口出现:
auto eth0 auth eth0:1
这些可以组合为:
auto eth0 eth0:1
networking和广播地址将从IP地址和networking掩码确定,如果没有提供。 您的ISP必须提供这些信息。 他们应该能够提供广播和networking地址,但我从不configuration它们。
如果您有固定的IP地址,则不需要DHCP或热插拔。 这两个都适用于非服务器configuration。 连接到networking时,DHCP用于从路由器或其他DHCP服务器获取地址。 连接到不同networking时,使用Hotplug从一组configuration中select适当的configuration。 对于在办公室或家中使用的笔记本电脑来说,热插拔是合适的,而DHCP不足以进行configuration。