国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

ubuntu與centos中更換ip的shell代碼

2019-10-26 18:36:21
字體:
來源:轉載
供稿:網友

代碼一
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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 德兴市| 常山县| 电白县| 贡山| 奉化市| 绿春县| 灌云县| 闵行区| 靖江市| 深圳市| 连南| 安泽县| 当阳市| 伊宁市| 永年县| 唐山市| 晋州市| 平果县| 曲水县| 伊春市| 会宁县| 甘谷县| 黄骅市| 高雄市| 通渭县| 海宁市| 武汉市| 泸州市| 武冈市| 大宁县| 乌拉特前旗| 友谊县| 泰来县| 长阳| 石台县| 黑山县| 安陆市| 阿合奇县| 清流县| 磴口县| 华蓥市|