marcelp1
Posts: 132
Joined: Mon Jun 11, 2012 8:41 pm

ddclient - no dyndns provider

Fri Feb 08, 2013 6:15 pm

Hi all,

I want to be able to get the RPi on boot connect to my server:

http://myserver.co.uk/rpi/"macaddressof ... rface".php

and get its IP (supplement for any of the dyndns providers which now charge if more than one client is registred.

"macaddressoftheinterface".php
file has got script to get clients IP:
<?php
$remote_address = getenv("REMOTE_ADDR");
echo "
$remote_address";
?>

so I can see if the RPi is connected via Ethernet or Wi-Fi and what
is the external ip address of it in my log.

So if the RPi is connected via Ethernet and eth0 mac is b8:27:eb:be:a9:1f
it would connect to
http://myserver.co.uk/rpi/b827ebbea91f_LAN.php
and if it is connected via Wi-Fi wlan0 mac is 80:1f:02:61:56:81
it would connect to
http://myserver.co.uk/rpi/801f02615681_WLAN.php

Is ddclient what I need or is there another way to achieve this?

killerbobjr
Posts: 5
Joined: Thu Feb 07, 2013 6:44 am

Re: ddclient - no dyndns provider

Sat Feb 09, 2013 3:31 am

First off, what are you trying to accomplish? Are you at a remote location and need to connect to your Pi over the internet? If so, is your Pi always connected to your server through the LAN cable? If yes, then give the LAN connection a static address and your Pi will always be available at the same address.

Or is your Pi at one location, your server at another, and you at a third, and you want to be able to find out which way your Pi has made its primary internet connection by looking at logs on your server? If that's the case, and your Pi has to find a connection to the internet either through WiFi or LAN (I'm assuming from your description that the LAN connection is behind a firewall while the WiFi connection gets an IP directly from the ISP), and you want to be able to always connect to your Pi, it would probably be easier to give the Pi its own domain name (mypi.somefreedomainatafraiddotorg.com) and use ddlcient to update that IP address in the dns record. That way you always can get to your Pi directly by using the domain. And you can force the WiFi connection to connect first by creating a rule in /etc/udev/rules.d, something like:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="wi:fi:ma:ca:dd:rs", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="la:nm:ac:ad:dr:es", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

If connecting to your Pi directly is not important, but you need a log of when and how your Pi has connected, then put a script in your Pi's /etc/network/if-up.d and use "curl" to get your IP and log that into your server:

#! /bin/sh
ipaddr=$(curl http://ifconfig.me/ip)
curl http://myserver.co.uk/rpi.php?addr=$ipaddr

Return to “Networking and servers”