码迷,mamicode.com
首页 > 其他好文 > 详细

auto change ip and hostname

时间:2017-07-06 10:04:36      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:auto change ip and hostname

#!/bin/sh

ETHCONF=/etc/sysconfig/network-scripts/ifcfg-eth0

HOSTS=/etc/hosts

NETWORK=/etc/sysconfig/network 

NETMASK=255.255.255.0

###

function Change_ip ()

{

grep "dhcp"  $ETHCONF

if [ $? -eq 0 ];then

    read -p "Please insert ip Address:" IPADDR

    sed -i ‘s/dhcp/static/g‘ $ETHCONF

echo -e "IPADDR=$IPADDR\nNETMASK=$NETMASK\nGATEWAY=`echo $IPADDR|awk -F. ‘{print $1"."$2"."$3}‘`.2" >>$ETHCONF

echo "This IP address Change success !"

auto change ip and hostname

标签:auto change ip and hostname

原文地址:http://mustafayin.blog.51cto.com/12558614/1944872

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!