1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

DDNS service and dyndns

Discussion in 'Tomato Firmware' started by cariyawa, Apr 7, 2010.

  1. cariyawa

    cariyawa Addicted to LI Member

    I have a quick question about using dyndns in tomato 1.27. If I selected dyndns, there is a check box named:
    Code:
    Save state when IP changes (nvram commit)
    What does that exactly mean?

    Say we select the check box. So is that means, it saves the current IP in nvram and after a reboot cycle, if router gets the same WAN IP, it doesn't change the IP in dyndns name server?

    On the other hand if I don't select the check box, will it update my WAN ip in dyndns name server regardless what happened to WAN IP after a reboot cycle?


    OR....is this means something completely different?:confused:
     
  2. mstombs

    mstombs Network Guru Member

    If your IP doesn't change and the router doesn't save the old IP address dyndns regards the update as abusive. If your IP changes on every reboot (or regular dsl reconnect) no point in all those extra flash writes to save the IP address.
     
  3. cariyawa

    cariyawa Addicted to LI Member

    Thanks mstombs for your reply.

    so just to be more sure.... In my case, my IP does change regularly after most of the reboot cycles , so I can save some flash wear, just by "NOT" selecting that check box. right?
     
  4. cariyawa

    cariyawa Addicted to LI Member

    OK... now I have more information..I checked the nvram variables and I believe these are the ones that is directly responsible for taking care of the DDNS stuff.

    Code:
    ddnsx0
    ddnsx0_cache
    ddnsx1
    ddnsx1_cache
    ddnsx_refresh
    ddnsx_save
    debug_ddns
    
    So I did the following test to see how they change.

    This is the values for nvram thorough clear case:

    Code:
    ddnsx0=
    ddnsx0_cache=
    ddnsx1=
    ddnsx1_cache=
    ddnsx_refresh=28
    ddnsx_save=1
    debug_ddns=0
    
    Now I set the dyndns with "Save state when IP changes (nvram commit)" check box enabled. So these are the values for the above variable.

    Code:
    ddnsx0=sdyndns<myusername:mypassword<myhostname.homelinux.com<0<<0<
    [b]ddnsx0_cache=1270654600,xx.xxx.xx.xxx[/b]
    ddnsx1=
    ddnsx1_cache=
    ddnsx_ip=
    ddnsx_refresh=28
    [b]ddnsx_save=1[/b]
    debug_ddns=0
    
    I can see that ddnsx_save is set to 1 and ddnsx0_cache has a value which is what we want. Because when next time reboots, if it gets the same WAN IP, it will not update the name server by comparing the one with nvram variables.

    Again, just to be sure, I did a nvram erase again and started all over.. but this time I didn't select the "Save state when IP changes (nvram commit)" check box. So basically I asked not to retain the IP when reboots. i.e. it supposed to update my dyndns account regardless of IP change. Here is the nvram dump.

    Code:
    ddnsx0=sdyndns<myusername:mypassword<myhostname.homelinux.com<0<<0<
    [b]ddnsx0_cache=1270654767,xx.xxx.xx.xxx[/b]
    ddnsx1=
    ddnsx1_cache=
    ddnsx_ip=
    ddnsx_refresh=28
    [b]ddnsx_save=0[/b]
    debug_ddns=0
    
    I can clearly see ddnsx_save is set to 0. But it also wrote to the ddnsx0_cache variable.

    Basically, I can't see a difference between above two, except ddnsx_save which has no effect at all on ddnsx0_cache nvram variable. It was written regardless of what we do with ddnsx_save variable.

    I didn't go through tomato code at all. Therefore I may have just twisted by brain...and talking nonsense but if I am right... logic should be something like this:

    Code:
    if(ddnsx_save==1) {
          save WAN IP in [b]ddnsx0_cache[/b]
          // this will retain the value in nvram and avoid abusive updates
    } else { // ddnsx_save=0 case 
          save WAN IP in a [b]temporary variable in RAM[/b]
          // this will allow to avoid abusive updates if IP chanegs while router is running
         // but once it reboots, it will update name servers regardless IP change.
    }
    
     
  5. Toastman

    Toastman Super Moderator Staff Member Member

    Ah, that's also interesting to me. Thanks both.

    Tomato's NVRAM can be corrupted by brownouts very easily. I found I could do it quite easily by pulling the power plug, reinstating it, and pulling it out again. I hadn't given it much thought after that - except that obviously it must be writing to NVRAM when the power hiccups occur. I can see this would be one reason, there are probably more :biggrin: Just never thought about it before...
     
  6. mstombs

    mstombs Network Guru Member

    I will check the code sometime, I recall this never worked properly in Hyperwrt Thibor, but seemed to just work in Tomato for me. It is important to save the IP and a timestamp, to get the forced updates after 28 days even if IP doesn't change, but there used to be an issue checking the cache time before ntpd had reset the correct time. Maybe the variables are stored in nvram vars, but no "nvram commit" is performed - but if something else also does a commit they get saved - that's the way flash works, a whole 64kB flash block is erased and rewritten for any change.

    When you have wan dhcp connection I have never really understood why the WAN IP, netmask and gateway are stored in nvram...
     
  7. cariyawa

    cariyawa Addicted to LI Member

    I also tried disabling Auto Refresh by putting 0. Then I was expecting to have ddnsx0_cache to be empty(hoping tomato uses some other temporary variable to keep the status), but it is not. So I think instead of using a temporary ram variable, tomato always use nvram variable(ddnsx0_cache) to store the status regardless what we choose for Save state when IP changes (nvram commit).

    I'll also try to get the source from git and dig in to it.. but it will be my first time peek on "tomato source". :biggrin:
     

Share This Page