在使用RAKsmart服务器的时候,如果安装的是Ubuntu操作系统的话,那么我们应该怎么添加单个、整段IP呢?
其实,在RAKsmart 服务器Ubuntu系统中配置单个、整段IP方法是非常简单的,今天这里就简单的说说。如果大家需要添加独立IP的话,可以安装下面方法进行。
多IP不同段配置方法:
多个不同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 7.7.7.2
netmask 255.255.255.248
gateway 7.7.7.1 (如果是多个不同IP段,只要1个gateway配置就行,其它IP不需要配置gateway)
auto eth0:0
iface eth0:0 inet static
address 7.7.7.3
netmask 255.255.255.248
auto eth0:1
iface eth0:1 inet static
address 7.7.7.4
netmask 255.255.255.248
auto eth0:2
iface eth0:2 inet static
address 7.7.7.5
netmask 255.255.255.248
auto eth0:4
iface eth0:4 inet static
address 4.4.4.130(虽然这是不同的IP段,但不需要配置gateway,只需配置netmask即可)
netmask 255.255.255.224
auto eth0:5
iface eth0:5 inet static
address 4.4.4.131
netmask 255.255.255.224
如果想添加更多独立IP的话,按照上述方法进行添加就行了。
配置文件完成后,用命令/etc/init.d/networking restart 重启网络,不需要reboot重启服务器。/etc/init.d/networking restart重启网络的时候,如果你的配置文件有错误,一般都有提示的。
整段IP添加方法
整段IP添加使用脚本添加,具体如下:
# !/bin/bash
for ((i=10;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 193.10.10.$j”>>/etc/network/interfaces
echo “netmask 255.255.255.0”>>/etc/network/interfaces
echo “gateway 193.10.10.254″>>/etc/network/interfaces
echo ” “>>/etc/network/interfaces
done
# end
相关含义说明:
i代表的是子网卡号
j代表的是具体的IP
该脚本从是从10开始的
修改完系统中文件要给775的权限,注意网卡名称
以上就是RAKsmart服务器Ubuntu配置单个、整段IP方法的方法,不会的朋友可以安装上述方法进行添加。