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

Run a script when assigned a new DHCP address?

Discussion in 'Tomato Firmware' started by Mango, Jun 11, 2010.

  1. Mango

    Mango Addicted to LI Member

    Could anyone here please point me in the right direction of running a script whenever my ISP assigns me a new public IP address?

    Many thanks :)
    Mango
     
  2. rhester72

    rhester72 Network Guru Member

    You can always cache the public IP somewhere in /tmp, and compare it against the wan_ipaddr nvram variable in the WAN Up script...if it changes, do something. :)

    Rodney
     
  3. Mango

    Mango Addicted to LI Member

    Thanks. So, WAN Up will always fire on DHCP renewal?
     
  4. rhester72

    rhester72 Network Guru Member

    Well, hrm...I'm assuming the only circumstance under which your IP address would change during a DHCP renew is if you lost/had to re-establish your connection to your ISP...are you saying that your ISP will actually change your IP address "on the fly" without reconnection?

    Rodney
     
  5. Mango

    Mango Addicted to LI Member

    My IP address always changes every week or two with no input from me, and no obvious downtime.

    Let's find out if the WAN Up script will run then :) I set up a script that will keep track of when it is run.

    Edit: The WAN Up script does not run when the IP address is renewed. However, my public IP has not changed. I'll leave it for a week and see what happens.
     
  6. mstombs

    mstombs Network Guru Member

    If it did would be a big problem with my 30second lease to half-bridge modem!

    Firewall and WAN Up has to run on WAN-IP change, the IP is used in iptables rules.

    Changing an IP by dhcp is not pretty, the client (Tomato) has to give up trying to RENEW and then ask for and obtain a new one when the lease runs out - hence the short lease times with half bridge.

    Restarting the firewall does break connections, and misses the point of using nat MASQUERADE (I believe invented due to unreliable old dial-up connections). Some mods switched to using SNAT which doesn't require the netfilter code to keep checking its WAN IP.

    I use WAN UP to put message in log with new IP, and send an email to remote log in gmail account (sort of back-up to dyndns).
     
  7. Mango

    Mango Addicted to LI Member

    Thanks :)
     

Share This Page