Skip to content

Commit 04b7406

Browse files
committed
Initial version.
0 parents  commit 04b7406

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Configuration
2+
nc-ddns.config.sh

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Namecheap Dynamic DNS Updater (Basic)
2+
3+
Just a simple *bash + cURL* based updater for the Namecheap Dynamic DNS service.
4+
Works on macOS, probably Linux, and probably not Windows.
5+
6+
## Configuration
7+
8+
* Make a copy of the example configuration file `nc-ddns.config.example.sh` and
9+
name it `nc-ddns.config.sh`.
10+
* Fill in the configuration values in that file from
11+
Namecheap's web control panel:
12+
13+
```
14+
NC_DDNS_HOST=@
15+
NC_DDNS_DOMAIN=mydomain.com
16+
NC_DDNS_PASSWORD=ddns_password
17+
```
18+
19+
## Usage
20+
21+
```
22+
$ ./nc-ddns.sh
23+
```
24+
25+
## History
26+
27+
This updater was written as an alternative to the [nc-ddns] updater,
28+
because I couldn't get that updater to work.
29+
30+
[nc-ddns]: https://github.com/marcov/nc-ddns

nc-ddns.config.example.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
NC_DDNS_HOST=@
2+
NC_DDNS_DOMAIN=mydomain.com
3+
NC_DDNS_PASSWORD=ddns_password

nc-ddns.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# Load configuration
4+
source nc-ddns.config.sh
5+
6+
# Lookup my IP
7+
MY_IP=$(curl -fsSL "icanhazip.com")
8+
if [ $? -ne 0 ]; then
9+
echo "*** IP lookup failed. Is the IP lookup service offline?"
10+
exit 1
11+
fi
12+
13+
# Formulate URL to update my IP in Namecheap, based on documentation:
14+
# https://www.namecheap.com/support/knowledgebase/article.aspx/29/11/how-do-i-use-a-browser-to-dynamically-update-the-hosts-ip/
15+
UPDATE_URL="https://dynamicdns.park-your-domain.com/update?host=${NC_DDNS_HOST}&domain=${NC_DDNS_DOMAIN}&password=${NC_DDNS_PASSWORD}&ip=${MY_IP}"
16+
17+
# Update my IP in Namecheap
18+
STATUS_CODE=$(curl -o /dev/null -s -w "%{http_code}\n" "${UPDATE_URL}")
19+
if [ $STATUS_CODE -ne 200 ]; then
20+
echo "*** Update IP failed. Is the configuration wrong?"
21+
exit 1
22+
fi

0 commit comments

Comments
 (0)