脚本放在root目录下即可

#! /bin/sh 
#change ip and change domian ip
# by waitli
source /etc/profile

DATE=$(date +%Y%m%d%H%M%S)
function ppoe
{
  /usr/sbin/pppoe-stop 
  sleep 5s
  /usr/sbin/pppoe-start
  sleep 10s
  /usr/bin/ping -c 1 xxxxx.xxxxx.net > /dev/null 2>&1  #检测  
  if [ $? -eq 0 ];then  
     echo "networkok ">/opt/ip.log
  else  
     ppoe 
  fi 
}
ppoe
sleep 1s 
function change 
  {
    /usr/bin/lynx -mime_header -auth=xxxx:xxx "http://members.xxxxx.net/dyndns/update?system=dynd
ns&hostname=porxy.xxxxxx.net"  > /dev/null 2>&1
  
   /usr/bin/ping -c 1 porxy.xxxxx.net  > /dev/null 2>&1
   if [ $? -eq 0 ];then
       echo "domainok ">/opt/ip.log
       echo $DATE >>/opt/ip.log
   else
        sleep 10s
        change
   fi
  }

change

版权声明:本文为原创文章,版权归 Wait li 的运维笔记 所有,转载请联系博主获得授权!
本文地址:http://waitli.top/index.php/archives/34/

评论已关闭

×