一键修改IP多实例-v1
#!/bin/bash #2020-03-01 #auto change ip #By Flyaway ###################### grep "dhcp" /etc/sysconfig/network-scripts/ifcfg-ens33 if [ $? -eq 0 ];then cat >/etc/sysconfig/network-scripts/ifcfg-ens33 <<EOF TYPE=Ethernet BOOTPROTO=static DEFROUTE=yes DEVICE=ens33 ONBOOT=yes IPADDR=192.168.1.19 PREFIX=24 GATEWAY=192.168.1.1 DNS1=114.114.114.114 EOF fi cat /etc/sysconfig/network-scripts/ifcfg-ens33 systemctl restart network ifconfig
一键修改IP多实例-v2
#!/bin/bash #2020-03-01 #auto change ip #By Flyaway ###################### ETH_FIX="24" ETH_NAME="ens33" ETH_WAY="192.168.1.1" ETH_IP="192.168.1.19" ETH_DNS="114.114.114.114" ETH_BAK="/data/backup/$(date +%Y%m%d%H%M%S)" ETH_DIR="/etc/sysconfig/network-scripts/" cd $ETH_DIR if [ ! -d $ETH_BAK ];then mkdir -p $ETH_BAK fi cp ifcfg-$ETH_NAME $ETH_BAK grep "dhcp" ifcfg-$ETH_NAME if [ $? -eq 0 ];then cat >ifcfg-$ETH_NAME <<EOF TYPE=Ethernet BOOTPROTO=static DEFROUTE=yes DEVICE=$ETH_NAME_ ONBOOT=yes IPADDR=$ETH_IP PREFIX=$ETH_FIX GATEWAY=$ETH_WAY DNS1=$ETH_DNS EOF fi cat ifcfg-$ETH_NAME systemctl restart network ifconfig $ETH_NAME
一键修改IP多实例-v3
#!/bin/bash #2020-03-01 #auto change ip #By Flyaway ###################### ETH_IP="$1" ETH_FIX="24" ETH_NAME="ens33" ETH_WAY="192.168.1.1" ETH_DNS="114.114.114.114" ETH_DIR="/etc/sysconfig/network-scripts/" ETH_BAK="/data/backup/`date +%Y%m%d%H%M%S`" if [ $# -eq 0 ];then echo -e "