Go Premium for a chance to win a PS4. Enter to Win


Dynamic address broadcasting

Posted on 2000-02-23
Medium Priority
Last Modified: 2010-03-18

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).

Question by:cubedweller
  • 3
  • 2
LVL 40

Expert Comment

ID: 2553211
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.

Expert Comment

ID: 2554690

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
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...)


Author Comment

ID: 2555385
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.

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

LVL 40

Accepted Solution

jlevie earned 200 total points
ID: 2555498
Obligatory caveat: You'd be well advised to check the Terms and Conditions of your service. Some providers take an extremely dim view of their subscribers running web and other servers and have been know to terminate the service when such servers are found.

Okay, on the assumption that you have in mind to mod the pages locally with the correct IP and ship those up to the ISP, I'd definitely do it with a perl script periodically run from cron. As I said, I could write a simple one for you to start with.

What to me would be a better long term solution would be to use one of the dynamic dns services. You'd only have to change the pages one time and could ultimately dispense with the ISP's web server entirely by getting folks used to going directly to your server. One such service (free) is www.dyndns.org and there are free clients that can automatically handle the IP updates.

Author Comment

ID: 2555797
Alright, jlevie, you convinced me.  I went with dyndns.

Thanks again,
LVL 40

Expert Comment

ID: 2555897
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.

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question