你的位置: Kiyo'Space首页 服务器 阅读文章 欢迎留下您的足迹

Centos如何快速绑定多个IP(一个配置文件即可)

[ 服务器 ] 分享

有时候,我们有数十个IP,难道都要一个一个的来写配置文件吗?Centos如何快速绑定多个IP?可否做到一个配置文件即可?可以!

可以在/etc/sysconfig/network-scripts下创建一个range文件

比如,vi /etc/sysconfig/network-scripts/ifcfg-eth0-range0

DEVICE=eth0
BOOTPROTO=static
HWADDR=00:1c:c0:fd:0f:27
IPADDR_START=64.120.228.163
IPADDR_END=64.120.228.166
CLONENUM_START=1
NETMASK=255.255.255.248
ONBOOT=yes
TYPE=Ethernet

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

没有评论

  • (Required)
  • (Required, will not be published)