Solved

Dynamic address broadcasting

Posted on 2000-02-23
6
197 Views
Last Modified: 2010-03-18
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
0
Comment
Question by:cubedweller
  • 3
  • 2
6 Comments
 
LVL 40

Expert Comment

by:jlevie
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.
0
 
LVL 3

Expert Comment

by:alien_life_form
ID: 2554690
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



0
 

Author Comment

by:cubedweller
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.

Thanks
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 40

Accepted Solution

by:
jlevie earned 50 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.
0
 

Author Comment

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

Thanks again,
CubeDweller
0
 
LVL 40

Expert Comment

by:jlevie
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.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now