openwrt lede
no-ip.com配置 (no-ip.com configuration)
In case that your home network gets a dynamic (public) IP address from the internet service provider (ISP) and you want to get access to your network services (NAS, IP Cam, any webserver etc.) over the internet, then a DDNS service is necessary.
如果您的家庭网络从Internet服务提供商(ISP)获得了动态(公共)IP地址,并且您希望通过Internet访问网络服务(NAS,IP Cam,任何Web服务器等),则需要使用DDNS服务是必要的。
Typical modems support DDNS service configuration out of the box (e.g. Fritzbox), but if that is not possible then any OpenWRT device on your network can help out.
典型的调制解调器开箱即用地支持DDNS服务配置(例如Fritzbox),但是如果不可能,则网络上的任何OpenWRT设备都可以提供帮助。
Content
内容
- Setup a ddns-client on an OpenWrt Access Point where the Modem would not support dyndns out of the box ** The ddns-client will update the public IP periodically on the chosen DDNS service provider 在调制解调器不支持dyndns的OpenWrt接入点上设置ddns客户端** ddns客户端将定期在所选DDNS服务提供商上更新公共IP
Port forwarding to the local services has to be configured on the modem.
端口转发到本地服务必须在调制解调器上配置。
Requirements
要求
- Pick and register a free DNS name with a compatible DynamicDNS provider (e.g. no-ip.com) 选择免费的DNS名称并向兼容的DynamicDNS提供商注册(例如,no-ip.com)
- Your network needs to get a public dynamic IP address assigned from the internet service provider (ISP) 您的网络需要获得互联网服务提供商(ISP)分配的公共动态IP地址
建立 (Setup)
ISP
|
LTE Modem (Dynamic public IP; Modem configured with port-
| forwarding; Modem acts as router)
| <lan interface>
Access Point (Local IP 192.168.1.2, Dumb WiFi Access Point;
| Configured DDNS client)
|
Local Service (192.168.1.10, e.g. IP Cam; exposed to the
internet via http://mydomain.ddns.net:8080/webcams)
在OpenWrt设备上安装软件包 (Install packages on OpenWrt device)
Install ddns scripts using opkg package manager.
使用opkg软件包管理器安装ddns脚本。
opkg update
opkg install ddns-scripts
Depending on your ddns service provider, additional packages may be necessary.
根据您的ddns服务提供商, 可能需要其他软件包 。
opkg install ddns-scripts_no-ip_com
The ddns-scripts are installed to /usr/lib/ddns
:
ddns脚本已安装到/usr/lib/ddns
:
root@openwrt:/usr/lib/ddns# ll
-rwxr-xr-x 1 root root 30151 Aug 1 16:31 dynamic_dns_functions.sh*
-rwxr-xr-x 1 root root 4109 Aug 1 16:31 dynamic_dns_lucihelper.sh*
-rwxr-xr-x 1 root root 10308 Aug 1 16:31 dynamic_dns_updater.sh*
-rwxr-xr-x 1 root root 1366 Aug 1 16:31 update_no-ip_com.sh*
组态 (Configuration)
The ddns client can be configured directly in /etc/config/ddns
.
可以在/etc/config/ddns
直接配置ddns客户端。
Start with enabling the ddns client.
首先启用ddns客户端。
$ /etc/init.d/ddns enable
基本设定 (Basic setup)
First of all, you have to set your credentials from your provider.
首先,您必须从提供商处设置凭据。
config service 'myddns_ipv4-config'
option lookup_host '<YOUR-DOMAIN-NAME>'
option domain '<YOUR-DOMAIN-NAME>' # e.g. myhome.ddns.net
option username '<YOUR-USER>'
option password '<YOUR-PASSWORD>'
option interface 'lan'
option ip_network 'lan'
option service_name 'no-ip.com'
检测公共IP (Detecting public IP)
The purpose of the ddns client is to update the dyndns service provider with your current IP address, so we have to configure that.
ddns客户端的目的是使用您当前的IP地址更新dyndns服务提供商,因此我们必须对其进行配置。
For that setup the ddns client is running on an arbitary Access Point, so an external service like http://ifconfig.me/ip
is necessary to retrieve the public IP address.
对于该设置,ddns客户端在任意接入点上运行,因此必须使用外部服务(如http://ifconfig.me/ip
)来检索公共IP地址。
Append to configuration:
追加配置:
config service 'myddns_ipv4-config'
option ip_source 'web'
option ip_url 'http://ifconfig.me/ip'
# external service retrieves public IP in plain text
更新DNS服务提供商 (Update DNS service provider)
This setting tells the client how to notify your dyndns service provider with your current IP.
此设置告诉客户端如何用您当前的IP通知您的dyndns服务提供商。
Next configure the setting update_url
(depending on your service). Lookup the setting for your supported service provider (supported dyndns providers are listed in /etc/ddns/services
)
接下来,配置设置update_url
(取决于您的服务)。 查找支持的服务提供商的设置(受支持的dyndns提供程序列在/etc/ddns/services
)
$ awk '$1 ~ /no-ip.com/ {print $2}' /etc/ddns/services
update_no-ip_com.sh
Append in service configuration:
附加在服务配置中:
config service 'myddns_ipv4-config'
option update_url 'update_no-ip_com.sh'
Sidenote: For no-ip.com the update_url setting uses on the additional installed
update_no-ip_com.sh
script. For other ddns providers the setting could be a http link pointing directly to an API, e.g. foropendns.com
it would behttp://[USERNAME]:[PASSWORD]@updates.opendns.com/nic/update?hostname=[DOMAIN]&myip=[IP]
.旁注:对于no-ip.com,update_url设置用于其他已
update_no-ip_com.sh
的update_no-ip_com.sh脚本。 对于其他ddns提供程序,该设置可以是直接指向API的http链接,例如对于opendns.com
,它将是http://[USERNAME]:[PASSWORD]@updates.opendns.com/nic/update?hostname=[DOMAIN]&myip=[IP]
。
打开日志 (Turn on the logs)
config service 'myddns_ipv4-config'
option use_logfile '1'
套用设定 (Apply configuration)
$ /etc/init.d/ddns restart
Check that your configuration works!
检查您的配置是否有效!
The log output should look like:
日志输出应如下所示:
104739 : Detect registered/public IP
104739 : #> /usr/bin/nslookup <your.ddns.net> >/var/run/ddns/myddns_ipv4.dat 2>/var/run/ddns/myddns_ipv4.err
104743 : Registered IP '<YOUR-PUBLIC-DYNAMIC-IP>' detected
104743 info : Starting main loop at 2020-08-12 10:47
104743 : Detect local IP on 'web'
104743 : #> /bin/uclient-fetch -q -O /var/run/ddns/myddns_ipv4.dat -Y off 'http://ifconfig.me/ip' 2>/var/run/ddns/myddns_ipv4.err
104747 : Local IP '<PUBLIC-IP>' detected on web at 'http://ifconfig.me/ip'
104747 : Update needed - L: '<PUBLIC-IP>' <> R: '<PUBLIC-IP>'
104747 : parsing script '/usr/lib/ddns/update_no-ip_com.sh'
104747 : sending dummy IP to 'no-ip.com'
104747 : #> /bin/uclient-fetch -q -O /var/run/ddns/myddns_ipv4.dat -Y off 'http:<your.email@gmail.com>:***PW***@dynupdate.no-ip.com/nic/update?hostname=<YOUR.DDNS.NET>&myip=127.0.0.1' 2>/var/run/ddns/myddns_ipv4.err
104755 : 'no-ip.com' answered:
good 127.0.0.1
104756 : sending real IP to 'no-ip.com'
104756 : #> /bin/uclient-fetch -q -O /var/run/ddns/myddns_ipv4.dat -Y off 'http:<your.email@gmail.com>:***PW***@dynupdate.no-ip.com/nic/update?hostname=<YOUR.DDNS.NET>&myip=<PUBLIC-IP>' 2>/var/run/ddns/myddns_ipv4.err
104805 : 'no-ip.com' answered:
good 46.75.33.201
104805 info : Update successful - IP '<PUBLIC-IP>' send
104805 info : Forced update successful - IP: '<PUBLIC-IP>' send
104805 : Waiting 600 seconds (Check Interval)
Your dyndns setup is ready to use, configure port forwarding and you are set.
您的dyndns设置已准备就绪,可以使用,配置端口转发并设置好。
资源资源 (Resources)
openwrt lede