Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1730927
  • 博文数量: 234
  • 博客积分: 4966
  • 博客等级: 上校
  • 技术积分: 3322
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-13 01:03
文章分类

全部博文(234)

文章存档

2017年(2)

2016年(1)

2015年(8)

2014年(11)

2013年(44)

2012年(27)

2011年(22)

2010年(30)

2009年(37)

2008年(6)

2007年(45)

2006年(1)

分类: 服务器与存储

2013-08-10 14:31:36

自动更新花生壳的ip

参考:

只能使用GET方式提交信息,这里使用curl,需提前安装好curl。
加一个判断,如果当前dns中的ip和检测的ip不一致时,就自动提交;一致则退出。

#!/bin/bash
orayuser=your oray name
oraypass=your oray passoword
oraydomain=your domain
realip=`curl  | cut -d' ' -f 6 | cut -d'<' -f 1`
theurl=""
currentip=`nslookup $oraydomain | tail -2 | head -1 | cut -d' ' -f 2`
if [ "$realip" = "$currentip" ]; then
 exit 0
else
 curl "$theurl"
fi

在crontab中加入以下内容,每十五分钟检测一次

*/15 * * * * /bin/bash /root/pushiporay.sh

–添加于2013年3月3日开始–

后来申请了noip.com的二级域名,才发现花生壳和人家的api是如此的像。同理可更新noip里的记录

#!/bin/bash
noipuser=your noip username
noippass=your noip password
noipdomain=your noip domain
realip=`curl  | cut -d' ' -f 6 | cut -d'<' -f 1`
noipurl=""
noipcurrentip=`nslookup $noipdomain | tail -2 | head -1 | cut -d' ' -f 2`
if [ "$realip" = "$noipcurrentip" ]; then
 echo "no need to update"
 exit 0
else
 curl "$noipurl"
fi

 转载自:

阅读(2826) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~