Linux下最简单的动态域名解析

一、准备材料

1、在国内动态域名解析一般使用花生壳,即oray.com这个家伙,可以免费申请一个二级域名(oray帐号一个);
2、注册了oray帐号你就能申请到一个免费的支持动态域名解析的二级域名(支持动态域名解析的域名一个);
3、如果你有自己的顶级域名,觉得使用别人的二级域名不够屌,可以呀,做别名处理简单搞定(顶级域名一个,这个没有没关系);
4、Linux或Unix或类Unix主机一台(我在这里针对小米路由器做测试,前提是小米路由器已经root了,能够ssh登录后台);

二、基本原理

1、假如家里使用的ADSL拨号上网,路由器上会获得一个公网ip地址;
2、我想通过某个域名对应这个ip地址,但这个ip地址随着每次的拨号都会发生变化;
3、通过某种机制,当ip发生变化时告诉DNS服务器,让他即时更新;
4、问题来了,谁来告诉DNS服务器ip变了?这是我们今天的重点!

三、解决方案

1、小米路由器在路由模式下支持DDNS,直接输入花生壳的用户名及密码,对应域名,路由器会自动上报ip给oray的DNS服务器更新;
2、如果在桥接模式下,路由器的DDNS功能无法使用,至少界面上无法操作到了,实际上应该是能用的,因为小米路由器本身不也要升级吗?
3、oray是有PC客户端的,但总不能为了一个动态ip搞台电脑24小时待机,不实在,有嵌入式的客户端那可接受,小米路由器支持该功能实际上就是安装了这种嵌入式的小客户端;
4、如果没有,还有一个办法可以解决,啰嗦了这么多总算谈到重点上了,先看看花生壳官网的 说明

1
2
3
4
5
6
7
8
9
方式1:使用URL验证     适用于浏览器或应用程序(fetch, curl, lwp-request)
访问地址:http:/username:[email protected]/ph/update?hostname=yourhostname&myip=ipaddress
 
方式2:原始HTTP GET访问    如何在ROS中设置花生壳ddns
GET /ph/update?hostname=yourhostname&myip=ipaddress HTTP/1.0
Host: ddns.oray.com
Authorization: Basic base-64-authorization
User-Agent: Oray
注:其中 base-64-authorization 请使用 Base64 加密 username:password 后的字符替换

四、实现方式

1.1、vi /etc/rc.local
1.2、在exit 0前面添加一行内容如下,实现开机即自动刷新一次;

1
wget -q -O /tmp/log/oray.log 'http://用户名:密码@ddns.oray.com/ph/update?domain= 动态域名'

中文部分根据实际替换
2.1、vi /etc/crontabs/root
2.2、在最后面添加一行,实现每10分钟自动刷新一次;

1
*/10 * * * * wget -q -O /tmp/log/oray.log 'http://用户名:密码@ddns.oray.com/ph/update?domain=动态域名'

参考链接:Linux如何设置定时任务

One thought on “Linux下最简单的动态域名解析

  1. JamesPew

    It can be daunting trying to figure out what you need to do once you have been diagnosed with sleep apnea. There are so many new things to learn, and you may feel a bit overwhelmed. Reading this article can provide you with some simple steps to take to make the transition much easier.

    You really need to do your best to lose weight if you have sleep apnea. Those who have sleep apnea typically have a neck circumference of 17 inches or more. This excess weight around the throat causes the airway to collapse more easily during sleep. Reducing your weight by even ten pounds can have a beneficial impact on your sleep apnea.

    Try your best to lay off tobacco and nicotine products. Cigarette smoke can irritate your upper airway causing it to swell up, subsequently hindering your ability to breath during the night. Quitting smoking could therefore, significantly improve your sleep apnea symptoms and will also improve your body’s overall health and your feelings of well-being.

    If you suffer from sleep apnea, it is vital to avoid consuming alcohol before bedtime. Alcohol acts as a sedative, therefore, it will naturally slow down your breathing. In addition, it will relax all the muscles in your body, including those in your throat that help to keep your airway open.

    Lose a bit of weight to get rid of your sleep apnea. Many people have corrected their apnea by losing weight. Even a few pounds can help your sleep apnea symptoms.

    Don’t give up on treatment for sleep apnea after one doesn’t work. There are a variety of treatments for your condition, so finding the right one is sometimes a process of trial and error. The number and severity of your symptoms influence what treatment is correct one for you. Giving multiple treatments a chance ensures you find the one that works the most effectively.

    Sleep apnea does not go away on its own; patients need treatment. Some treatments work better for different people. If you lose weight you will help your sleep apnea, but this is not always the cause. CPAP machines are considered non-invasive, and many people use them successfully. Others prefer surgery to relieve their sleep apnea. Choose whichever method you think will work for you so you may begin to live a happy and comfortable life.

    A great way to ensure that you do not sleep on your back and cause sleep apnea to occur is to use a tennis ball to prevent rolling onto your back. You can place one in a pillow behind your back and when you roll over in your sleep, the tennis ball will make you roll back on your side.

    People who use alcohol, sedatives, and sleeping pills are far more likely to suffer from sleep apnea. This is because these drugs will relax the throat and cause their breathing to be impaired. Using these drugs before bedtime is more likely to cause sleep apnea than using these drugs during the day.

    By reading through the great sleep apnea tips found in this article, you are ready to face your problem head on. While you may not be able to rid yourself of the problem completely, you will feel more confident and start working towards that all-important goal, a good night’s sleep.

    viagrasansordonnancefr.com

Leave a Reply