程冬冬 2010.04.28 shell

作者:2008级嵌入式  程冬冬

#将下面内容保存为 cdd.sh 文件
#! /bin/sh                                            //shell标准注释
ifdown eth0                                           //关闭eth0网卡
ifconfig eth0 192.168.1.98 up                         //设置eth0 ip地址,并启动
route add default gw 192.168.1.1                      //设置网关
echo nameserver 211.84.160.8 > /etc/resolv.conf       //添加DNS服务器
ping -c 1 www.baidu.com
if [ $? -eq 0 ]                                       //测试ping结果
then
 echo 实验成功
else
  echo 网络不通
fi

[root@localhost ~]# chmod +x cdd.sh
[root@localhost ~]# ./cdd.sh

posted @ 2016-03-30 10:00  张同光  阅读(38)  评论(0编辑  收藏  举报