[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: dynamic IP questions?



Vikki Roemer wrote:
On Sat, Jan 10, 2004 at 09:13:55AM -0500, 0debian user wrote:

Also I wanted to run my own web server and mail server but my machine is not always online so how can I do it?


Go to http://www.dyndns.org/ and sign up there.  They give you up to 5
hostnames for free, you just have to update the IP address every time you
redial.  That's who I get my 3 hostnames through, and I'm happy with them. :)
I recommend ipcheck.py (apt-get install ipcheck) to update the addy.
However, don't ask me how to *automate* the update script, because I'm still
trying to figure that out myself.

HTH.



Here's the entry in /etc/crontab on my gateway/router machine (that connects via pppoe to my adsl provider) for those interested in automating this sort of thing.

0-55/5  * * * *   root          /root/radscripz/reconnector.py

And the contents of reconnector.py (with my personal details replaced with <something>).

<file>

#!/usr/bin/env python

import os, string, sys, time, smtplib

fi,fo = os.popen2('/sbin/ifconfig','t')

sss = fo.read()

fi.close()
fo.close()

if string.find(sss,"ppp0") > -1:
        sys.exit(0)

ei, eo = os.popen2('/usr/local/bin/start-pppoe', 't')

ei.close()
eo.close()
time.sleep(10)

os.chdir('/root/dyndns')

gi, go = os.popen2('/usr/bin/python /root/dyndns/ipcheck.py -l -i ppp0 <dyndns-username> <dyndns-password> <dyndns-hostname>','t')

gi.close()

res = go.read()
go.close()
mailcon = smtplib.SMTP('<mailserver>', port=25)

recips = ['<address1>', '<address2>']

mailcon.sendmail('connexor@<machine-name>', recips, res)

mailcon.quit()
sys.exit(0)

</file>



Basically, it runs every five minutes and if the connection has died, it reconnects, then updates the dyndns stuff and also emails me at several addresses with the new IP (which is probably redundant, but it does have the added benefit of providing me with a record of how often I've been disconnected).

	good luck,
		~c



--
This is not a democracy; it's a cheerocracy.
  -Torrance Shipman



Reply to: