shell-自动更改LINUX服务器IP
来源:互联网 发布:金融数据终端 编辑:程序博客网 时间:2024/04/29 20:46
#!/bin/bashecho "Enter the old ip:"$1echo "Enter the new ip:"$2if [[ $1 == "" ]];then echo "Usage: $0 Enter the new ip:$1" echo "Usage: $0 Enter the old ip:$2" exit 0fii=0for line in `ls /etc/sysconfig/network-scripts | grep -E "ifcfg-em|ifcfg-eth"`dostrip=`cat /etc/sysconfig/network-scripts/$line | grep -i "$1"`strboot=`cat /etc/sysconfig/network-scripts/$line | grep -i "^onboot" | awk -F '=' '{print $2}' | grep -i "yes"`if [ -n "$strip" -a -n "$strboot" ];thenecho $linefile=$lineecho $stripecho $strbootipfile="/etc/sysconfig/network-scripts/$file"hostnamefile="/etc/sysconfig/network"sed -i 's/^IPADDR/#IPADDR/g' $ipfile#sed -i 's/^NETMASK/#NETMASK/g' $ipfilesed -i 's/^GATEWAY/#GATEWAY/g' $ipfilesed -i 's/^HOSTNAME/#HOSTNAME/g' $ipfilesed -i 's/^HOSTNAME/#HOSTNAME/g' $hostnamefilenewip=$2newgateway=newhostname=cat >>$ipfile<<EOFIPADDR="$newip"GATEWAY="$newgateway"EOFecho "HOSTNAME=\"$newhostname\"" >>$hostnamefilehostname "$newhostname"echo "OK"else echo $lineecho $stripecho $strbootecho "error"fidone
0 0
- shell-自动更改LINUX服务器IP
- Linux 更改自动获取IP为静态
- Linux上DHCP服务器自动绑定IP和MAC地址shell脚本
- linux 自动ping ip的shell脚本
- Linux使用shell编程自动切换IP
- Linux使用shell编程自动切换IP
- Linux下Shell实现服务器IP监测
- linux 自动获取FTP服务器文件shell
- 嵌入式Linux更改IP
- 更改 linux shell提示符
- linux 更改shell
- Linux 更改默认shell
- 更改EBS服务器域名/IP
- linux 更改服务器时间
- linux下更改ip、网关
- 关于更改linux ip地址
- linux虚拟机ip地址更改
- 虚拟机Linux IP地址更改
- String和StringBuilder和StringBuffer
- 2014.8.5毕业后工作第一个月
- ListView点击头排序
- repo init - gpg: 无法检查签名:找不到公钥
- C++ 构造转换函数和强制转换函数
- shell-自动更改LINUX服务器IP
- hdu how many tables
- 屌丝程序员赚钱之道之taobao 2
- 如何在linux下查看电脑硬件设备属性
- python 功能函数
- 如何在Android平台上使用JS直接调用Java方法
- java 日期(Date DateFormat Calendar)
- ubuntu 中eclipse 无法找到系统标准头文件
- 工作日志