OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Archive »
  • 15.7 Legacy Series »
  • [SOLVED] Help with Dynamic DNS
« previous next »
  • Print
Pages: [1]

Author Topic: [SOLVED] Help with Dynamic DNS  (Read 8744 times)

fgrutz

  • Newbie
  • *
  • Posts: 8
  • Karma: 1
    • View Profile
[SOLVED] Help with Dynamic DNS
« on: July 07, 2015, 02:22:22 am »
Hi, First post here.

I setting up a Firewall for my home network, and having some trouble with dynamic DNS updates.

I am forced to use an ISP provided router that can´t be set as a bridge, so I set the firewall as its DMZ, as far as forwarding ports its working OK. But since the firewall WAN port have a never changing IP address, when the ISP changes my external IP, I´m forced to manually force the Dynamic DNS update to set it to the new External IP or it still points to the old IP.

There is some way to make it update say like every 5 minutes?

Thanks in advance.

Fábio Grützmacher
« Last Edit: July 10, 2015, 04:17:03 pm by franco »
Logged

bcjenkins

  • Newbie
  • *
  • Posts: 24
  • Karma: 6
    • View Profile
Re: Help with Dynamic DNS
« Reply #1 on: July 07, 2015, 03:28:48 am »
You could write a script to do it and run the script from any computer behind the modem/router.

Code: [Select]
#!/bin/sh

PUBLIC_IP=$(curl -s http://ipecho.net/plain; echo)
echo $PUBLIC_IP

Logged

lucifercipher

  • Jr. Member
  • **
  • Posts: 55
  • Karma: 9
    • View Profile
Re: Help with Dynamic DNS
« Reply #2 on: July 07, 2015, 07:59:00 pm »
If your ISP router is acting as an RFC bridged device and you are using OPNsense as your primary connection (pppoe or static IP) then you shouldn't experience any problems. So now lets say that you are facing problems, use you can google around for IP helper script. The one which is mentioned by bcjenkins is perfect! Save it as a bash script and add it to cron updates for like 5 minutes to do the job. Hope this helped.
Logged

fgrutz

  • Newbie
  • *
  • Posts: 8
  • Karma: 1
    • View Profile
Re: Help with Dynamic DNS
« Reply #3 on: July 07, 2015, 11:58:03 pm »
What I actually want is to update the NO-IP dynamic DNS when it happens, the script help to know it happened, but how do I call this update from cron?

Sorry but I am a newbie to OPNSense.

Thanks
Logged

bcjenkins

  • Newbie
  • *
  • Posts: 24
  • Karma: 6
    • View Profile
Re: Help with Dynamic DNS
« Reply #4 on: July 08, 2015, 02:03:18 pm »
You can run a dynamic IP address update utility from any PC behind the ISP router. This could be your OpnSense firewall or a Windows PC, etc.

In order to run an updater on the OpnSense firewall which is independent of the functions built in, you would want to run it from a script of some sort. I don't use no-ip, so I can't speak to whether or not this script would work. It was found using Google. For reference: http://techgeekjay.blogspot.com/2013/03/no-ip-automatic-update-bash-script-for.html

A few pieces have been changed such as using sh for the interpreter instead of bash and log locations.

Code: [Select]
#!/bin/sh

# No-IP uses emails as passwords, so make sure that you encode the @ as %40
USERNAME=--account name--
PASSWORD=--my password--
HOST=--my host name--
LOGFILE=/var/log/noip.log
STOREDIPFILE=/var/run/current_ip
USERAGENT="Simple Bash No-IP Updater/0.4 antoniocs@gmail.com"

if [ ! -e $STOREDIPFILE ]; then
 touch $STOREDIPFILE
fi

NEWIP=$(curl http://icanhazip.com/)
STOREDIP=$(cat $STOREDIPFILE)

if [ "$NEWIP" != "$STOREDIP" ]; then
 RESULT=$(curl -o "$LOGFILE" -s --user-agent "$USERAGENT" "https://$USERNAME:$PASSWORD@dynupdate.no-ip.com/nic/update?hostname=$HOST&myip=$NEWIP")

 LOGLINE="[$(date +"%Y-%m-%d %H:%M:%S")] $RESULT"
 echo $NEWIP > $STOREDIPFILE
else
 LOGLINE="[$(date +"%Y-%m-%d %H:%M:%S")] No IP change"
fi

echo $LOGLINE >> $LOGFILE

exit 0

Save this to the firewall, adjust the values as needed at the top and set it up in a cron job.

--bcj
Logged

fgrutz

  • Newbie
  • *
  • Posts: 8
  • Karma: 1
    • View Profile
Re: Help with Dynamic DNS
« Reply #5 on: July 09, 2015, 06:05:39 pm »
Worked like a charm.

Thanks bcjenkins.
Logged

bcjenkins

  • Newbie
  • *
  • Posts: 24
  • Karma: 6
    • View Profile
Re: Help with Dynamic DNS
« Reply #6 on: July 10, 2015, 02:31:59 pm »
That's awesome. It might be an interesting feature enhancement to make one of the monitoring interfaces a pseudo one which pings against an external server to derive its value. This way it can be managed in the GUI.

Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • Archive »
  • 15.7 Legacy Series »
  • [SOLVED] Help with Dynamic DNS
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2023 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2