centos7如何快速添加ip

添加不同段ip;编辑网卡eth0(网卡名)

vi /etc/sysconfig/network-scripts/ifcfg-eth0:1

 

DEVICE=eth0:1

BOOTPROTO=static

IPADDR=155.138.10.10

NETMASK=255.255.255.0

GATEWAY=网关地址 

ONBOOT=yes

 

重启网卡  service network restart

 

批量添加ip段

vi /etc/sysconfig/network-scripts/ifcfg-eth0-range

 

IPADDR_START=133.160.1.2(开始ip)

IPADDR_END=133.160.1.5(结束ip)

GATEWAY=网关地址 

PREFIX=24

CLONENUM_START=0

 

重启网卡  service network restart

 

批量添加ip段方法2(仅限centos7)

for I in $(seq 178 182); do nmcli con mod eth0 +ipv4.addresses 173.247.235.${I}; done

      (seq 开始ip 结束ip)     (eth0为网卡名)   (173.247.234.为ip段)

重启网卡  service network restart