RAKsmart服務(wù)器Ubuntu配置單個(gè)IP與整段IP是什么?

raksmart的朋友們,大家好,今天rak給大家說(shuō)一下在我們的美國(guó)服務(wù)器Ubuntu系統(tǒng)怎么配置單個(gè)IP和整段IP,昨天和前天說(shuō)的都是centos系統(tǒng),今天就講一下Ubuntu的操作方法。

多IP不同段配置:

多個(gè)不同IP段的?/etc/network/interfaces?配置文件的范例如下:

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

auto eth0

iface eth0 inet static

address 8.8.8.2

netmask 255.255.255.248

gateway 8.8.8.1?

要注意這里,多個(gè)不同IP段,只要1個(gè)gateway配置即可,其他IP不需要配置gateway

auto eth0:0

iface eth0:0 inet static

address 8.8.8.3

netmask 255.255.255.248

auto eth0:1

iface eth0:1 inet static

address 8.8.8.4

netmask 255.255.255.248

auto eth0:2

iface eth0:2 inet static

address 8.8.8.5

netmask 255.255.255.248

auto eth0:3

iface eth0:3 inet static

address 8.8.8.6

netmask 255.255.255.248


auto eth0:4

iface eth0:4 inet static

address 6.6.6.130?

注意這里,雖然這是不同的IP段,但是不需要配置gateway,只需要配置netmask即可

netmask 255.255.255.224

auto eth0:5

iface eth0:5 inet static

address 6.6.6.131

netmask 255.255.255.224


更多ip也類似配置即可。配置文件完成后,用命令/etc/init.d/networking restart?重啟網(wǎng)絡(luò),不需要reboot重啟服務(wù)器。?/etc/init.d/networking restart?重啟網(wǎng)絡(luò)的時(shí)候,如果你的配置文件有錯(cuò)誤,那么他會(huì)提示你。比如IP重復(fù)了,書寫錯(cuò)誤了,等等。

整段IP添加:

整段IP添加使用腳本添加

腳本信息:

# !/bin/bash

for ((i=1;i<=255;i=i+1))

do

??? echo "auto eth0:$i">>/etc/network/interfaces

??? echo "iface eth0:$i inet static">>/etc/network/interfaces

#?? let j=$i

??? echo "address 192.1.1.$j">>/etc/network/interfaces

??? echo "netmask 255.255.255.0">>/etc/network/interfaces

??? echo "gateway 192.1.1.254">>/etc/network/interfaces

??? echo "? ">>/etc/network/interfaces

done

# end


腳本修改文件解析:

i值是子網(wǎng)卡號(hào)

j是具體IP

該腳本從是從:1開始的

子網(wǎng)卡號(hào)可隨意不沖突就行??,let?j=$i-9?利用這個(gè)?湊出具體IP

修改完系統(tǒng)中文件要給775的權(quán)限,注意網(wǎng)卡名稱

以上就是在raksmart服務(wù)器Ubuntu系統(tǒng)附加單IP和多IP的方法,以后raksmart會(huì)為大家?guī)?lái)更多的服務(wù)器使用教程。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容