有时候,我们购买了5个IP,13个IP,难道都要一个一个的来写配置文件吗?Centos如何快速绑定多个IP?可否做到一个配置文件即可?可以!
可以在/etc/sysconfig/network-scripts下创建一个range文件
比如,vi /etc/sysconfig/network-scripts/ifcfg-eth0-range0
DEVICE=eth0BOOTPROTO=staticIPADDR_START=64.120.228.163IPADDR_END=64.120.228.166CLONENUM_START=8NETMASK=255.255.255.248ONBOOT=yes
CLONENUM_START — 网络克隆接口的启始号. # eg “1″ 生成的网络接口会从 eth0:1开始。
然后重启网络让IP生效: service network restart
NETMASK 子网掩码 参考表:
/29 (5 usable) NETMASK = 255.255.255.248
/28 (13 usable) NETMASK = 255.255.255.240
/27 (29 usable) NETMASK = 255.255.255.224
/26 (61 usable) NETMASK = 255.255.255.192
/25 (125 usable) NETMASK = 255.255.255.128
/24 (253 usable) NETMASK = 255.255.255.0
IP段/28举例: 64.120.220.224/28
The first two IPs (network & gateway) and the last IP (broadcast) in your assignment are unusable for you.
Network: 64.120.220.224
Gateway: 64.120.220.225
Broadcast: 64.120.220.239
Useable IPs: 64.120.220.226-238 (13 useable)
NETMASK = 255.255.255.240
联系客服