逍遥游

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh

# check ip change and update it



ip_regex="[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}"



ipaddr=$(ifconfig pppoe-wan | awk '/inet /{print $2}' |grep -o "$ip_regex" )

old_ipaddr=$(ping -c 1 kang.ddns.info|head -1 | grep -o "$ip_regex")





if [ "$ipaddr" != "$old_ipaddr" ];then


# 发邮件
echo "Subject:$ipaddr" | ssmtp -v robot12123@334343.net

# 更新
wget -q -O /tmp/ddns --no-check-certificate 'https://nic.changeip.com/nic/update?u=XXX&p=XXX&hotname=kk'



fi