强烈向大家推荐一个好网站,【我要自学网】,教程由在校老师录制,有办公会计、平面设计、室内设计、机械设计、网页编程、影视动画等教程.....让你足不出门,都可以体验学校的专业教育!
Centos7
for I in $(seq 1 254); do nmcli con mod eth0 +ipv4.addresses 192.168.242.${I}/24; done
Centos6
在/etc/sysconfig/network-scripts/中新建文件ifcfg-eth0-range0
vi /etc/sysconfig/network-scripts/ifcfg-eth0-range0
#输入以下文件内容格式:
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR_START=起始IP地址
IPADDR_END=结束IP地址
CLONENUM_START=0
GATEWAY=网关地址
NETMASK=子网掩码
NO_ALIASROUTING=yes
保存后,运行service network restart重启网络服务即可
debian
编辑保存 vi /etc/network/ipboot.sh
以下不用配置主ip for i in {195..222};do ip addr add 156.226.120.$i/27 dev eno1;done for i in {226..254};do ip addr add 156.226.121.$i/27 dev eno1;done for i in {2..30};do ip addr add 156.226.122.$i/27 dev eno1;done for i in {34..62};do ip addr add 156.226.123.$i/27 dev eno1;done for i in {66..94};do ip addr add 156.226.124.$i/27 dev eno1;done for i in {98..126};do ip addr add 156.226.125.$i/27 dev eno1;done for i in {130..158};do ip addr add 156.226.126.$i/27 dev eno1;done for i in {162..190};do ip addr add 156.226.127.$i/27 dev eno1;done
编辑保存vi /etc/rc.local 复制以下
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. cd ./etc/network/ bash ipboot.sh exit 0
然后执行
chmod 777 /etc/network/ipboot.sh chmod 777 /etc/rc.local systemctl restart rc-local 然后重启 reboot