LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxQuestions.org Member Success Stories (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/)
-   -   Using ipcheck with D-Link DI704P Router. (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/using-ipcheck-with-d-link-di704p-router-96189/)

/bin/bash 09-24-2003 01:33 AM

Using ipcheck with D-Link DI704P Router.
 
If you have an account with dyndns.org or some other dynamic dns service and you want your dynamic IP updated automatically you need to use some type of script. The alternative is you could manually login to the service and change the IP each time your lease expires... egad! The latter was not what I wanted so I searched the long list of clients which were available. The one I chose (mainly because it was supposed to work with the D-Link DI704P) was ipcheck. It is a python script "ipcheck.py" you simply pass a few options on the command line and away it goes... not!

I finally got the thing to work but it does require modifying the script. You can pass the username and password for the D-Link on the command line but there is no need to. The D-Link DI704P does not require you to login to access the status.htm page! I just commented out the part where the script does the login because it was causing me alot of grief. Another bug was the default user for the DI704 was set to root and should be admin. Finally where the script searches for the IP Address it was finding the LAN IP not the WAN IP. I changed the search KEY from "IP Address" to "WAN" and it worked.

If you get the ipcheck.py script for use on a DI704P Router here are the changes I made:
Code:

  1095c1095
<  DI704_user = "root"
---
>  DI704_user = "admin"
3557,3571c3557,3571
<      params = urllib.urlencode( menud )
<      ipurl = "http://" + iphost + "/cgi-bin/login"
<      logger.logit("urlopen " + ipurl)
<      urlfp = urllib.urlopen(ipurl, params)
<      logger.logit("urlfp.read")
<      ipdata = urlfp.read()
<      logger.logit("urlfp.close")
<      urlfp.close()
<      filename = "post.out"
<      if opt_directory:
<        filename = opt_directory + filename
<      fp = open(filename, "w")
<      fp.write(ipdata)
<      fp.close()
<      logger.logit("post.out file created")
---
>      # params = urllib.urlencode( menud )
>      # ipurl = "http://" + iphost + "/cgi-bin/login"
>      # logger.logit("urlopen " + ipurl)
>      # urlfp = urllib.urlopen(ipurl, params)
>      # logger.logit("urlfp.read")
>      # ipdata = urlfp.read()
>      # logger.logit("urlfp.close")
>      # urlfp.close()
>      # filename = "post.out"
>      # if opt_directory:
>      #  filename = opt_directory + filename
>      # fp = open(filename, "w")
>      # fp.write(ipdata)
>      # fp.close()
>      # logger.logit("post.out file created")
3597,3598c3597
<    p1 = string.find(ipdata, "IP Address")
<
---
>    p1 = string.find(ipdata, "WAN")

Yes I did email the author.

/bin/bash 10-01-2003 01:10 PM

UpDate:

I have since found that ddclient also works with a DI704P router, although it does not claim to.

Simply edit the /etc/ddclient.conf file and modify these lines:
Code:

use=fw, fw=192.168.0.1/status.htm, fw-skip='WAN' # found after IP Address
protocol=dyndns2                                # default protocol
#proxy=fasthttp.sympatico.ca:80                # default proxy
server=members.dyndns.org                      # default server
#server=members.dyndns.org:8245                # default server (bypassing proxies)

login=myloginID                            # default login
password=mypassword                          # default password
#mx=mx.for.your.host                            # default MX
#backupmx=yes|no                                # host is primary MX?
#wildcard=yes|no                                # add wildcard CNAME?
##
## dyndns.org dynamic addresses
##
## (supports variables: wildcard,mx,backupmx)
##
server=members.dyndns.org,            \
protocol=dyndns2                      \
myputer.mydomain.org



All times are GMT -5. The time now is 06:38 PM.