校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > ubuntu與centos中更換ip的shell代碼

ubuntu與centos中更換ip的shell代碼

熱門標簽:昆明電話外呼系統好么 電話機器人每天搜索多少次 艾比利外呼系統 衡水外呼線路解決 免費門店地圖標注注冊入駐 陜西便宜電銷機器人軟件 外呼系統一天耗費多少流量 海口智能語音電銷機器人好用嗎 杞縣地圖標注app

代碼一
ubuntu與centos

復制代碼 代碼如下:

ubuntu:
#!/bin/bash
echo "ipaddr:"
read line
echo $line
sed "s/address.*$/address=${line}/g" /etc/network/interfaces
centos(未測試):
#!/bin/bash
echo "ipaddr:"
read line
echo $line
sed "s/IPADDR.*$/IPADDR=${line}/g" /etc/sysconfig/network-scipts/ifcfg-eth0

代碼二
ubuntu更改IP的shell代碼,自己寫的,比較拙,請指正
復制代碼 代碼如下:

#! /bin/sh

echo "Use gateway at 192.168.0.1 (Y) or 192.168.1.1 (N)
or detail set (O)\nPlease choose Y/N/O"
read OP
if [ "$OP" = Y ] || [ "$OP" = y ] ; then
 GATEWAY=192.168.0.1
 IP=192.168.0.215
elif [ "$OP" = N ] || [ "$OP" = n ] ; then
 GATEWAY=192.168.1.1
 IP=192.168.1.215
else
 echo "Please input the ip:"
 read IP
 echo "Please input the gateway"
 read GATEWAY
fi
echo "auto lo
iface lo inet static

auto eth0
iface eth0 inet static
netmask 255.255.255.0
address $IP
gateway $GATEWAY" > /tmp/interfaces
clear
echo "Init File interfaces Successfully!"
echo "*************************************"
cat /tmp/interfaces
echo "*************************************"
echo "Change the file in /etc/networks/interfaces?(Y/N)"
read OP
if [ "$OP" = Y ] || [ "$OP" = y ] ; then
 echo "Set OK!"
 cp /tmp/interfaces /etc/network/interfaces
 /etc/init.d/networking restart
else
 echo "Give up"
fi
rm /tmp/interfaces
echo "Whether change the DNS(/etc/resolv.conf)(Y/N)"
read OP
if [ "$OP" = Y ] || [ "$OP" = y ];then
 echo "Input the DNS server IP:"
 read IP
 echo "Now change the DNS IP"
 mv /etc/resolv.conf /etc/resolv.conf.bak
 echo "nameserver $IP" >/etc/resolv.conf
 echo "Done!"
fi

您可能感興趣的文章:
  • Ubuntu16.04 靜態IP地址設置(NAT方式)
  • 詳解ubuntu14.04如何設置靜態IP的方法
  • ubuntu 設置靜態IP的實現方法
  • 基于Ubuntu 16.04設置固定IP的方法教程

標簽:昌都 營口 南京 臨滄 海口 宿遷 泰安 西寧

巨人網絡通訊聲明:本文標題《ubuntu與centos中更換ip的shell代碼》,本文關鍵詞  ubuntu,與,centos,中,更換,的,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《ubuntu與centos中更換ip的shell代碼》相關的同類信息!
  • 本頁收集關于ubuntu與centos中更換ip的shell代碼的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 大名县| 大丰市| 永州市| 曲靖市| 繁峙县| 德格县| 广平县| 张家川| 星子县| 新乐市| 潮州市| 岚皋县| 陆川县| 任丘市| 晋州市| 吉木乃县| 新巴尔虎左旗| 岑巩县| 蒲江县| 临高县| 清水河县| 博罗县| 博兴县| 沁阳市| 高尔夫| 云林县| 日喀则市| 福清市| 禹州市| 灵石县| 南部县| 辽阳市| 和硕县| 永胜县| 理塘县| 南靖县| 石门县| 贵溪市| 北安市| 行唐县| 道真|