为 apache 服务器配置多个 IP

为 apache 服务器配置多个 IP

我们有一个 Rootserver,支持人员告诉我们“你有 5 个 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
 auto p2p1
 iface p2p1 inet static
    address 94.xxx.xxx.102
    netmask 255.255.255.0
    network 94.xxx.xxx.0
    broadcast 94.xxx.xxx.255
    gateway 94.xxx.xxx.1
    # dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 8.8.8.8
    dns-search hoster.com

iface p2p1:1 inet static
    adress 94.xxx.xx.116
    netmask 255.255.255.0
    network 94.xxx.xxx.0
    broadcast 94.xxx.xx.255
    gateway 94.xxx.xxx.1
    #dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 8.8.8.8
    dns-search hoster.com

iface p2p1:2 inet static
    adress xxx.xxx.xxx.117
    netmask 255.255.255.0
    network 94.xxx.xxx.0
    broadcast 94.xxx.xxx.0
    gateway 94.xxx.xxx.1
    #dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 8.8.8.8
    dns-search hoster.com

iface p2p1:3 inet static
    adress 94.xxx.xxx.118
    netmask 255.255.255.0
    network 94.xxx.xxx.0
    broadcast 94.xxx.xxx.0
    gateway 94.xxx.xxx.1
    #dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 8.8.8.8
    dns-search hoster.com

 iface p2p1:4 inet static
    adress 94.xxx.xxx.119
    netmask 255.255.255.0
    network 94.xxx.xxx.0
    broadcast 94.xxx.xxx.0
    gateway 94.xxx.xxx.1
#dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 8.8.8.8
    dns-search hoster.com

我是不是漏掉了什么?重启后仍然不起作用。这是我第一次配置多个 IP。

答案1

您的 IP 别名节应包含最少的数据和auto每个别名的语句。我更喜欢使用最后一个八位字节作为别名号。这是我将使用的配置。

auto p2p1:116
iface p2p1:116 inet static
   address xxx.xxx.xxx.116
   netmask 255.255.255.0

auto p2p1:117
iface p2p1:117 inet static
   address xxx.xxx.xxx.117
   netmask 255.255.255.0

auto p2p1:118
iface p2p1:118 inet static
   address xxx.xxx.xxx.118
   netmask 255.255.255.0

auto p2p1:119
iface p2p1:119 inet static
   address xxx.xxx.xxx.119
   netmask 255.255.255.0

或者,如果您已经ip安装了该命令,则可以在节中添加地址,p2p1并添加如下行:

up ip addr add xxx.xxx.xxx.116/24 dev p2p1 || true
up ip addr add xxx.xxx.xxx.117/24 dev p2p1 || true
up ip addr add xxx.xxx.xxx.118/24 dev p2p1 || true
up ip addr add xxx.xxx.xxx.119/24 dev p2p1 || true

详细信息可以在 的输出中找到man interfaces

相关内容