[1]删除用户默认配置文件
由于在默认清空下,配置文件是系统自动生成的用户设备配置文件保存在
/etc/udev/rule.d/下面
#cp /etc/udev/rule.d /etc/udev/rule.d.bak.0 -R
# rm /etc/udev/rule.d/*
[2]修改网卡配置文件,添加多IP配置
#vim /etc/network/interfaces
为如下内容
auto eth0
iface eth0 inet static
address 213.128.82.162
netmask 255.255.255.240
network 213.128.82.160
broadcast 213.128.82.175
gateway 213.128.82.161
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 195.175.39.39
dns-search altinsoft.net
auto eth0:0
iface eth0:0 inet static
address 213.128.82.163
netmask 255.255.255.240
auto eth0:1
network 213.128.82.160
broadcast 213.128.82.175
gateway 213.128.82.161
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 195.175.39.39
dns-search altinsoft.net
auto eth0:0
iface eth0:0 inet static
address 213.128.82.163
netmask 255.255.255.240
auto eth0:1
iface eth0:1 inet static
address 213.128.82.164
netmask 255.255.255.240
auto eth0:2
iface eth0:2 inet static
address 213.128.82.165
netmask 255.255.255.240
auto eth0:3
iface eth0:3 inet static
address 213.128.82.166
netmask 255.255.255.240
auto eth0:4
iface eth0:4 inet static
address 213.128.82.167
netmask 255.255.255.240
............
实验环境,我添加了12个IP地址
[3]让配置生效
#/etc/init.d/networking restart
[4]检查效果
root@ubuntu:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:26:b9:86:13:fb
inet addr:213.128.82.162 Bcast:213.128.82.175 Mask:255.255.255.240
inet6 addr: fe80::226:b9ff:fe86:13fb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:134 errors:0 dropped:0 overruns:0 frame:0
TX packets:134 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:15404 (15.4 KB) TX bytes:17608 (17.6 KB)
eth0:0 Link encap:Ethernet HWaddr 00:26:b9:86:13:fb
inet addr:213.128.82.163 Bcast:213.128.82.175 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:1 Link encap:Ethernet HWaddr 00:26:b9:86:13:fb
inet addr:213.128.82.164 Bcast:213.128.82.175 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:2 Link encap:Ethernet HWaddr 00:26:b9:86:13:fb
inet addr:213.128.82.165 Bcast:213.128.82.175 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:3 Link encap:Ethernet HWaddr 00:26:b9:86:13:fb
inet addr:213.128.82.166 Bcast:213.128.82.175 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:4 Link encap:Ethernet HWaddr 00:26:b9:86:13:fb
inet addr:213.128.82.167 Bcast:213.128.82.175 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:5 Link encap:Ethernet HWaddr 00:26:b9:86:13:fb
inet addr:213.128.82.168 Bcast:213.128.82.175 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:6 Link encap:Ethernet HWaddr 00:26:b9:86:13:fb
inet addr:213.128.82.169 Bcast:213.128.82.175 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:7 Link encap:Ethernet HWaddr 00:26:b9:86:13:fb
inet addr:213.128.82.170 Bcast:213.128.82.175 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:8 Link encap:Ethernet HWaddr 00:26:b9:86:13:fb
inet addr:213.128.82.171 Bcast:213.128.82.175 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:9 Link encap:Ethernet HWaddr 00:26:b9:86:13:fb
inet addr:213.128.82.172 Bcast:213.128.82.175 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:10 Link encap:Ethernet HWaddr 00:26:b9:86:13:fb
inet addr:213.128.82.173 Bcast:213.128.82.175 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:11 Link encap:Ethernet HWaddr 00:26:b9:86:13:fb
inet addr:213.128.82.174 Bcast:213.128.82.175 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:155 errors:0 dropped:0 overruns:0 frame:0
TX packets:155 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:14630 (14.6 KB) TX bytes:14630 (14.6 KB)
可以看到三个IP地址,就说明配置成功了。