Link to home
Start Free TrialLog in
Avatar of cubedweller
cubedweller

asked on

Dynamic address broadcasting

Hello,

My Linux box gets its address via DHCP, making it sometimes hard for me to find from outside.

I would like it to write its address on a web page whenever it boots up or gets a new address.  Does anyone have a script that does something like this?
Note: I can only use FTP to access the webserver where I want to post the info (ISP's rules).

Thanks,
CubeDweller
Avatar of jlevie
jlevie

It would be easy enough to construct a script that could be run from cron or at boot up. I'd think I'd do it from cron, say every half hour, as I don't know how you'd determine if the address had been re-negotiated.

The script would:

1) Get the ip out of an ifconfig.

2) Compare the current IP against a saved copy and if they are different make the new ip become the saved IP and ftp the saved data to the web page using ncftput.

I'd do it with a perl script as it seems to me it'd be easier. I don't have time right now to whip one up, but I'll give it a shot later if someone else doesn't come up with a script in the meantime.

There are places on the Internet that offer this kind of service. Typical costs seem to be in the $20-40 a year and you can have a DNS record associated with the IP. I thought I had a bookmark, but if you do a search on "dynamic dns services" you ought to turn up soemthing.
Greetings.

If you can do cgi-bin on a web server,
you could try something in the line of the following script (untested and I am omitting error checks, etc.):

# your machine ethernet address
ETH='08:00:xx:xx'
#
BCAST='192.168.0.255'
#
ping -q -b -c 5 1> /dev/null 2>&1

SELF=`arp -a | grep $ETH | awk '{print $1}'`

echo 'Content-type: text/plain'
echo ''
echo "You will find yourself as $SELF"

exit 0

The only snag is that the web server this goes on has to be on the same physical segment of your machine (so ping/arp will work, as these days routers tend to drop IP-directed broadcasts. Also, this technique has a (quite low) potential for getting on a netadmin nerves if it gets hit too often.

Actually, I just found out that only root can 'ping -b'. Whoops. Now that's a pity, cause I sorta liked this... So I will post the comment anyway. (I do not think the sysadmin would chmod +s this script...)
 
Cheers
  alf



Avatar of cubedweller

ASKER

Maybe it would help if I explain exactly what I am trying to do:

I have a couple hundred megs of web content, but an ISP that only gives me 5 megs of space (RoadRunner).  I figure I can get around this limitation by hosting the vast majority of the site on my Linux box.

I want to make it a seamless user experience, so I hope to write my current IP address into the META http-equiv="refresh" tag on key pages.  This would automatically redirect the user to the right server.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of jlevie
jlevie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Alright, jlevie, you convinced me.  I went with dyndns.

Thanks again,
CubeDweller
Yeah, it just seems like a simpler solution. There are dynamic dns servers that'll service an actual domain name for you (that you'd get registered) rather than the pseudo domain like dyndns uses. I haven't located any free ones though. About $25 or so per year seems to be the norm.