Tag: Shell Modify IP
#!/bin/bash#2017-7-13#by ip_file=/etc/sysconfig/network-scripts/ifcfg-eth0zt= ' grep "static" $IP _file|wc -l ' bf_file=/data/ifcfg-eth/' date "+%y_%m_%d" '/ipaddr= "192.168.25.107" netmask= "255.255.255.0 "Getaway=" 192.168.25.2 "#备份原来的配置文件 #back up the original configuration fileif [ ! -d $Bf _file ];thenmkdir -p $Bf _fileficp $ip _file $Bf _file# Modify ip# change ipif [ $zt -eq 1 ];thensed -i s#ipaddr.* #IPADDR = $IPADDR #g $ip _filesed -i s#netmask.* #NETMASK = $netmask #g $ip _filesed -i s#gateway.* #GATEWAY =$ getaway#g $ip _fileelsesed -i s#bootproto.* #BOOTPROTO =static#g $ip _filecat > > $ip _file<< eofipaddr= $IPADDRNETMASK = $netmaskGATEWAY = $getawayEOFfi # Restart the service and print the configuration file #restart the service and print the configuration filesleep 2service network restartecho "_________________________________ "cat $ip _fileecho " _________________________________ "ifconfigecho " ________________________________ "Ifconfig eth0
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/9B/CD/wKioL1lnNqmTZfuYAAQF1aT1ixQ429.png "title=" Enjoy. png "alt=" Wkiol1lnnqmtzfuyaaqf1at1ixq429.png "/>
This article is from the "Tiandaochouqin" blog, make sure to keep this source http://taindaochouqin.blog.51cto.com/12995943/1947248
Linux Shell simple script to modify IP