Skip to content

Commit 6c13f39

Browse files
committed
add sample systemd unit
1 parent 309b7e6 commit 6c13f39

File tree

5 files changed

+48
-25
lines changed

5 files changed

+48
-25
lines changed

README.md

+21-23
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ It lets you easily create a dyndns.org-like service, using your own DNS server,
2121
## Quick Guide
2222

2323
`sftdyn` is for you if you host a DNS zone and can run a Python server so it updates the nameserver records.
24-
This guide assumes that you're using bind, your zone is `dyn.sft.mx`, and your server's IP is `12.345.678.901`.
24+
This guide assumes that you're using bind, your zone is `dyn.sft.mx`, and your server's IP is `12.345.678.90`.
2525
It's mediocre likely that you want to adjust that.
2626

2727

@@ -51,7 +51,7 @@ cp /etc/bind/db.empty /etc/bind/dyn.sft.mx.zone
5151
If you want to use `dyn.sft.mx` as the hostname for your update requests, add a record to the zone file:
5252

5353
```
54-
@ IN A 12.345.678.901
54+
@ IN A 12.345.678.90
5555
@ IN AAAA some:ipv6::address
5656
```
5757

@@ -63,29 +63,18 @@ To install *sftdyn*, use `pip install sftdyn` or `./setup.py install`.
6363
Launch it with `python3 -m sftdyn [command-line options]`.
6464

6565
Configuration is by command-line parameters and conf file.
66-
A sample conf file is provided in `sample.conf`.
66+
A sample conf file is provided in `etc/sample.conf`.
6767
If no conf file name is provided, `/etc/sftdyn/conf` is used.
6868
Hostnames/update keys are specified in the conf file.
6969

7070
#### systemd service
7171

7272
To run `sftdyn` automatically, you can use a systemd service.
7373

74-
Create `/etc/systemd/system/sftdyn.service` on the `sftdyn` host machine:
74+
The `sftdyn` distribution package should automatically install `sftdyn.service`.
7575

76-
```
77-
[Unit]
78-
Description=SFT dyndns service
79-
After=network.target
80-
81-
[Service]
82-
User=bind
83-
ExecStart=/usr/bin/env python3 -m sftdyn
84-
Restart=on-failure
85-
86-
[Install]
87-
WantedBy=multi-user.target
88-
```
76+
If you have to manually install it, use the example unit `etc/sftdyn.service`
77+
and copy it to `/etc/systemd/system/sftdyn.service` on the `sftdyn` host machine.
8978

9079
Enable the launch on boot and also start `sftdyn` now:
9180

@@ -94,18 +83,21 @@ sudo systemctl enable --now sftdyn.service
9483
```
9584

9685
#### Unencrypted operation
86+
9787
You _can_ use `sftdyn` in plain HTTP mode.
9888
Your average commercial dynamic DNS provider provides a HTTP interface, so most routers only support that.
9989

10090
Somebody could grab your "secret url" with this and perform unintended updates of your record.
10191

10292

10393
#### Encrypted operation
94+
10495
Because of the above reason, you _should_ use HTTPS to keep your update url token secret.
10596
For that, your server needs a X.509 key and certificate.
10697
You can create those with [let's encrypt](https://letsencrypt.org/), buy those somewhere, or create a self-signed one.
10798

10899
##### Self-signed certificate
100+
109101
To generate `server.key` and a self-signed `server.crt` valid for 1337 days:
110102

111103
```
@@ -125,6 +117,7 @@ Make sure you enter your server's domain name for _Common Name_.
125117
The client triggers the IP update at the `sftdyn` server, so your DNS then delivers the correct IP.
126118

127119
#### Plastic router
120+
128121
To use your router as client, select _user-defined provider_, enter http://dyn.sft.mx:8080/yourupdatekey as the update URL, and random stuff as domain name/user name/password. (tested with my AVM Fritz!Box. YMMV). Most routers don't support HTTPS update requests (especially not with custom CA-cert, so you'll probably need HTTP.
129122

130123
#### Request with `curl`
@@ -144,6 +137,7 @@ If you use HTTPS with a self-signed certificate, `curl` will refuse to talk to t
144137
| 200 | _your ip_ | Returned if no key is provided |
145138

146139
##### systemd timer
140+
147141
`systemd` timers are like cronjobs. Use them to periodically run the update query.
148142

149143
Create `/etc/systemd/system/sftdynupdate.timer`:
@@ -199,7 +193,7 @@ Cronjobs are the legacy variant to periodically run a task, you could do this li
199193

200194
## About
201195

202-
I wrote this script after the free `dyndns.org` service was shut down.
196+
This software was written after the free `dyndns.org` service was shut down.
203197
After a week or so of using plain `nsupdate`, I was annoyed enough to decide to write this.
204198

205199
It is the main goal to stay as minimal as possible; for example, I deliberately didn't implement a way to specify the hostname or IP that you want to update; just a simple secret update key is perfectly good for the intended purpose. If you feel like it, you can make the update key look like a more complex request; every character is allowed. Example: `?host=test.sft.mx&key=90bbd8698198ea76`.
@@ -218,13 +212,17 @@ The conf file is interpreted as python code, so you can do arbitrarily complex s
218212
Somebody who knows a valid udpate key could semi-effectively DOS your server by spamming update requests from two different IPs. For each request, nsupdate would be launched and your zone file updated.
219213

220214
## Development
221-
IMHO, the project is feature-complete; it has everything that **I** currently want.
222215

223-
Features that _might_ be useful, which I _might_ implement if someone asked nicely:
224-
- Support to run this inside a "real" webserver like nginx or Apache (WSGI?)
225-
- I'm sure there are more
216+
IMHO, the project is feature-complete; it has everything that **I** currently need.
217+
218+
If you have any requests, ideas, feedback or bug reports,
219+
are simply filled with pure hatred,
220+
or just need help getting the damn thing to run,
221+
join our chatroom and just ask:
222+
223+
- IRC: `irc.freenode.net/#sfttech`
224+
- Matrix: `#SFTtech:matrix.org`
226225

227-
If you have any requests, ideas, feedback or bug reports, are simply filled with pure hatred, or just need help getting the damn thing to run, join `irc.freenode.net/#sfttech` (I'm mic_e).
228226

229227
If you actually _did_ implement a useful feature, please send a pull request; I'd be happy to merge it.
230228

sample.conf etc/sample.conf

File renamed without changes.

etc/sftdyn.service

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
Description=sft dynamic dns service
3+
After=network.target
4+
5+
[Service]
6+
User=named
7+
ExecStart=/usr/bin/env python3 -m sftdyn -v
8+
Restart=on-failure
9+
10+
[Install]
11+
WantedBy=multi-user.target

setup.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,19 @@
2323
license="GPL3+",
2424
packages=["sftdyn"],
2525
scripts=["bin/sftdyn"],
26-
data_files=[("/etc/sftdyn/", ["sample.conf"])]
26+
data_files=[
27+
("/etc/sftdyn/", ["etc/sample.conf"]),
28+
("/usr/lib/systemd/system/", ["etc/sftdyn.service"]),
29+
],
30+
platforms=[
31+
'Linux',
32+
],
33+
classifiers=[
34+
("License :: OSI Approved :: "
35+
"GNU General Public License v3 or later (GPLv3+)"),
36+
"Topic :: Internet :: WWW/HTTP",
37+
"Intended Audience :: Developers",
38+
"Environment :: Console",
39+
"Operating System :: POSIX :: Linux"
40+
],
2741
)

sftdyn/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
which then update dns records with nsupdate.
44
"""
55

6-
VERSION = "0.5"
6+
VERSION = "0.6"
77

88

99
import asyncio

0 commit comments

Comments
 (0)