⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0270dynamic_dns.htm

📁 鸟哥LINUX 学习课本
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<br><font size="-1" color="#ffffff" face="SimSun">email=$email&amp;passwd=$password&amp;hostname=$hostname&amp;debug=1&amp;\</font><br><font size="-1" color="#ffffff" face="SimSun">forceip=$newip"</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;lynx -dump $HOST &gt; /dev/null 2&gt;&amp;1</font><br><font size="-1" color="#ffffff" face="SimSun">}</font></p><p><font size="-1" color="#ffffff" face="SimSun"># 这个函数在更新防火墙机制</font><br><font size="-1" color="#ffffff" face="SimSun">iptablesrule() {</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;[ -f /usr/local/virus/iptables/iptables.rule ] &amp;&amp; \</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;sh /usr/local/virus/iptables/iptables.rule</font><br><font size="-1" color="#ffffff" face="SimSun">}</font></p><p><font size="-1" color="#ffffff" face="SimSun"># 这个函数取得您的DNS 主机名与 IP 是否相同!</font><br><font size="-1" color="#ffffff" face="SimSun">getdnsip (){</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;dnsip=`host $hostname | awk '{print $4}'`</font><br><font size="-1" color="#ffffff" face="SimSun">}</font></p><p><font size="-1" color="#ffffff" face="SimSun">#</font><br><font size="-1" color="#ffffff" face="SimSun">#======================ONLY EMAIL SESSION jobs 1 =====================</font><br><font size="-1" color="#ffffff" face="SimSun">&#160; if ["$jobs" == "1" ]; then</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;# 1. Get the older IP and newer IP</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;oldip</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;getip</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;while [ "$newip" == "" ]</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;do</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;checkip</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;getip</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;done</font></p><p><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;# 2. compare with older IP and newer IP. And e-mail to you</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;if [ "$newip" != "$oldip" ]; then</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;mailtoyou&#160;&#160;&#160;&#160;&#160;&#160; # just mail to you</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;fi</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;exit 0</font><br><font size="-1" color="#ffffff" face="SimSun">&#160; fi</font></p><p><font size="-1" color="#ffffff" face="SimSun">#======================EMAIL and UPDATE SESSION job 2 ================</font><br><font size="-1" color="#ffffff" face="SimSun">&#160; if ["$jobs" == "2" ]; then</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;# 1. Get the older IP and newer IP</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;oldip</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;getip</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;while [ "$newip" == "" ]</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;do</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;checkip</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;getip</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;done</font></p><p><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;# 2. compare with older IP and newer IP. And e-mail to you</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;if [ "$newip" != "$oldip" ]; then</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;mailtoyou&#160;&#160;&#160;&#160;&#160;&#160; # just mail to you</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;updateforyou&#160;&#160;&#160; # just update for you</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sleep 3s</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;iptablesrule&#160;&#160;&#160; # just reflush iptables rule</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;fi</font></p><p><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;# 3. check if the DNS name == newip</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;getdnsip</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;if [ "$newip" != "$dnsip" ]; then</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;updateforyou&#160;&#160;&#160; # just update for you</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sleep 3</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;iptablesrule&#160;&#160;&#160; # just reflush iptables rule</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;fi</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;exit 0</font><br><font size="-1" color="#ffffff" face="SimSun">&#160; fi</font></p><p><font size="-1" color="#ffffff" face="SimSun">#======================SHARE IP MECHANIME job 3 ======================</font><br><font size="-1" color="#ffffff" face="SimSun">&#160; if ["$jobs" == "3" ]; then</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;# 1. Get the older IP and newer IP</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;oldip</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;newip=`lynx -dump "http://www.adsldns.org/login.php?email=$email&amp;passwd=$password"|grep 您好|cut -d":" -f2|sed 's/ .*$//g'`</font></p><p><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;# 2. compare with older IP and newer IP. And e-mail to you</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;if [ "$newip" != "$oldip" ]; then</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;mailtoyou&#160;&#160;&#160;&#160;&#160;&#160; # just mail to you</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;updateforyou&#160;&#160;&#160; # just update for you</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sleep 3s</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;iptablesrule&#160;&#160;&#160; # just reflush iptables rule</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;fi</font></p><p><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;# 3. check if the DNS name == newip</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;getdnsip</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;if [ "$newip" != "$dnsip" ]; then</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;updateforyou&#160;&#160;&#160; # just update for you</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sleep 3</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;iptablesrule&#160;&#160;&#160; # just reflush iptables rule</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;fi</font><br><font size="-1" color="#ffffff" face="SimSun">&#160;&#160;&#160;&#160;&#160;&#160;&#160;exit 0</font><br><font size="-1" color="#ffffff" face="SimSun">&#160; fi</font></p></td></tr></tbody></table> <br>上面的 script 您可以在 <a href="http://linux.vbird.org/download/index.php#ping_net_card" target="_blank">http://linux.vbird.org/download/index.php#ping_net_card</a>下载,至于安装的方法就相当的简单啦!您只要下载该 script ,然后将他移动到适当的目录之下,修改一下上面显示粗体字的地方,然后再修改您的/etc/crontab !嘿嘿!那就成功啰!<br> <table bgcolor="#000000" border="1" cols="1" width="650"><tbody><tr><td><font size="-1" color="#ffffcc" face="SimSun">1. 下载 script并移动到适当的目录:</font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]# </font><font color="#ffff00">wget http://linux.vbird.org/download/vbird/ping_net_card.sh</font></font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]# </font><font color="#ffff00">mkdir -p /usr/local/pingcard</font></font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]# </font><font color="#ffff00">cp ping_net_card.sh /usr/local/pingcard</font></font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]# </font><font color="#ffff00">chmod 744 /usr/local/pingcard/ping_net_card.sh</font></font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]# </font><font color="#ffff00">vi /usr/local/pingcard/ping_net_card.sh</font></font><br><font size="-1" color="#ff6666" face="SimSun"># 这个时候进入vi 的画面,请依照您的需求来修改 INPUT 的部分!</font><br><font size="-1" color="#ffff99" face="SimSun"> </font><br><font size="-1" color="#ffffcc" face="SimSun">2. 修改 crontab&#160;</font><br><font size="-1" color="#ffffff" face="SimSun">[root@testroot]# vi /etc/crontab</font><br><font size="-1" color="#ff6666" face="SimSun"># ....新增加一行:</font><br><font size="-1" color="#ffffff" face="SimSun">*/3 * * * *root /usr/local/pingcard/ping_net_card.sh</font></td></tr></tbody></table> <br>嘿嘿!这样一来,如果您的主机不正常的断电之后,在三分钟之内就会自动的拨接,此外,还会自动的上网去更新您的DNS 主机名称!还会 e-mail 到您的信箱去!告诉您最新的 IP 是什么!哈哈!简不简单呀!?( 注:因为我没有 cable modem ,所以在 cable 的部分我是经由网友回报而做成的script !此外,我也没有 IP 分享器!所以第三个 jobs=3 还没有测试过!无论如何,jobs=1 是完全没有问题的!此外,针对朋友们常常发生的 lynx 没有安装的问题,这是我也先将他写了一个小小的检查档案,可以告诉朋友们!嘿!您的lynx 安装了没?! )<br> <br><hr width="100%"><a name="need_dynamic_noip"></a><font color="#000099">动态DNS -- http://www.no-ip.com</font><br> <br>除了 www.adsldns.org 之外,我们还有其它的选择,那就是 no-ip 这家公司所提供的免费动态DNS 系统啦!申请的方法如下:<br> <ol><li><font color="#000099">登入主网页:</font></li><br>在如下的图示当中,因为我们要注册一个新的网域,所以就给他选择如下的『<font color="#000066">Sign-up-Free!</font>』那一项:<br><img src="0270dynamic_dns_files/no-ip-01.jpg" nosave="" height="171" width="503"><br> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -