Forum
  • Search
  • Member List
  • Calendar
Hello There, Guest! Login Register — Login with Facebook

suggested feature in Xbian Config: update IP via a dynamic dns provider
Thank you for your donation

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode | Linear Mode
suggested feature in Xbian Config: update IP via a dynamic dns provider
9th Nov, 2013, 07:51 AM
Post: #1
zilexa Offline
Registered
Posts: 231
Joined: Feb 2013
Reputation: 9
suggested feature in Xbian Config: update IP via a dynamic dns provider
I have been using ddclient but it doesn't work that well to update your IP address in case your ISP doesn't give you a static IP.

Now I have found this neat little script: first it checks IF your IP address has changed. Only if it has changed, it will update your subdomain at your dyn dns provider. It seems to be a very 'light' solution, no need to install a program like ddclient.

Perhaps the script could be added to XBian and an "checkbox" could be added to the XBian Config UI to enable it? By default it should be disabled. If enabled, user will have to select time (perhaps default 4 hrs) then all it should do is add a line to cronjob. The user would still need to fill in their token though...

But I still have 1 issue. The script seems very clean, but it needs interface data and I do not understand that part:
Terminal
TOKEN="mytoken,removedforprivacyreasons"
IFACE=[PUBLIC-IF]

if test -f /etc/freedns/dnsactual.conf
then
CacheIP=$(cat /etc/freedns/dnsactual.conf)
fi

CurreIP=$(ifconfig $IFACE | grep -oEe "addr:[0-9\.]*" | cut -f 2 -d Smile

if [ "$CurreIP" = "$CacheIP" ]
then
# Both IP are equal
echo "Update not required..."
else
# The IP has change
echo "Updating http://free.afraid.org with " $CurreIP
wget http://freedns.afraid.org/dynamic/update.php?$TOKEN -o /dev/null -O /dev/stdout
echo `date` "Updating log with IP " $CurreIP >> /var/log/dnsactual.log
fi
rm -f /etc/freedns/dnsactual.conf
echo $CurreIP > /etc/freedns/dnsactual.conf

script is saved in /etc/freedns/dnsactual.sh.
When I run it:
Terminal
xbian@xbian /etc/freedns $ sudo sh dnsactual.sh
[PUBLIC-IF]: error fetching interface information: Device not found
Update not required...

I replaced PUBLIC-IF for eth0 but that doesn't work. I would like to get this script working for myself. I tried Googling the public-if part but nothing comes up. Advice?
Find all posts by this user
Quote this message in a reply
11th Nov, 2013, 12:15 PM
Post: #2
f1vefour Offline
Administrator
******
Posts: 1,342
Joined: Mar 2013
Reputation: 58
RE: suggested feature in Xbian Config: update IP via a dynamic dns provider
eth0 is the public interface unless your using a wireless dongle, so are you doing IFACE=[eth0] or just IFACE=eth0 ?

Please read rules and do a search before you post! | FAQs | How to post log file? | Can't find an answer? Contact us.
Visit this user's website Find all posts by this user
Quote this message in a reply
11th Nov, 2013, 08:27 PM
Post: #3
zilexa Offline
Registered
Posts: 231
Joined: Feb 2013
Reputation: 9
RE: suggested feature in Xbian Config: update IP via a dynamic dns provider
ahh that was my mistake. I removed the brackets and I also added "sudo" before ifconfig. Now it should work. Unfortunately, since I am behind my ISP modemrouter, the ifconfig eth0 command returns my local IP instead of my wan IP.
I guess there is no way to figure out your external IP without connecting to a server outside my network?

My goal was to create an as light as possible script.. get the IP, compare it to the previous found IP and if different, then change it at a DNS provider of choice. Now it seems you first have to check with some website/provider/server to get the IP... I'll play a little more.
Find all posts by this user
Quote this message in a reply
13th Nov, 2013, 11:02 AM
Post: #4
mk01 Offline
Registered
Posts: 2,485
Joined: Mar 2013
Reputation: 209
RE: suggested feature in Xbian Config: update IP via a dynamic dns provider
@zilexa

public_ip=$(wget -O - checkip.dyndns.org 2>/dev/null | cut -d':' -f2 | cut -d'<' -f1 )

Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here
Find all posts by this user
Quote this message in a reply
14th Nov, 2013, 12:18 AM
Post: #5
zilexa Offline
Registered
Posts: 231
Joined: Feb 2013
Reputation: 9
RE: suggested feature in Xbian Config: update IP via a dynamic dns provider
Thanks I actually found identical solution yesterday Big Grin I just wanted to experiment and find a way to obtain my external IP address without asking an external server. But that seems to be the only way!
Find all posts by this user
Quote this message in a reply
14th Nov, 2013, 04:31 AM
Post: #6
f1vefour Offline
Administrator
******
Posts: 1,342
Joined: Mar 2013
Reputation: 58
RE: suggested feature in Xbian Config: update IP via a dynamic dns provider
This is simpler:

external_ip=$(wget -qO- http://ipecho.net/plain)

Please read rules and do a search before you post! | FAQs | How to post log file? | Can't find an answer? Contact us.
Visit this user's website Find all posts by this user
Quote this message in a reply
15th Nov, 2013, 02:09 AM
Post: #7
zilexa Offline
Registered
Posts: 231
Joined: Feb 2013
Reputation: 9
RE: suggested feature in Xbian Config: update IP via a dynamic dns provider
OK this is the solution. I still want to add a few other IP check services in case ipecho.net goes down. But for now it works perfectly. For reference if anyone else wants this:

Schedule this script to run every x hours, mine runs every 4 hours (type crontab -e in terminal and add this to the bottom):
Code:
0 */4 * * * sudo sh /etc/ipupdate/ipupdate.sh

the script, create a new textfile (sudo nano /etc/ipupdate/ipupdate.sh) and copy paste:
Code:
# this script will check if the current external IP address has been
# changed by your ISP internet provider. If so, it will update your
# subdomain (for example: mypc.freedns.org). This way, you will always
# be able to connect to your Raspberry when you are not at home and don't know
# the IP address of your home. Also handy if your ISP internet provider keeps changing your IP.

TOKEN="add your token from your freedns subdomain"

if test -f /etc/ipupdate/ipupdate.conf
then
CacheIP=$(cat /etc/ipupdate/ipupdate.conf)
fi

ExternIP=$(wget -qO- http://ipecho.net/plain)

if [ "$ExternIP" = "$CacheIP" ]
then
# Both IP are equal
echo "Update not required..."
else
# The IP has change
echo "Updating http://free.afraid.org with " $ExternIP
wget http://freedns.afraid.org/dynamic/update.php?$TOKEN -o /dev/null -O /dev/stdout
echo `date` "Updating log with IP " $ExternIP >> /var/log/dmesg
fi
sudo rm -f /etc/ipupdate/ipupdate.conf
sudo echo $ExternIP > /etc/ipupdate/ipupdate.conf
Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


Possibly Related Threads...
Thread: Author Replies Views: Last Post
  [SOLVED] [xbian-config] Kernel update reverted crs 5 17,168 13th Dec, 2012 05:47 AM
Last Post: BartOtten

  • View a Printable Version
  • Send this Thread to a Friend
  • Subscribe to this thread
Forum Jump:

Current time: 10th May, 2025, 03:03 AM Powered By MyBB, © 2002-2025 MyBB Group.