-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,41 @@ | ||
# Dynamic DNS in Firewall | ||
|
||
Allow traffic from a Dynamic DNS Domain with a Dynamic IP Address | ||
Automatically set traffic rules from a Dynamic DNS Domain with Dynamic IP Addresses | ||
|
||
> Currently only works with `UFW`, but could be easily adapted to `IPTABLES`. Feel free to contribute! | ||
## How it works | ||
|
||
Allows traffic from IPv4 and optionally IPv6 addesses for a given domain. | ||
|
||
``` | ||
$ ufw status | ||
22 ALLOW IN 1111:1:1::1 # SSH from Dynamic IP (one.dynamic.dns.domain.tld) | ||
22 ALLOW IN 2.2.2.2 # SSH from Dynamic IP (two.dynamic.dns.domain.tld) | ||
22 ALLOW IN 2222:2:2::2 # SSH from Dynamic IP (two.dynamic.dns.domain.tld) | ||
``` | ||
|
||
Multiple addresses supported per domain! | ||
|
||
As well as domains supported! Add as many Dynamic DNS domains as you want! | ||
|
||
Firewall rules for addresses no longer in the DNS records are removed. | ||
|
||
## Required packages | ||
- ufw | ||
- dig | ||
- grep | ||
- awk | ||
|
||
## "Install"/Schedule Cron | ||
|
||
1. Download the latest release | ||
2. Copy to your desired location—for this example we will use `/var/cron` | ||
3. Run it to make sure it works without any errors `bash /var/cron/dynamic-dns-in-ufw.sh` | ||
4. Then enter crontab `$ sudo vim /etc/crontab` | ||
5. To the end of the line add one of the following: | ||
- To run every hour add `0 * * * * root /var/cron/dynamic-dns-in-ufw.sh` | ||
- Or for every half hour add `*/30 * * * * root /var/cron/dynamic-dns-in-ufw.sh` | ||
6. Save and exit vim `:wq` | ||
|
||
|
||
Currently only works with UFW, but could be easily adapted to IPTABLES. Feel free to contribute! |