• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >linux shell > ubuntu与centos中更换ip的shell代码

ubuntu与centos中更换ip的shell代码

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了ubuntu和centos区别,centos和ubuntu哪个好,centos ubuntu,centos ubuntu比较,ubuntu还是centos等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

代码一
ubuntu与centos

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
</div>

</div>

您可能想查找下面的文章:

  • ubuntu与centos中更换ip的shell代码

相关文章

  • linux下采用shell脚本实现批量为指定文件夹下图片添加水印的方法
  • Linux BASH多进程并行处理的方法实现
  • shell中的循环语句、判断语句实例
  • 在 Shell 提示符中显示 Git 分支名称的方法
  • Shell中判断字符串是否为数字的6种方法分享
  • 一个简单的转换输出的shell脚本代码
  • Shell脚本实现防止国外ip访问服务器
  • linux shell 字符串操作(长度,查找,替换)详解
  • Shell踢人的三种方法
  • linux shell实现守护进程脚本

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • getcwd cannot access parent directories错误解决方法
    • 脚本实现SSH登录邮件报警
    • 批量转换目录下文件编码的shell脚本代码
    • Shell脚本判断Linux系统是32位还是64位的几种方法分享
    • 5个实用的shell脚本面试题和答案
    • Linux Shell脚本系列教程(二):终端打印命令详解
    • expect实现批量修改linux密码脚本分享
    • Linux进程间通信——使用流套接字
    • bash脚本编程学习之算术运算与文件查找
    • shell字符串操作详解

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有