Results 1 to 9 of 9

Thread: Write me a new script or program?

Hybrid View

  1. #1
    Moderator
    Good Guru
    Compunuts's Avatar
    Join Date
    May 2001
    Location
    California
    Posts
    3,935

    Write me a new script or program?

    Here is the thing. My ISP now intentionally changed the network setting once in a while ( like once a month ). They are not only changing IPs and stuff but they are changing the whole net blocks effectively rendering my box useless once that happen ( except outgoing traffic ). Since I run a mail server and web server for personal use, I can't use it remotely until I got home, manually restart my NIC and change IP in my DNS setting.

    So is there any program ( or scripts ) that can do this?

    1. Will check my server via ping or host. Then will get IP addy.
    2. Will query local NIC interface with ifconfig command. Then extract the IP address info.
    3. Will match the two.
    4. If it's the same, then it will do nothing.
    5. If the IPs are different or if the ping didn't return an IP, then will mail the notification to third party address ( such as to gmail account of mine ) so that I can update DNS info rather than on the remote location and finding out it's not working any longer.
    6. Scripts of any language is acceptable since I won't be writing them. ;D
    7. The script or program will be run from crontab once every 8 hours.

    Can this be accomplished?

  2. #2

    Re:Write me a new script or program?

    If I'm getting what you're saying (I'm tired and very well may not be) this should do the trick:
    http://ddclient.sourceforge.net/

  3. #3

    Re:Write me a new script or program?

    if ddclient is not what you are looking for it's fairly simple to write an application that does what you want in bash I did something similiar some time a go using grep and awk it's easy to grab the ip from ifconfig

  4. #4

    Re:Write me a new script or program?

    Since your ips are changing... what is the dynamic dns server you are using?
    I'm using DynDNS and I use WebDate-0.1 to do that for me.

    Webdate-0.1: http://knowhow.garl.dyndns.org/webdate/

    ..

    HTH

  5. #5
    Moderator
    Good Guru
    Compunuts's Avatar
    Join Date
    May 2001
    Location
    California
    Posts
    3,935

    Re:Write me a new script or program?

    Okay, I will check out the ddclient.

    The main reason I don't use dyndns service is that your domain name is always http://your-server.dyndns.com which I don't want.

    I have my own domain name as http://www.my-domain.com and it's pointed to my IP address. But lately, my ISP had been doing crazy stuff ( it's a good thing the city is trying to negotiate a new cable provider and the California supreme court made decision last week that my ISP can't block the city's decision to negotiate deals with other providers for possible substitution ).

    So I'm guessing it is easy to do a ping or host query, then do a local query of IP, match against the two and send out alert if it's not the same. I, as in non-programmer, knows nothing about how to go about it. :-[

  6. #6

    Re:Write me a new script or program?

    Well no time like the present to learn...

    Anyways, you could just make a bash script, which is just a series of shell commands to be executed.

  7. #7

    Re:Write me a new script or program?

    [quote author=Compunuts link=board=9;threadid=9723;start=0#msg88379 date=1093582076]
    Okay, I will check out the ddclient.

    The main reason I don't use dyndns service is that your domain name is always http://your-server.dyndns.com which I don't want.

    I have my own domain name as http://www.my-domain.com and it's pointed to my IP address. But lately, my ISP had been doing crazy stuff ( it's a good thing the city is trying to negotiate a new cable provider and the California supreme court made decision last week that my ISP can't block the city's decision to negotiate deals with other providers for possible substitution ).

    So I'm guessing it is easy to do a ping or host query, then do a local query of IP, match against the two and send out alert if it's not the same. I, as in non-programmer, knows nothing about how to go about it. :-[
    [/quote]

    Try out http://www.zoneedit.com/. They allow DynDNS for those that have their own domains. As for IP address updating, you have several choices. If you want to write your own script, you can use http://cgi.internode.on.net/cgi-bin/showmyip?textonly=1 to get your current IP address and then use `dig +short <domain>` to check the IP address on the DNS records for your domain. Then compare those two and if they differ, update the DNS records. Here is a simple Perl script that may help you do what you want (you will need wget, dig, and lynx):
    Code:
    #!/usr/bin/perl -w
    
    use strict;
    
    # Complete the following variables
    my $ipaddr_file_location = "";
    my $domain_name = "";
    my $username = "";
    my $password = "";
    #No need to modify script following this line
    
    `wget --quiet -O $ipaddr_file_location http://cgi.internode.on.net/cgi-bin/showmyip?textonly=1`;
    
    my $dynaddr = `dig +short $domain_name`;
    my $newaddr = `cat $ipaddr_file_location`;
    
    chomp($dynaddr);
    chomp($newaddr);
    
    if ($dynaddr ne $newaddr)
    {
            `lynx -source -auth=$username:$password 'http://dynamic.zoneedit.com/auth/dynamic.html?host=$domain_name'`;
    }
    
    exit;
    P.S. To all the Perl coders: feel free to critic/improve this script.

  8. #8

    Re:Write me a new script or program?

    Code:
    #!/usr/bin/perl -w
    
    use strict;
    
    # Complete the following variables
    my $domain_name = "";
    my $username = "";
    my $password = "";
    #No need to modify script following this line
    
    my $dynaddr = `dig +short $domain_name`;
    my $newaddr = `wget --quiet -O - http://cgi.internode.on.net/cgi-bin/showmyip?textonly=1`;
    
    chomp($dynaddr);
    chomp($newaddr);
    
    if ($dynaddr ne $newaddr)
    {
            `lynx -source -auth=$username:$password 'http://dynamic.zoneedit.com/auth/dynamic.html?host=$domain_name'`;
    }
    
    exit;
    I'm not a Perl coder (actually, I prefer Python.) Nonetheless, the above is a little more succinct.

  9. #9

    Re:Write me a new script or program?

    [quote author=rhorn link=board=9;threadid=9723;start=0#msg88415 date=1093726489]
    I'm not a Perl coder (actually, I prefer Python.) Nonetheless, the above is a little more succinct.
    [/quote]

    Cool, thanks! I was not sure on how to directly assign the output of wget to a variable. Karma++

Similar Threads

  1. write simultaneously
    By svar in forum Linux - Hardware, Networking & Security
    Replies: 1
    Last Post: 10-08-2011, 06:42 AM
  2. KDE Issue: root isn't able to write anything
    By honey bee in forum Linux - General Topics
    Replies: 4
    Last Post: 09-01-2007, 06:02 AM
  3. how to write cron job
    By anu2 in forum General Chat
    Replies: 1
    Last Post: 03-02-2007, 12:28 PM
  4. How to write a pet
    By mcdougrs in forum Linux - General Topics
    Replies: 3
    Last Post: 01-09-2003, 04:50 PM
  5. linux script/program continue statement help!
    By morphman in forum Programming
    Replies: 5
    Last Post: 05-25-2002, 04:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •