首頁  >  文章  >  運維  >  Linux雲端伺服器怎麼加入IP位址

Linux雲端伺服器怎麼加入IP位址

WBOY
WBOY轉載
2023-05-16 19:37:101421瀏覽

在新增IP之前,我們需要準備以下訊息,請注意替換尖括號中對應的參數。

  • 現有IP位址、子網路遮罩、預設閘道

  • #新增IP位址、子網路遮罩

  • DNS伺服器

#為了使新IP生效,您需要在管理中心的雲端伺服器管理中執行重新啟動操作。您可以透過ping指令來偵測是否新增成功。

CentOS 6

1、設定靜態IP。

vi /etc/sysconfig/network-scripts/ifcfg-eth0

把BOOTPROTO=dhcp改成BOOTPROTO=static,並在該檔案最後加上IP位址、子網路遮罩和預設網關,這些資訊可以在雲端伺服器管理中取得。

BOOTPROTO=static
...
IPADDR=<currentip>
NETMASK=<netmask>
GATEWAY=<gateway>
DNS1=<dns1>

2、建立網路介面設定檔。

vi /etc/sysconfig/network-scripts/ifcfg-eth0:1

內容如下:

DEVICE=eth0:1
BOOTPROTO=static
IPADDR=<newip>
NETMASK=<netmask>
ONBOOT=yes

3、啟動網路接口,IP位址新增完畢。

ifup eth0:1

Ubuntu

1、查看網路設備名稱,例如eth0。

ip link show

2、編輯網路介面設定檔。

vi /etc/network/interfaces

內容如下:

auto eth0:0
iface eth0:0 inet static
address <newip>
netmask <netmask>

3、啟動網路接口,IP位址新增完畢。

ifup eth0:0

Ubuntu 16.x

1、查看網路設備名稱,例如ens3。

ip link show

2、編輯網路介面設定檔。

vi /etc/network/interfaces

內容如下:

auto ens3:0
iface ens3:0 inet static
address <newip>
netmask <netmask>

3、啟動網路接口,IP位址新增完畢。

ifup ens3:0

FreeBSD 10

1、編輯網路介面設定檔。

vi /etc/rc.conf

內容如下:

ifconfig_vtnet0_alias0="<newip> netmask <netmask>"

2、執行下列指令重新啟動網路。

/etc/rc.d/netif restart && /etc/rc.d/routing restart

以上是Linux雲端伺服器怎麼加入IP位址的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:yisu.com。如有侵權,請聯絡admin@php.cn刪除