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ù)器使用教程。