Hello again! It’s Emmanuel Corels from Emmanuel Corels Creatives, back with another essential how-to for MikroTik newcomers. Today, we’re going to set up Dynamic DNS (DDNS)—a must-have if your ISP assigns you a dynamic IP address. With DDNS, you can access your home or office network using a constant hostname, even if your public IP changes. Let’s walk through it step by step.
What Is DDNS and Why Do You Need It?
Most home or small-office internet connections come with a dynamic IP that can change periodically. This makes it hard to reach your network from outside if you’re using the IP address directly. Dynamic DNS solves this by linking your changing IP to a static hostname (like myhome.ddns.net). When your IP changes, the DDNS service updates the hostname record so you can always connect using the same address.
How DDNS Works
- DDNS Provider: You register for a DDNS service (such as No-IP, DynDNS, or MikroTik’s built-in DDNS service).
- Update Client: Your MikroTik periodically checks its public IP. If it detects a change, it sends an update to the DDNS provider.
- Hostname Mapping: The provider updates the DNS record, so your chosen hostname always points to your current IP.
Step 1: Choose a DDNS Service
You can choose a third-party provider (like No-IP or DynDNS) or use MikroTik’s built-in DDNS feature if it’s available on your RouterOS version. For this guide, we’ll outline using a third-party provider—let’s say No-IP.
- Sign Up: Go to No-IP and create a free account.
- Create a Hostname: Pick a name (e.g.,
myhome.ddns.net
) and assign it to your current public IP.
Step 2: Configure DDNS on Your MikroTik Router
MikroTik doesn’t have a dedicated DDNS client built in like some home routers do, but you can use a script to update your DDNS provider. We’ll set up a simple script that:
- Checks your public IP.
- Compares it to the current value.
- Updates No-IP via their API if a change is detected.
2.1 Create a Script
-
Open WinBox and navigate to System → Scripts.
-
Click the “+” button to add a new script.
-
Name it
ddns-update
. -
In the Source field, paste the following script (customize it with your account details):
:local ddnsUser "yourNoIPUsername" :local ddnsPass "yourNoIPPassword" :local ddnsHost "myhome.ddns.net" :local currentIP [/tool fetch url="http://ipecho.net/plain" as-value output=user] :local publicIP ($currentIP->"data") :local oldIP [/file get ddns_current_ip contents] :if ($publicIP != $oldIP) do={ /tool fetch url="https://dynupdate.no-ip.com/nic/update?hostname=$ddnsHost&myip=$publicIP" http-method=post user=$ddnsUser password=$ddnsPass mode=https keep-result=no; /file set ddns_current_ip contents=$publicIP; :log info "DDNS updated to $publicIP"; } else={ :log info "DDNS update not needed; IP unchanged ($publicIP)"; }
Notes:
- Replace
yourNoIPUsername
andyourNoIPPassword
with your actual No-IP credentials. - Replace
myhome.ddns.net
with your chosen hostname. - The script uses an external service (
ipecho.net
) to determine your public IP. - It compares the new IP with a stored file (
ddns_current_ip
). You need to create that file first.
- Replace
-
Create the File for Storing IP:
- Go to Files, click “+”, then New File.
- Name it
ddns_current_ip
and set its contents to an empty string or your current public IP.
-
Click OK to save the script.
2.2 Schedule the DDNS Update Script
Now, let’s run this script automatically at regular intervals.
- Navigate to System → Scheduler.
- Click “+” to add a new task.
- Name it
DDNS_Update_Task
. - Set Start Time (e.g.,
00:00:00
) and Interval to something reasonable—like5m
(every 5 minutes). - In the On Event field, type:
/system script run ddns-update
- Click OK.
Your MikroTik will now check its public IP every 5 minutes and update your No-IP DDNS record if needed.
Step 3: Test and Verify
- Force an Update: Temporarily change the script’s condition (or manually run it) to see if it logs an update.
- Check the Log (
/log print
) for messages like “DDNS updated to …” or “DDNS update not needed.” - From an external network, ping your hostname (e.g.,
ping myhome.ddns.net
) to confirm it resolves to your current public IP.
Common Pitfalls
- Authentication Errors: Ensure your No-IP username and password are correct.
- Firewall Blocking: Verify that your MikroTik can access the update URL (
dynupdate.no-ip.com
) via HTTPS. - Script File Not Found: Make sure the file
ddns_current_ip
exists in Files; otherwise, the script comparison fails. - IP Source URL: If
ipecho.net
is down, switch to another service likehttp://ifconfig.me/ip
(adjust the script accordingly).
Final Thoughts
With your DDNS script in place and scheduled, you’ll always be able to reach your network using a stable hostname—even if your ISP changes your IP. It’s a simple but powerful tool for remote access, hosting services, or managing your network without the hassle of a constantly changing IP.
Keep experimenting, and as always, feel free to reach out if you need further tweaks or run into any issues. Happy networking!
Guided with clarity by
Emmanuel Corels – Admin, Emmanuel Corels Creatives