openwrt设置ddns

openwrt默认的动态域名服务不好使,最后还是跟着大家使用wget的方法实现动态域名的功能

使用wget来更新:

wget -q -O- 'http://user:[email protected]/dyndns/update?system=dyndns&hostname=xyz.3322.org'

把上面这段命令写入到一个脚本(/usr/bin/ipup),然后使用 crontab来定时也运行这个脚本就行了
crontab的格式:

|分钟 |小时|日|月|星期|command
|-
|* /10|||||/usr/bin/ipup &> /dev/null
crontab -e然后输入:

*/10 * * * * /usr/bin/ipup &> /dev/null

设置好了定时运行ipup脚本,这样我们就把域名绑定到自己的路由器上了。

  • 之后还的设置好防火墙允许外部IP访问自己打开的端口比如22,然后再设置好端口转发才能在外网访问内网的网络服务。
    OpenWrt下有统一的配置方式便于我们制定自己的防火墙策略,这样避免了大家直接使用iptables的麻烦。防火墙的设置也很简洁
    可以自己看/etc/config/firewall里面的实例。比如我想开启自己的ssh服务,那么可以在里面添加相应的规则:
config 'rule'
    option '_name' 'ssh'  #定义名称
    option 'src' 'wan'#访问来源
    option 'proto' 'tcp' #使用的协议
    option 'dest_port' '22' #目标端口
    option 'target' 'ACCEPT'
config 'redirect'
    option '_name' 'ssh'
    option 'src' 'wan' 
    option 'proto' 'tcp'
    option 'src_dport' '22'  #访问者的目标端口
    option 'dest_ip' '192.168.1.1' #转发到内网主机的IP
    option 'dest_port' '22' #转发到内网机器的IP
    option 'dest' 'lan'

转自:
http://blog.chinaunix.net/uid-20553497-id-199164.html

你可能感兴趣的:(openwrt设置ddns)