在linux下,配置多个IP的话,通常是eth0.0.. eth0.1 ..eth0.x等等, 那么如果要配置大量的IP呢,这么配置也是可以的,但是繁琐,虽说这种情况很少。 对于添加大量IP,有一定规定的,RHCE / CentOS 系统提供绑定一个IP范围快速的方法让我们不再需要创建大量的文件,节省时间。如:
# vim /etc/sysconfig/network-scripts/ifcfg-eth0-range0
IPADDR_START=192.168.1.199
IPADDR_END=192.168.1.249
CLONENUM_START=0
NETMASK=255.255.255.0
IPADDR_START是第一IP, IPADDR_END是最后一个IP。 CLONENUM_START是将被分配给一系列的接口开始编号(该实例中是从eth0:0开始的)。 激活网卡:
ifdown eth0 && ifup eth0
结果如下
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.253.7.221 netmask 255.255.248.0 broadcast 10.253.7.255
ether 00:16:3e:0c:27:5a txqueuelen 1000 (Ethernet)
RX packets 491927058 bytes 80354909662 (74.8 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 417715253 bytes 63353677248 (59.0 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.199 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:16:3e:0c:27:5a txqueuelen 1000 (Ethernet)
eth0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.200 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:16:3e:0c:27:5a txqueuelen 1000 (Ethernet)
eth0:2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.201 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:16:3e:0c:27:5a txqueuelen 1000 (Ethernet)
eth0:3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.202 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:16:3e:0c:27:5a txqueuelen 1000 (Ethernet)
eth0:4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.203 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:16:3e:0c:27:5a txqueuelen 1000 (Ethernet)
eth0:5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.204 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:16:3e:0c:27:5a txqueuelen 1000 (Ethernet)
eth0:6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.205 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:16:3e:0c:27:5a txqueuelen 1000 (Ethernet)
eth0:7: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.206 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:16:3e:0c:27:5a txqueuelen 1000 (Ethernet)
eth0:8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.207 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:16:3e:0c:27:5a txqueuelen 1000 (Ethernet)
……