#!/bin/sh
i=1
echo "please input your ips: "
while :
do
  read ip
  if [[ ${ip} != "" ]]
  then
    echo "DEVICE=eth0:$i" > ifcfg-eth0:$i
    echo "BOOTPROTO=static" >> ifcfg-eth0:$i
    echo "DHCPCLASS=" >> ifcfg-eth0:$i
    echo "HWADDR=mac_addr" >> ifcfg-eth0:$i
    echo "IPADDR=${ip}" >> ifcfg-eth0:$i
    echo "NETMASK=255.255.255.0" >> ifcfg-eth0:$i
    echo "ONBOOT=yes" >> ifcfg-eth0:$i
  else
    exit 0
  fi
  let i++
done

生成的文件保存在当前目录下,检查清楚无误后复制到/etc/sysconfig/network-scripts/目录下

使用时请先根据实际修改相关配置,再运行!!!

本文出自 “MicalLi's Blog” 博客,请务必保留此出处http://micalli.blog.51cto.com/509064/833382