Configuring IP addresses and hostname scripts

Source: Internet
Author: User

#!/bin/bash# modifying IP and hostname ethconf=/etc/sysconfig/network-scripts/ifcfg-eth0 HOSTS=/etc/hosts NETWORK=/etc/sysconfig/Network DIR=/root/backup/'Date+%y%m%d ' NETMASK=255.255.255.0  functionchange_ip () {if[!-d $DIR]; Then mkdir-P $DIRfi Echo "Now change IP address, Doing Backup Interface eth0" CP$ETHCONF $DIR Read-P"Please insert IP address:"ipaddrsed-I."s/ipaddr=.*/ipaddr= $IPADDR/g"$ETHCONFEcho "This IP address change success!" }functionchange_hosts () {if[!-d $DIR]; Then mkdir-P $DIRfi   CP$HOSTS $DIREcho "Please insert IP and HOSTNAME"Read-P"Please insert IP address": ipaddr Read-P"Please insert HOSTNAME": hostnamesif[-N $IPADDR-n $HOSTNAMES]; Then Echo$IPADDR $HOSTNAMES >>$HOSTSsed-I."s/hostname=.*/hostname= $HOSTNAMES/g"$NETWORKEcho "This hosts change success"Else Echo "This $host is Exist ....."fi} PS3="Please Select IP or hosts Menu":  SelectIinch "change_ip" "change_hosts" "Reboot" "Quit"    Do Case$iinchchange_ip)   CHANGE_IP;;   change_hosts) change_hosts;; Reboot)Sync;Sync;Sync; init6;; Quit) Exit0;; *)   Echo  Echo "Please Insert $0:change_ip (1) | Change_hosts (2)"  Echo;; Esac  Done

Reference: http://www.jb51.net/article/56611.htm

Configuring IP addresses and hostname scripts

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.