我的目標

我的目標

我有一台 Ubuntu 13.10 VPS 伺服器,附有 1 個 IPv4 (111.111.111.111)(和 1 個 IPv6 位址)。

我最近請求了一個額外的 IP 位址 (222.222.222.222),但我似乎不知道如何將新的 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 eth0
iface eth0 inet dhcp

根據我搜尋後的結果,我需要新增一個新的 IP 位址,如下所示:

iface eth0:1 inet static
address 222.222.222.222
netmask 255.255.255.0

但不幸的是,這不起作用,我感覺它與->dhcp中的設置有關,但我不知道如何解決這個問題。auto eth0iface eth0 inet dhcp

另外值得注意的是,IP 1 的網關與 IP 2 的網關不同,這會導致任何問題嗎?

我的感覺是我需要刪除當前的網路配置eth0並將其替換為:

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

由於該伺服器上目前有一些小型網站處於活動狀態,因此我不想透過更改這些網路配置來冒任何停機的風險

我的目標

我的目標是(請告訴我這是否可能)對連接埠 80 上的所有 apache2 請求使用 IP 位址 1 (111.11...)。之外,但也在連接埠80 上。

答案1

如果兩個位址位於同一介面上,則您建議的配置看起來不錯。但是,您將需要以下行來確保介面出現:

auto eth0
auth eth0:1

這些可以組合為:

auto eth0 eth0:1

如果未提供,網路和廣播位址將根據 IP 位址和網路遮罩決定。您的 ISP 必須提供這些。他們應該能夠提供廣播和網路位址,儘管我從未配置過它們。

如果您有固定的 IP 位址,則不需要 DHCP 或熱插拔。這兩個都適用於非伺服器配置。 DHCP 用於連接網路時從路由器或其他 DHCP 伺服器取得位址。 Hotplug 用於在連接到不同網路時從一組配置中選擇適當的配置。 Hotplug 適用於 DHCP 不足以進行設定的辦公室或家庭中使用的筆記型電腦。

相關內容