Skip to content

Update DuckDNS with current local IP address (before NAT) of a specific physical port.

License

Notifications You must be signed in to change notification settings

neu-ece-esl/DuckDNS_Auto_Update

Repository files navigation

DuckDNS Auto Update

Update DuckDNS with a selected physical port's current local IP address (before NAT).

Observation

Default Public IP may not work correctly if the target machine is behind a NAT gateway.

XXX is a machine behind our NAT gateway. If we leave &ip= with no address specified, duckdns will retrieve the public IP address from the connection that connects to their server, which is some random address from our network gateway. This address is not allowed for inbound connections, meaning this DDNS config will not work.

Patch mechanism

Specify the ip parameter using the following command:

# Get current IP address
IP_INTERFACE = $(cat interface)
IP_ADDRESS = $(ip addr show $IP_INTERFACE | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1)

Solution

On XXX, the DuckDns update routine is settled using the following script:

Folder structure

/home/<service_user>/service/duckdns/
├── makefile
├── makefile.subdir.mak
└── XXX/
    ├── domain
    ├── token
    ├── if_mac_addr
    └── interface

Configuration Files

For example, check ./.example-domain/* for detail.

domain

XXX.duckdns.org

token

00000000-0000-0000-0000-000000000000

* the token is generated by duckdns, and may be varied through different account.

if_mac_addr

00:00:00:00:00:00

* This is the MAC address that represents the interface. The interface may change its name over time, but the MAC address should always be a constant.

interface (optional)

enp2s0

* This file is optional and will only be used if the MAC address is not matched.

Crontab

Config changed using command crontab -e. Here, we update the IP in every 10 minutes.

*/10 * * * * cd /home/<service_user>/service/duckdns/ && make; >/dev/null 2>&1

About

Update DuckDNS with current local IP address (before NAT) of a specific physical port.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published