Thank you!<br><br>What if I would like to use my own DNS server for this (considereing I've got my own domain names)?<br><br><div class="gmail_quote">On Dec 27, 2007 3:58 PM, Shane Geiger <<a href="mailto:sgeiger@ncee.net">
sgeiger@ncee.net</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">Marcelo de Moraes Serpa wrote:
<br>> Hello list,<br>><br>> I'd like to set up ssh access to my home computer so that I will be<br>> able to access it from work - for this no problem, installing sshd is<br>> straightforward.<br>><br>
> The issue here is that I don't have a fixed IP connection at home.<br>> Also, I wouldn't like to use services such as no-ip or similar.<br>><br>> What I thought was of writing a python program that would detect when
<br>> the internet network interface was restarted/started for the first<br>> time and then update a DNS record at my DNS server where I would have<br>> a subdomain that for my home machine's host.<br>><br>
> However, I have no idea on how I could detect if the network has been<br>> restarted nor how I could update this DNS record. Any suggestion would<br>> be greatly appreciated :)<br>><br>> Thanks in advance,
<br>><br>> Marcelo.<br><br></div></div>How to deal with networking depends on the system you use. For Debian:<br><br> Debian uses ifupdown (see ifup(8), ifdown(8) and interfaces(5)) to<br> manipulate network interfaces. Each interface is provided with
<br> several scripting hooks: pre-up, up, down, and post-down. These<br> hooks are available to each interface as in-line directives in<br> /etc/network/interfaces and also as *.d/ directories called with<br> run-parts (see run-parts(8)):
<br><div class="Ih2E3d"><br> /etc/network/if-up.d/<br></div> /etc/network/if-pre-up.d/<br> /etc/network/if-down.d/<br> /etc/network/if-post-down.d/<br><br><br><br><br>SETTING UP A DOMAIN NAME WITH
<a href="http://DYNDNS.ORG" target="_blank">DYNDNS.ORG</a><br><br>Go to their site and set up an account. While doing that (or perhaps<br>after--I don't remember), you can choose a domain name. You *could*<br>think of what they are giving you is a subdomain--not actually a
<br>domain. You will be able to choose something like <a href="http://foo.mine.nu" target="_blank">foo.mine.nu</a> where<br>"foo" is the name you choose for the name of your subdomain and<br>"<a href="http://mine.nu" target="_blank">
mine.nu</a>" is the domain they already own. (You can choose from many<br>domains they already own.) Since they manage these domains themselves,<br>they do not have to pay a registrar to set up a subdomain...and<br>
therefore they can give you a subdomain for free. (Actually, I'm using<br>the term "subdomain" loosely here...but I'm sure you get the point I'm<br>trying to make--which is that you don't have to pay for this name.)
<br><br>Once you have your name (<a href="http://foo.mine.nu" target="_blank">foo.mine.nu</a>, for example), you can set up a<br>program on your computer to update their DNS servers with your new<br>domain name whenever it changes.
<br><br>--------------------------------------------------<br><br><br>SETTING UP IPCHECK WITH <a href="http://DYNDNS.ORG" target="_blank">DYNDNS.ORG</a><br><br>I have been satisfied with my first choice (<a href="http://dyndns.org" target="_blank">
dyndns.org</a>), so I haven't<br>tried the others. They probably work well, too.<br><br>Set up an account on <a href="http://dyndns.org" target="_blank">dyndns.org</a>, and record the username, password, and<br>domain name in your notes. In the following examples, I use the
<br>following values:<br><br>username: sgeiger<br>pass: asdfasdf<br>domain name: <a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a><br><br><br>apt-get install ipcheck<br><br>You might want to run this first so that you are in the directory cron
<br>will use when you run ipcheck:<br>sudo su; cd ~;<br><br>HERE'S HOW TO CONFIGURE IT:<br>sgeiger@minime:~$ sudo /usr/sbin/ipcheck.py -l -r<br><a href="http://checkip.dyndns.org:8245" target="_blank">checkip.dyndns.org:8245
</a> shanerg asdfasdf <a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a><br>ipcheck.py: No ipcheck.dat file found.<br>ipcheck.py: Use same command+options ONCE with --makedat to create from<br>DNS lookup.
<br>sgeiger@minime:~$ sudo /usr/sbin/ipcheck.py --makedat -l -r<br><a href="http://checkip.dyndns.org:8245" target="_blank">checkip.dyndns.org:8245</a> shanerg asdfasdf <a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu
</a><br>ipcheck.py: ip1 looking up <a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a><br>ipcheck.py: result: '<a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a>'[]['<a href="http://139.55.232.72" target="_blank">
139.55.232.72</a>']<br>sgeiger@minime:~$ sudo /usr/sbin/ipcheck.py -l -r<br><a href="http://checkip.dyndns.org:8245" target="_blank">checkip.dyndns.org:8245</a> shanerg asdfasdf sgeiger.mine<br>.nu<br>sgeiger@minime:~$ sudo /usr/sbin/ipcheck.py -l -r
<br><a href="http://checkip.dyndns.org:8245" target="_blank">checkip.dyndns.org:8245</a> shanerg asdfasdf <a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a><br>sgeiger@minime:~$ sudo /usr/sbin/ipcheck.py -l -r
<br><a href="http://checkip.dyndns.org:8245" target="_blank">checkip.dyndns.org:8245</a> shanerg asdfasdf <a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a><br>sgeiger@minime:~$<br><br>When you run this manually and it works you will see no output.
<br><br>To add a cron job to update this automatically once a day at 10 am:<br><br>### Note: This script should be run once a day from cron, like this<br>(which runs it at 10:15 am every day)<br>15 10 * * * /usr/bin/python /usr/sbin/ipcheck.py -l -r
<br><a href="http://checkip.dyndns.org:8245" target="_blank">checkip.dyndns.org:8245</a> shanerg asdfasdf <a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a><br><br><br>To add another names (<a href="http://foobar.mine.nu" target="_blank">
foobar.mine.nu</a>):<br>sudo /usr/sbin/ipcheck.py --makedat -l -r <a href="http://checkip.dyndns.org:8245" target="_blank">checkip.dyndns.org:8245</a><br>shanerg rQ9ll0 <a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu
</a>,<a href="http://foobar.mine.nu" target="_blank">foobar.mine.nu</a><br><br>...and then put this into the cron tab:<br>15 10 * * * /usr/bin/python /usr/sbin/ipcheck.py -l -r<br><a href="http://checkip.dyndns.org:8245" target="_blank">
checkip.dyndns.org:8245</a> shanerg asdfasdf <a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a><br><br><br><br><br>Check the mail messages on the computer you are using in case there were<br>errors.<br><br>
Note: This creates a file named /root/ipcheck.dat and /root/ipcheck.log<br>on my computer.<br><br><br><br><br>STEPS FOR ADDING ANOTHER HOST:<br> - add the host on <a href="http://dnydns.org" target="_blank">dnydns.org</a>
<br> - run the script with makedat option<br> - run the script to update the server<br><br>In the example below, ipcheck will update the <a href="http://dyndns.org" target="_blank">dyndns.org</a> servers for the<br>names "
<a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a>" and for "<a href="http://myothername.mine.nu" target="_blank">myothername.mine.nu</a>":<br><br>sgeiger@minime:/root$ sudo /usr/sbin/ipcheck.py --makedat -l -r
<br><a href="http://checkip.dyndns.org:8245" target="_blank">checkip.dyndns.org:8245</a> shanerg asdfasdf<br><a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a>,<a href="http://sgeigerbot.mine.nu" target="_blank">
sgeigerbot.mine.nu</a>,<a href="http://myothername.mine.nu" target="_blank">myothername.mine.nu</a><br>ipcheck.py: There is already an ipcheck.dat file existing.<br>ipcheck.py: Remove this file first before running --makedat
<br>sgeiger@minime:/root$ sudo mv ipcheck.dat ipcheck.dat-old<br>sgeiger@minime:/root$ sudo /usr/sbin/ipcheck.py --makedat -l -r<br><a href="http://checkip.dyndns.org:8245" target="_blank">checkip.dyndns.org:8245</a> shanerg asdfasdf
<br><a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a>,<a href="http://sgeigerbot.mine.nu" target="_blank">sgeigerbot.mine.nu</a>,<a href="http://myothername.mine.nu" target="_blank">myothername.mine.nu</a>
<br>ipcheck.py: ip1 looking up <a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a><br>ipcheck.py: result: '<a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a>'[]['<a href="http://139.55.233.228" target="_blank">
139.55.233.228</a>']<br>ipcheck.py: ip2 looking up <a href="http://sgeigerbot.mine.nu" target="_blank">sgeigerbot.mine.nu</a><br>ipcheck.py: result: '<a href="http://sgeigerbot.mine.nu" target="_blank">sgeigerbot.mine.nu
</a>'[]['<a href="http://139.55.233.228" target="_blank">139.55.233.228</a>']<br>ipcheck.py: ip2 looking up <a href="http://myothername.mine.nu" target="_blank">myothername.mine.nu</a><br>ipcheck.py: result: '
<a href="http://myothername.mine.nu" target="_blank">myothername.mine.nu</a>'[]['<a href="http://139.55.233.228" target="_blank">139.55.233.228</a>']<br>sgeiger@minime:/root$<br><br><br>sgeiger@minime:/nu/mine/myothername$ sudo crontab -l
<br>15 10 * * * /usr/sbin/ipcheck.py -l -r <a href="http://checkip.dyndns.org:8245" target="_blank">checkip.dyndns.org:8245</a><br>shanerg asdfasdf <a href="http://sgeiger.mine.nu" target="_blank">sgeiger.mine.nu</a>,
<a href="http://sgeigerbot.mine.nu" target="_blank">sgeigerbot.mine.nu</a>,<a href="http://myothername.mine.nu" target="_blank">myothername.mine.nu</a><br>--acctfile /root/ipcheck.dat<br>sgeiger@minime:/nu/mine/myothername$
<br><font color="#888888"><br><br><br><br><br><br><br>--<br>Shane Geiger<br>IT Director<br>National Council on Economic Education<br><a href="mailto:sgeiger@ncee.net">sgeiger@ncee.net</a> | 402-438-8958 | <a href="http://www.ncee.net" target="_blank">
http://www.ncee.net</a><br><br>Leading the Campaign for Economic and Financial Literacy<br><br></font></blockquote></div><br>