Linux Shell simple script to modify IP

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.