NSLU2-Linux
view · edit · print · history

HowTo.SetUpYourOwnStaticLinkToYourSiteAtADynamicIP History

Hide minor edits - Show changes to markup

October 14, 2008, at 06:42 AM by SRS -- typos
Changed line 462 from:
      ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;
to:
      /opt/bin/ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;
Changed line 483 from:
    ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;
to:
    /opt/bin/ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;
Changed line 511 from:
   ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;
to:
   /opt/bin/ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;
October 12, 2008, at 08:02 PM by SRS -- date
Changed lines 401-402 from:
to:

BUG Fixes 10/12/2008

October 12, 2008, at 07:59 PM by SRS -- Description of bug fixes
Added lines 384-386:

BUG Fixes and improvements 10/12/2008 The 10/12/2008 update fixes some instances where the updates failed under unusual circumstances.

Changed lines 521-522 from:

SRS 07/06/2008

to:

BUG Fixes and improvements 10/12/2008 The 10/12/2008 update fixes some instances where the updates failed under unusual circumstances.

SRS 10/12/2008

October 12, 2008, at 07:50 PM by SRS -- BUG fixes and improvements
Added lines 403-404:
Changed lines 408-409 from:
  1. Version: 05/29/2008 SRS
to:
  1. Version: 10/12/2008 SRS
Added lines 497-510:
  1. If FTP Transfer Failed at any point or on last run then try again

if [ -f /var/tmp/ipnold.ip ]

 then
 /opt/bin/wget --quiet http://yourwebsite.com/ip.html --timeout=3 --output-document=/var/tmp/ipreal.html;
  if [ ! "`cat /var/tmp/ipreal.html`" = "`cat /var/tmp/ipnold.ip`" ]
   then
   #Fix up if IP read error this run
   rm -f /var/tmp/ip.html;
   cp /var/tmp/ipnold.ip /var/tmp/ip.html;
   # On prior FTP transfer failure now try again
   ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;
   echo "`date +mHS` - FIXED Failed Prior Tranfer -->UPDATED!" >> /var/log/ipnip_hist.log;
  fi

fi

Added line 514:
  1. updated SRS 10/12/2008
July 06, 2008, at 05:23 PM by SRS -- spelling correction on \"withe\"
Changed lines 393-394 from:

It has been tested and functions utilizing a variety of IP producing websites. It works perfectly withe the "www.whatismyip.com/automation/n09230945.asp" site referenced on this wiki page. The "checkip.dyndns.com" site (as per the script as is) seems quite reliable.

to:

It has been tested and functions utilizing a variety of IP producing websites. It works perfectly with the "www.whatismyip.com/automation/n09230945.asp" site referenced on this wiki page. The "checkip.dyndns.com" site (as per the script as is) seems quite reliable.

July 06, 2008, at 05:07 PM by SRS -- more format fixes
Changed lines 399-504 from:

(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

 #!/bin/ash                                                                                                                     

 # Stan's UpDate? IP to server remote Client for the Slug                                                                        
 # created by STAN, a variation of the 'DynDNSupdate' dnsupd script                                                             
 # Use NO variables the same as the 'DynDNSupdate' dnsupd script --important if might use the  'DynDNSupdate' script sometime(s)
 # Version: 05/29/2008 SRS                                                                                                      

 # Look for ipnerr.ip                                                                                                           
 if [ ! -f /var/tmp/ipnerr.ip ]                                                                                                 
 then                                                                                                                           
 # On ipnerr.ip not found.                                                                                                      
   # Set up ipnerr.ip for error logging.                                                                                        
   echo "off" > /var/tmp/ipnerr.ip                                                                                              
 fi                                                                                                                             
 # Fetch current IP Address.                                                                                                    
 # can use any ip displayer site you please, -  http://....                                                                     
 /opt/bin/wget --quiet http://checkip.dyndns.com/ --timeout=3 --output-document=/var/tmp/ip.html;                               
 # wget (line above) timeout to recieve site set to 3 seconds, change if problems, originaly not in script line;not specified   
 # Verify the data is good.                                                                                                     
 # may need to alter or eliminate INPAT lines below if change http://.... line above                                            
 IPNPAT='Current IP Address: *[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'                                                                   
 # TRY:  -         IPNPAT='[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' for line above for a different http://.... site                      
 #NOTE: the string IPNPAT='*[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' does NOT seem to work when tried with http://ipinfo.info            
 # (not advised) OR maybe use: -  if [ -f /var/tmp/ip.html ]  - for line below if ELIMINATE both INPAT lines                    
 if grep -q "$IPNPAT" /var/tmp/ip.html;                                                                                         
 then                                                                                                                           
 # On good IP data.                                                                                                             
   # Check for IP history.                                                                                                      
   if [ -f /var/tmp/ipnold.ip ]                                                                                                 
   then                                                                                                                         
   # On history found.                                                                                                          
     if [ "`cat /var/tmp/ipnerr.ip`" = "on" ]                                                                                   
     then                                                                                                                       
       echo "`date +mHS` - not updated: Network connection restored." >> /var/log/ipnip_hist.log;                     
       # Turn ipnerr.ip Off                                                                                                     
       echo "off" > /var/tmp/ipnerr.ip                                                                                          
     fi                                                                                                                         
     # Check for IP Change                                                                                                      
     if [ "`cat /var/tmp/ip.html`" = "`cat /var/tmp/ipnold.ip`" ]                                                               
     then                                                                                                                       
     # On no IP change                                                                                                          
       #                                                                                                                        

         # Check for Next day.                                                                                                  
         if [ ! "`cat /var/tmp/ipnday.ip`" = "`date +%x`" ]                                                                     
         then                                                                                                                   
         # On day change                                                                                                        
           # Log entry                                                                                                          
           echo "`date +mHS` - No update -" >> /var/log/ipnip_hist.log;                                               
           echo "`date +%x`" > /var/tmp/ipnday.ip;                                                                              
         fi                                                                                                                     

     else                                                                                                                       
     # On IP change                                                                                                             
       # Update server with a new ip.                                                                                           
       ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;             
       # Log the IP change and notify user.                                                                                     
       echo "`date +mHS` - update -" >> /var/log/ipnip_hist.log;                                                      
       echo "`date +%x`" > /var/tmp/ipnday.ip;                                                                                  
       rm -f /var/tmp/ipnold.ip;                                                                                                
       cp /var/tmp/ip.html /var/tmp/ipnold.ip;                                                                                  
 #     Set_Led beep1                                                                                                            
 #     Set_Led beep1                                                                                                            
 #     Set_Led beep1                                                                                                            
     fi                                                                                                                         
   else                                                                                                                         
   # On No History                                                                                                              
     # Initialize client and Update IP to server.                                                                               
     # Check ipnerr.ip status                                                                                                   
     if [ "`cat /var/tmp/ipnerr.ip`" = "on" ]                                                                                   
     then                                                                                                                       
     # Log Service Restoral.                                                                                                    
       echo "`date +mHS` - not updated: Network connection restored." >> /var/log/ipnip_hist.log;                     
     fi                                                                                                                         
     # Set ipnerr.ip off                                                                                                        
     echo "off" > /var/tmp/ipnerr.ip                                                                                            
     ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;               
     echo "`date +mHS` - initialization -" >> /var/log/ipnip_hist.log;                                                
     echo "`date +%x`" > /var/tmp/ipnday.ip;                                                                                    
     cp /var/tmp/ip.html /var/tmp/ipnold.ip;                                                                                    
   fi                                                                                                                           
 else                                                                                                                           
 # On IP read error                                                                                                             
   # Check ipnerr.ip status                                                                                                     
   if [ ! "`cat /var/tmp/ipnerr.ip`" = "on" ]                                                                                   
   then                                                                                                                         
   # On ipnerr.ip = off - Log read error.                                                                                       
     echo "`date +mHS` - not updated: read error on ip fetch" >> /var/log/ipnip_hist.log;                             
   fi                                                                                                                           
   # Set ipnerr.ip = On to allow only one error log on next run.                                                                
   echo "on" > /var/tmp/ipnerr.ip                                                                                               
   # Notify user.                                                                                                               
 # Set_Led beep2                                                                                                                
 fi                                                                                                                             
 # end                                                                                                                          
 # Set the interval of the next IP check using a crontab entry.                                                                 
 # Once every 15 minutes is good for a home server.                                                                             
to:

(:table border=0 width=100% bgcolor=#eeeeff:)

(:cell:)
#!/bin/ash

# Stan's UpDate IP to server remote Client for the Slug
# created by STAN, a variation of the 'DynDNSupdate' dnsupd script
# Use NO variables the same as the 'DynDNSupdate' dnsupd script --important if might use the  'DynDNSupdate' script sometime(s)
# Version: 05/29/2008 SRS

# Look for ipnerr.ip
if [ ! -f /var/tmp/ipnerr.ip ]
then
# On ipnerr.ip not found.
  # Set up ipnerr.ip for error logging.
  echo "off" > /var/tmp/ipnerr.ip
fi
# Fetch current IP Address.
# can use any ip displayer site you please, -  http://....
/opt/bin/wget --quiet http://checkip.dyndns.com/ --timeout=3 --output-document=/var/tmp/ip.html;
# wget (line above) timeout to recieve site set to 3 seconds, change if problems, originaly not in script line;not specified
# Verify the data is good.
# may need to alter or eliminate INPAT lines below if change http://.... line above
IPNPAT='Current IP Address: *[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'
# TRY:  -         IPNPAT='[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' for line above for a different http://.... site
#NOTE: the string IPNPAT='*[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' does NOT seem to work when tried with http://ipinfo.info
# (not advised) OR maybe use: -  if [ -f /var/tmp/ip.html ]  - for line below if ELIMINATE both INPAT lines
if grep -q "$IPNPAT" /var/tmp/ip.html;
then
# On good IP data.
  # Check for IP history.
  if [ -f /var/tmp/ipnold.ip ]
  then
  # On history found.
    if [ "`cat /var/tmp/ipnerr.ip`" = "on" ]
    then
      echo "`date +%Y%m%d.%H%M%S` - not updated: Network connection restored." >> /var/log/ipnip_hist.log;
      # Turn ipnerr.ip Off
      echo "off" > /var/tmp/ipnerr.ip
    fi
    # Check for IP Change
    if [ "`cat /var/tmp/ip.html`" = "`cat /var/tmp/ipnold.ip`" ]
    then
    # On no IP change
      #

        # Check for Next day. 
        if [ ! "`cat /var/tmp/ipnday.ip`" = "`date +%x`" ]
        then
        # On day change
          # Log entry
          echo "`date +%Y%m%d.%H%M%S` - No update -" >> /var/log/ipnip_hist.log;
          echo "`date +%x`" > /var/tmp/ipnday.ip;
        fi

    else
    # On IP change
      # Update server with a new ip. 
      ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;
      # Log the IP change and notify user.
      echo "`date +%Y%m%d.%H%M%S` - update -" >> /var/log/ipnip_hist.log;
      echo "`date +%x`" > /var/tmp/ipnday.ip;
      rm -f /var/tmp/ipnold.ip;
      cp /var/tmp/ip.html /var/tmp/ipnold.ip;
#     Set_Led beep1
#     Set_Led beep1
#     Set_Led beep1
    fi
  else
  # On No History
    # Initialize client and Update IP to server.
    # Check ipnerr.ip status
    if [ "`cat /var/tmp/ipnerr.ip`" = "on" ]
    then
    # Log Service Restoral.
      echo "`date +%Y%m%d.%H%M%S` - not updated: Network connection restored." >> /var/log/ipnip_hist.log;
    fi
    # Set ipnerr.ip off
    echo "off" > /var/tmp/ipnerr.ip
    ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;
    echo "`date +%Y%m%d.%H%M%S` - initialization -" >> /var/log/ipnip_hist.log;
    echo "`date +%x`" > /var/tmp/ipnday.ip;
    cp /var/tmp/ip.html /var/tmp/ipnold.ip;
  fi
else
# On IP read error
  # Check ipnerr.ip status
  if [ ! "`cat /var/tmp/ipnerr.ip`" = "on" ]
  then
  # On ipnerr.ip = off - Log read error. 
    echo "`date +%Y%m%d.%H%M%S` - not updated: read error on ip fetch" >> /var/log/ipnip_hist.log;
  fi
  # Set ipnerr.ip = On to allow only one error log on next run.
  echo "on" > /var/tmp/ipnerr.ip
  # Notify user.
# Set_Led beep2
fi
# end
# Set the interval of the next IP check using a crontab entry.
# Once every 15 minutes is good for a home server.
Added line 500:

\\

July 06, 2008, at 04:51 PM by SRS -- # comments cutoff so fixed this
Changed lines 401-498 from:
  1. !/bin/ash
  2. Stan's UpDate? IP to server remote Client for the Slug
  3. created by STAN, a variation of the 'DynDNSupdate' dnsupd script
  4. Use NO variables the same as the 'DynDNSupdate' dnsupd script --important if might use the 'DynDNSupdate' script sometime(s)
  5. Version: 05/29/2008 SRS
  6. Look for ipnerr.ip

if [ ! -f /var/tmp/ipnerr.ip ] then

  1. On ipnerr.ip not found.
    1. Set up ipnerr.ip for error logging.
    echo "off" > /var/tmp/ipnerr.ip

fi

  1. Fetch current IP Address.
  2. can use any ip displayer site you please, - http://....

/opt/bin/wget --quiet http://checkip.dyndns.com/ --timeout=3 --output-document=/var/tmp/ip.html;

  1. wget (line above) timeout to recieve site set to 3 seconds, change if problems, originaly not in script line;not specified
  2. Verify the data is good.
  3. may need to alter or eliminate INPAT lines below if change http://.... line above

IPNPAT='Current IP Address: *[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'

  1. TRY: - IPNPAT='[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' for line above for a different http://.... site
  2. NOTE: the string IPNPAT='*[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' does NOT seem to work when tried with http://ipinfo.info
  3. (not advised) OR maybe use: - if [ -f /var/tmp/ip.html ] - for line below if ELIMINATE both INPAT lines

if grep -q "$IPNPAT" /var/tmp/ip.html; then

  1. On good IP data.
    1. Check for IP history.
    if [ -f /var/tmp/ipnold.ip ] then
    1. On history found. if [ "`cat /var/tmp/ipnerr.ip`" = "on" ] then
      echo "`date +mHS` - not updated: Network connection restored." >> /var/log/ipnip_hist.log;
      # Turn ipnerr.ip Off
      echo "off" > /var/tmp/ipnerr.ip
    fi
    # Check for IP Change
    if [ "`cat /var/tmp/ip.html`" = "`cat /var/tmp/ipnold.ip`" ]
    then
    # On no IP change
      #

        # Check for Next day. 
        if [ ! "`cat /var/tmp/ipnday.ip`" = "`date +%x`" ]
        then
        # On day change
          # Log entry
          echo "`date +mHS` - No update -" >> /var/log/ipnip_hist.log;
          echo "`date +%x`" > /var/tmp/ipnday.ip;
        fi

    else
    # On IP change
      # Update server with a new ip. 
      ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;
      # Log the IP change and notify user.
      echo "`date +mHS` - update -" >> /var/log/ipnip_hist.log;
      echo "`date +%x`" > /var/tmp/ipnday.ip;
      rm -f /var/tmp/ipnold.ip;
      cp /var/tmp/ip.html /var/tmp/ipnold.ip;
  1. Set_Led beep1
  2. Set_Led beep1
  3. Set_Led beep1
    fi
  else
  # On No History
    # Initialize client and Update IP to server.
    # Check ipnerr.ip status
    if [ "`cat /var/tmp/ipnerr.ip`" = "on" ]
    then
    # Log Service Restoral.
echo "`date +mHS` - not updated: Network connection restored." >> /var/log/ipnip_hist.log; fi
  1. Set ipnerr.ip off
    echo "off" > /var/tmp/ipnerr.ip
    ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;
    echo "`date +mHS` - initialization -" >> /var/log/ipnip_hist.log;
    echo "`date +%x`" > /var/tmp/ipnday.ip;
    cp /var/tmp/ip.html /var/tmp/ipnold.ip;
  fi

else

  1. On IP read error
    1. Check ipnerr.ip status
    if [ ! "`cat /var/tmp/ipnerr.ip`" = "on" ] then
    1. On ipnerr.ip = off - Log read error. echo "`date +mHS` - not updated: read error on ip fetch" >> /var/log/ipnip_hist.log;
    fi
    1. Set ipnerr.ip = On to allow only one error log on next run.
    echo "on" > /var/tmp/ipnerr.ip
    1. Notify user.
  2. Set_Led beep2

fi

  1. end
  2. Set the interval of the next IP check using a crontab entry.
  3. Once every 15 minutes is good for a home server.
to:
 #!/bin/ash                                                                                                                     

 # Stan's UpDate? IP to server remote Client for the Slug                                                                        
 # created by STAN, a variation of the 'DynDNSupdate' dnsupd script                                                             
 # Use NO variables the same as the 'DynDNSupdate' dnsupd script --important if might use the  'DynDNSupdate' script sometime(s)
 # Version: 05/29/2008 SRS                                                                                                      

 # Look for ipnerr.ip                                                                                                           
 if [ ! -f /var/tmp/ipnerr.ip ]                                                                                                 
 then                                                                                                                           
 # On ipnerr.ip not found.                                                                                                      
   # Set up ipnerr.ip for error logging.                                                                                        
   echo "off" > /var/tmp/ipnerr.ip                                                                                              
 fi                                                                                                                             
 # Fetch current IP Address.                                                                                                    
 # can use any ip displayer site you please, -  http://....                                                                     
 /opt/bin/wget --quiet http://checkip.dyndns.com/ --timeout=3 --output-document=/var/tmp/ip.html;                               
 # wget (line above) timeout to recieve site set to 3 seconds, change if problems, originaly not in script line;not specified   
 # Verify the data is good.                                                                                                     
 # may need to alter or eliminate INPAT lines below if change http://.... line above                                            
 IPNPAT='Current IP Address: *[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'                                                                   
 # TRY:  -         IPNPAT='[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' for line above for a different http://.... site                      
 #NOTE: the string IPNPAT='*[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' does NOT seem to work when tried with http://ipinfo.info            
 # (not advised) OR maybe use: -  if [ -f /var/tmp/ip.html ]  - for line below if ELIMINATE both INPAT lines                    
 if grep -q "$IPNPAT" /var/tmp/ip.html;                                                                                         
 then                                                                                                                           
 # On good IP data.                                                                                                             
   # Check for IP history.                                                                                                      
   if [ -f /var/tmp/ipnold.ip ]                                                                                                 
   then                                                                                                                         
   # On history found.                                                                                                          
     if [ "`cat /var/tmp/ipnerr.ip`" = "on" ]                                                                                   
     then                                                                                                                       
       echo "`date +mHS` - not updated: Network connection restored." >> /var/log/ipnip_hist.log;                     
       # Turn ipnerr.ip Off                                                                                                     
       echo "off" > /var/tmp/ipnerr.ip                                                                                          
     fi                                                                                                                         
     # Check for IP Change                                                                                                      
     if [ "`cat /var/tmp/ip.html`" = "`cat /var/tmp/ipnold.ip`" ]                                                               
     then                                                                                                                       
     # On no IP change                                                                                                          
       #                                                                                                                        

         # Check for Next day.                                                                                                  
         if [ ! "`cat /var/tmp/ipnday.ip`" = "`date +%x`" ]                                                                     
         then                                                                                                                   
         # On day change                                                                                                        
           # Log entry                                                                                                          
           echo "`date +mHS` - No update -" >> /var/log/ipnip_hist.log;                                               
           echo "`date +%x`" > /var/tmp/ipnday.ip;                                                                              
         fi                                                                                                                     

     else                                                                                                                       
     # On IP change                                                                                                             
       # Update server with a new ip.                                                                                           
       ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;             
       # Log the IP change and notify user.                                                                                     
       echo "`date +mHS` - update -" >> /var/log/ipnip_hist.log;                                                      
       echo "`date +%x`" > /var/tmp/ipnday.ip;                                                                                  
       rm -f /var/tmp/ipnold.ip;                                                                                                
       cp /var/tmp/ip.html /var/tmp/ipnold.ip;                                                                                  
 #     Set_Led beep1                                                                                                            
 #     Set_Led beep1                                                                                                            
 #     Set_Led beep1                                                                                                            
     fi                                                                                                                         
   else                                                                                                                         
   # On No History                                                                                                              
     # Initialize client and Update IP to server.                                                                               
     # Check ipnerr.ip status                                                                                                   
     if [ "`cat /var/tmp/ipnerr.ip`" = "on" ]                                                                                   
     then                                                                                                                       
     # Log Service Restoral.                                                                                                    
       echo "`date +mHS` - not updated: Network connection restored." >> /var/log/ipnip_hist.log;                     
     fi                                                                                                                         
     # Set ipnerr.ip off                                                                                                        
     echo "off" > /var/tmp/ipnerr.ip                                                                                            
     ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;               
     echo "`date +mHS` - initialization -" >> /var/log/ipnip_hist.log;                                                
     echo "`date +%x`" > /var/tmp/ipnday.ip;                                                                                    
     cp /var/tmp/ip.html /var/tmp/ipnold.ip;                                                                                    
   fi                                                                                                                           
 else                                                                                                                           
 # On IP read error                                                                                                             
   # Check ipnerr.ip status                                                                                                     
   if [ ! "`cat /var/tmp/ipnerr.ip`" = "on" ]                                                                                   
   then                                                                                                                         
   # On ipnerr.ip = off - Log read error.                                                                                       
     echo "`date +mHS` - not updated: read error on ip fetch" >> /var/log/ipnip_hist.log;                             
   fi                                                                                                                           
   # Set ipnerr.ip = On to allow only one error log on next run.                                                                
   echo "on" > /var/tmp/ipnerr.ip                                                                                               
   # Notify user.                                                                                                               
 # Set_Led beep2                                                                                                                
 fi                                                                                                                             
 # end                                                                                                                          
 # Set the interval of the next IP check using a crontab entry.                                                                 
 # Once every 15 minutes is good for a home server.                                                                             
July 06, 2008, at 04:39 PM by SRS -- Highlight script
Changed lines 399-400 from:
to:

(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

Changed lines 499-500 from:
to:

(:tableend:) SRS 07/06/2008

July 06, 2008, at 04:33 PM by SRS -- The ip to staic ip ftp server script
Changed lines 400-403 from:
to:
  1. !/bin/ash
  2. Stan's UpDate? IP to server remote Client for the Slug
  3. created by STAN, a variation of the 'DynDNSupdate' dnsupd script
  4. Use NO variables the same as the 'DynDNSupdate' dnsupd script --important if might use the 'DynDNSupdate' script sometime(s)
  5. Version: 05/29/2008 SRS
  6. Look for ipnerr.ip

if [ ! -f /var/tmp/ipnerr.ip ] then

  1. On ipnerr.ip not found.
    1. Set up ipnerr.ip for error logging.
    echo "off" > /var/tmp/ipnerr.ip

fi

  1. Fetch current IP Address.
  2. can use any ip displayer site you please, - http://....

/opt/bin/wget --quiet http://checkip.dyndns.com/ --timeout=3 --output-document=/var/tmp/ip.html;

  1. wget (line above) timeout to recieve site set to 3 seconds, change if problems, originaly not in script line;not specified
  2. Verify the data is good.
  3. may need to alter or eliminate INPAT lines below if change http://.... line above

IPNPAT='Current IP Address: *[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'

  1. TRY: - IPNPAT='[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' for line above for a different http://.... site
  2. NOTE: the string IPNPAT='*[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' does NOT seem to work when tried with http://ipinfo.info
  3. (not advised) OR maybe use: - if [ -f /var/tmp/ip.html ] - for line below if ELIMINATE both INPAT lines

if grep -q "$IPNPAT" /var/tmp/ip.html; then

  1. On good IP data.
    1. Check for IP history.
    if [ -f /var/tmp/ipnold.ip ] then
    1. On history found. if [ "`cat /var/tmp/ipnerr.ip`" = "on" ] then
      echo "`date +mHS` - not updated: Network connection restored." >> /var/log/ipnip_hist.log;
      # Turn ipnerr.ip Off
      echo "off" > /var/tmp/ipnerr.ip
    fi
    # Check for IP Change
    if [ "`cat /var/tmp/ip.html`" = "`cat /var/tmp/ipnold.ip`" ]
    then
    # On no IP change
      #

        # Check for Next day. 
        if [ ! "`cat /var/tmp/ipnday.ip`" = "`date +%x`" ]
        then
        # On day change
          # Log entry
          echo "`date +mHS` - No update -" >> /var/log/ipnip_hist.log;
          echo "`date +%x`" > /var/tmp/ipnday.ip;
        fi

    else
    # On IP change
      # Update server with a new ip. 
      ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;
      # Log the IP change and notify user.
      echo "`date +mHS` - update -" >> /var/log/ipnip_hist.log;
      echo "`date +%x`" > /var/tmp/ipnday.ip;
      rm -f /var/tmp/ipnold.ip;
      cp /var/tmp/ip.html /var/tmp/ipnold.ip;
  1. Set_Led beep1
  2. Set_Led beep1
  3. Set_Led beep1
    fi
  else
  # On No History
    # Initialize client and Update IP to server.
    # Check ipnerr.ip status
    if [ "`cat /var/tmp/ipnerr.ip`" = "on" ]
    then
    # Log Service Restoral.
echo "`date +mHS` - not updated: Network connection restored." >> /var/log/ipnip_hist.log; fi
  1. Set ipnerr.ip off
    echo "off" > /var/tmp/ipnerr.ip
    ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com" /"optionalsubdirectory(s)"/ /var/tmp/ip.html;
    echo "`date +mHS` - initialization -" >> /var/log/ipnip_hist.log;
    echo "`date +%x`" > /var/tmp/ipnday.ip;
    cp /var/tmp/ip.html /var/tmp/ipnold.ip;
  fi

else

  1. On IP read error
    1. Check ipnerr.ip status
    if [ ! "`cat /var/tmp/ipnerr.ip`" = "on" ] then
    1. On ipnerr.ip = off - Log read error. echo "`date +mHS` - not updated: read error on ip fetch" >> /var/log/ipnip_hist.log;
    fi
    1. Set ipnerr.ip = On to allow only one error log on next run.
    echo "on" > /var/tmp/ipnerr.ip
    1. Notify user.
  2. Set_Led beep2

fi

  1. end
  2. Set the interval of the next IP check using a crontab entry.
  3. Once every 15 minutes is good for a home server.
July 06, 2008, at 04:31 PM by SRS -- Script for send IP to static ip server via ftp
Added lines 1-2:

Scroll down to 'UPDATE 07/06/2008' to see a script that will send your dynamic ip address as a html web page to a web server at a static address (of your choice).

Changed lines 383-389 from:
to:

UPDATE 07/06/2008 SRS

Here is a script that will send your dynamic ip address as a html web page to a web server at a static address (of your choice). It is originally based on the dnsupd script at the DynDNSupdate page ( http://www.nslu2-linux.org/wiki/HowTo/DynDNSupdate ); Version: 08/03/2006 (the one just following the 'Update: 7/30/2006' entry). Follow the instructions there to create the /var/tmp, and to get the script executable and running every 15 minutes.

You do NOT need any dynamic DNS service, just a server with FTP access. You will need to install the following packages: NCFTP, NCURES, WGET

It has been functioning perfectly for me for a few months now but there is no guarantees of it suitability or correctness.

It has been tested and functions utilizing a variety of IP producing websites. It works perfectly withe the "www.whatismyip.com/automation/n09230945.asp" site referenced on this wiki page. The "checkip.dyndns.com" site (as per the script as is) seems quite reliable.

I hope this will be of use to people.

SRS 07/06/2008

May 27, 2008, at 08:40 PM by Thomas Reitmayr --
Changed line 280 from:

...

to:

[@...

Changed lines 282-283 from:

...

to:

...@]

Changed line 298 from:
 #!/bin/sh
to:

#!/bin/sh

May 27, 2008, at 08:37 PM by Thomas Reitmayr --
Deleted line 290:

(remove the "(aprove site)" there is just 1 space between "echo" and "var"

May 27, 2008, at 08:33 PM by Thomas Reitmayr --
Changed lines 286-288 from:

If you like to have a direct link to your nslu the change ip.shtml (add html redirection):

<html><head><meta http-equiv="refresh" content="0; URL=http://<!--#echo var="REMOTE_ADDR" -->">

to:

If you like to have a direct link to your nslu then change ip.shtml (add html redirection):

<html><head><meta http-equiv="refresh" content="0; URL=http://<!--#echo var="REMOTE_ADDR" -->">

Changed line 299 from:
  1. !/bin/sh
to:
 #!/bin/sh
Changed line 351 from:
   wget -O $WORKDIR/no-ip.response.txt \ 
to:
   wget -O $WORKDIR/no-ip.response.txt \
Changed lines 358-359 from:
   test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "0" && \ 
     test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "1" && \ 
to:
   test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "0" && \
     test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "1" && \
Changed lines 370-371 from:

fi

to:
 fi
May 27, 2008, at 08:22 PM by Thomas Reitmayr --
Changed line 351 from:
   wget -O $WORKDIR/no-ip.response.txt \\
to:
   wget -O $WORKDIR/no-ip.response.txt \ 
Changed lines 358-359 from:
   test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "0" && 
test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "1" && \\
to:
   test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "0" && \ 
     test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "1" && \ 
May 27, 2008, at 08:18 PM by Thomas Reitmayr --
Changed line 351 from:
   wget -O $WORKDIR/no-ip.response.txt \
to:
   wget -O $WORKDIR/no-ip.response.txt \\
Changed lines 358-359 from:
   test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "0" &&      test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "1" && \
to:
   test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "0" && 
test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "1" && \\
May 27, 2008, at 08:17 PM by Thomas Reitmayr -- minor formatting improvement
Changed lines 352-353 from:

"http://dynupdate.no-ip.com/dns?username=$USERNAME&password=$PASSWD&hostname=$DOMAIN&ip=$NEWIP"

to:
     "http://dynupdate.no-ip.com/dns?username=$USERNAME&password=$PASSWD&hostname=$DOMAIN&ip=$NEWIP" 
Changed lines 358-360 from:
   test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "0" && test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "1" && cat $WORKDIR/no-ip.response.txt |mail -s "IP-change error..." $MAILTO
to:
   test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "0" &&      test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "1" &&      cat $WORKDIR/no-ip.response.txt |mail -s "IP-change error..." $MAILTO
May 17, 2008, at 06:32 AM by balleyne -- Added whatismyip.com automation page as an option
Added lines 49-50:

Or you could just use the automation service at whatismyip.com, since they provide a page that does exactly this already. See http://whatismyip.com/automation.asp

July 14, 2006, at 10:29 PM by Dutch --
Changed lines 16-17 from:
 <% Response.Write Request.ServerVariables("REMOTE_ADDR") %>
to:
 <head><title>IP</title></head>
 <body><% Response.Write Request.ServerVariables("REMOTE_ADDR") %></body>
July 14, 2006, at 09:51 PM by Dutch --
Added lines 16-24:
 <% Response.Write Request.ServerVariables("REMOTE_ADDR") %>

(:tableend:)


PHP version (courtesy of tman):

(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

Deleted lines 27-33:
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 <%
 dim address
 '
 address = Request.ServerVariables("REMOTE_ADDR")
 '
 %>
Changed line 29 from:
 <body><% response.write address %></body>
to:
 <body><?php echo $_SERVER['REMOTE_ADDR']; ?></body>
Changed lines 35-36 from:

PHP version (courtesy of tman):

to:

Perl version (courtesy of Roy Silvernail):

Changed lines 39-44 from:
 <html>
 <head>
 <title>IP</title>
 </head>
 <body><?php echo $_SERVER['REMOTE_ADDR']; ?></body>
 </html>
to:
 #!/usr/bin/perl
 use Carp;
 use CGI;
 $q = new CGI;
 print "Content-type: text/plain\n\n".$ENV{'REMOTE_ADDR'}."\n";
Changed lines 48-49 from:

Perl version (courtesy of Roy Silvernail):

to:

The script portions will look different in some other language, but the HTML ought to be the same, since all you want on the page is the IP address....


Step 2:

This script generates a tiny web page with the links to your site based on your gateway's IP when passed your gateway's IP as a parameter:


Deleted lines 59-79:
 #!/usr/bin/perl
 use Carp;
 use CGI;
 $q = new CGI;
 print "Content-type: text/plain\n\n".$ENV{'REMOTE_ADDR'}."\n";

(:tableend:)


The script portions will look different in some other language, but the HTML ought to be the same, since all you want on the page is the IP address....


Step 2:

This script generates a tiny web page with the links to your site based on your gateway's IP when passed your gateway's IP as a parameter:


(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

April 04, 2006, at 07:53 PM by Steve G -- Note about wget versions
Added lines 244-248:

I was really confused by this until I realised that for HTTPS you need the 1.10.2-2 version of wget in the wget-ssl ipkg rather than 1.9.1-r1 version in ipkg wget! Now I have a Perl script to ask my router (D-Link DI-524) for it's status page, extract the current IP address, check it, and update my DynDNS if necessary. Brilliant! Steve G

February 28, 2006, at 08:11 AM by Daniel Deremiah -- modified last script to mak it working.
Changed line 303 from:
 #!/bin/sh
to:
  1. !/bin/sh
Changed lines 355-356 from:
   wget -O $WORKDIR/no-ip.response.txt "http://dynupdate.no-ip.com/dns?username=$USERNAME&password=$PASSWD&hostname=$DOMAIN&ip=$NEWIP" 
to:
   wget -O $WORKDIR/no-ip.response.txt "http://dynupdate.no-ip.com/dns?username=$USERNAME&password=$PASSWD&hostname=$DOMAIN&ip=$NEWIP" 
Added line 361:
   cd $WORKDIR
February 28, 2006, at 08:00 AM by Daniel Deremiah -- added some changes to the last script
Changed lines 370-371 from:
to:

fi

Changed lines 375-377 from:
 rm $WORKDIR/wget.log
 rm $WORKDIR/no-ip.response.txt
 rm $WORKDIR/whatismyip
to:
 rm $WORKDIR/wget.log 2> /dev/null
 rm $WORKDIR/no-ip.response.txt 2> /dev/null
 rm $WORKDIR/whatismyip 2> /dev/null
January 29, 2006, at 02:04 PM by Stein -- www.no-ip.com
Changed lines 298-308 from:
to:

Stein: Here is a complete script to update your www.no-ip.com account:

(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

 #!/bin/sh
 #
 # File: ~/script/checkIP/checkIP
 # This script checks if you have a new Internet IP address.
 # If so, it will update your profile at www.no.ip.org and 
 # send you a email notification.
 #

 #set -x

 MAILTO="your@address"
 WORKDIR=~/script/checkIP
 USERNAME="username"
 PASSWD="pswd"
 DOMAIN="your.no-ip.org"  

 #
 #Download the html page with the IP and save it to the file: whatismyip
 #
 wget -o $WORKDIR/wget.log -O $WORKDIR/whatismyip whatismyip.com  

 #
 #Isolate the new IP
 #
 NEWIP=$(grep '[0-9].[0-9].[0-9].[0-9]' $WORKDIR/whatismyip |grep displaycopy| cut -d"'" -f 2)
  #
  # NOTE: the "grep '[0-9].[0-9].[0-9].[0-9]" will not always filter just the IP address
  #

 #
 # Get the stored "old" IP address
 #
 OLDIP=$(cat $WORKDIR/oldip) 

 #
 # Compare the files: newip and oldip and act accordingly
 #
 if [ "$NEWIP" = "$OLDIP" ]; then
   echo "OLD IP ($OLDIP)"
 #elif [ "$NEWIP" != '[0-9].[0-9].[0-9].[0-9]' ]; then 
 #Does not seem to work :-(
   #
   # Print error and append ip to wget.log
   #
 #  echo "Error... (NewIP: $NEWIP)" |tee -a $WORKDIR/wget.log  
 #  cat $WORKDIR/wget.log |mail -s "CheckIP? ERROR" $MAILTO
 else
   echo "NEW IP! $NEWIP (Old: $OLDIP)"

   #
   # Update www.no-ip.org
   # For help take a look at: http://www.no-ip.com/integrate/
   wget -O $WORKDIR/no-ip.response.txt "http://dynupdate.no-ip.com/dns?username=$USERNAME&password=$PASSWD&hostname=$DOMAIN&ip=$NEWIP" 

   #
   # Check reply from no-ip.org. "0" and "1" response is good.
   #
   test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "0" && test "$(cat no-ip.response.txt|cut -d ":" -f 2)" != "1" && cat $WORKDIR/no-ip.response.txt |mail -s "IP-change error..." $MAILTO
   #
   # Send email notification
   #
   echo $NEWIP |mail -s "New IP" $MAILTO

   #
   # Stores the new ip
   #
   echo $NEWIP > $WORKDIR/oldip


 #
 # Clean up
 #
 rm $WORKDIR/wget.log
 rm $WORKDIR/no-ip.response.txt
 rm $WORKDIR/whatismyip

(:tableend:)

January 09, 2006, at 03:52 AM by Psychodad -- simple ip upload
Added line 295:

(remove the "(aprove site)" there is just 1 space between "echo" and "var"

January 09, 2006, at 03:48 AM by Psychodad --
Changed lines 280-281 from:

... repplace xyz, user, password and: chmod 755 /opt/getip.sh

to:

... replace xyz, user, password and: chmod 755 /opt/getip.sh

Changed lines 290-298 from:
to:

If you like to have a direct link to your nslu the change ip.shtml (add html redirection):

<html><head><meta http-equiv="refresh" content="0; URL=http://<!--#echo var="REMOTE_ADDR" -->"> <BODY></html>


January 09, 2006, at 03:39 AM by Psychodad --
Changed lines 265-279 from:
  1. !/bin/sh

cd /opt rm ip.shtml wget www.xyz.ch/ip.shtml cat ip.shtml >nslu.html USER=user PASSWD=password ftp -n www.xyz.ch <<END user $USER $PASSWD cd html asc put nslu.html quit END

to:
 #!/bin/sh
 cd /opt
 rm ip.shtml
 wget www.xyz.ch/ip.shtml
 cat ip.shtml >nslu.html
 USER=user
 PASSWD=password
 ftp -n www.xyz.ch <<END
 user $USER $PASSWD
 cd html
 asc
 put nslu.html
 quit
 END
Added line 283:
January 09, 2006, at 03:38 AM by Psychodad --
Added lines 244-297:

and even more simple: (version with own server and no DynDNS-provider)

I just did it! You do not need a script to get your IP, just upload this to your server and name it ip.shtml

<html> <head></head><body>

<!--#echo var="REMOTE_ADDR" -->

</body> </html>

So www.yourserver.com/ip.shtml should show your IP.

Then use this script to ftp the ip to your server:

File: opt/getip.sh

  1. !/bin/sh

cd /opt rm ip.shtml wget www.xyz.ch/ip.shtml cat ip.shtml >nslu.html USER=user PASSWD=password ftp -n www.xyz.ch <<END user $USER $PASSWD cd html asc put nslu.html quit END

... repplace xyz, user, password and: chmod 755 /opt/getip.sh

Now just ad a line to /etc/crontab ...

 1 * * * 0 root    /opt/getip.sh

...

And you can see your IP on www.yourserever.com/nslu.html

November 24, 2005, at 05:39 AM by MattMcNeill -- everydns
Changed lines 238-243 from:

Personally, my vote goes for Malfi's solution, since you can host something with your own top level domain with a free dynamic dns server like hn.org or if you don't mind a sub-domain, many excellent dynamic dns servers like dyndns.org offer this for free (yourname.dyndns.org). If you already have a site, and for whatever reason, you want to link to your setup instead of distributing your setup's address directly to users, you may always do so with a link to "yourname.dyndns.org" or use zero-frame forwarding to hide your actual address.

to:

Personally, my vote goes for Malfi's solution, since you can host something with your own top level domain with a free dynamic dns server like hn.org or if you don't mind a sub-domain, many excellent dynamic dns servers like dyndns.org offer this for free (yourname.dyndns.org). If you already have a site, and for whatever reason, you want to link to your setup instead of distributing your setup's address directly to users, you may always do so with a link to "yourname.dyndns.org" or use zero-frame forwarding to hide your actual address.


I also like the dyndns solution. My router actually automatically updates my dyndns account to point to its WAN IP address so I don't even really need Malfi's script, but the real beauty comes in after that. I have purchased my own domain name from an ISP and use a free DNS management service (http://www.everydns.net/) to add a CNAME into my dns record so that home.mydnsname.org is aliased to mydnsname.dyndns.org. Thus I have a static and personalised DNS record which always gets me back to my home network. Works like a charm.

November 22, 2005, at 05:50 AM by James Fu -- Comparison
Added lines 229-238:

Lol, I'd say both methods are useful in their own rights.

In the script outlined by Malfi, you'll be able to host a page from your home or wherever you have the setup. This is useful when 1) You don't want to pay someone to host your site. 2) It's ineffective to host your site elsewhere because you host big and constantly changing files, like music, movies, etc.

In the original script, you'll have to host a page somewhere, be it paid or a free service like Geocities. There, a link could point to your setup on a dynamic IP. With the script, a dynamic dns provider is cut out of the equation.

Personally, my vote goes for Malfi's solution, since you can host something with your own top level domain with a free dynamic dns server like hn.org or if you don't mind a sub-domain, many excellent dynamic dns servers like dyndns.org offer this for free (yourname.dyndns.org). If you already have a site, and for whatever reason, you want to link to your setup instead of distributing your setup's address directly to users, you may always do so with a link to "yourname.dyndns.org" or use zero-frame forwarding to hide your actual address.

August 21, 2005, at 01:07 PM by tman --
Changed lines 1-2 from:

Here's what I did. Feel free to make improvements, especially in Step 1. If there's a way to get this info from a router directly instead of indirectly via a website as decribed, then I'm all ears! :^) I'm also interested in a way of directly scripting a Lynx session so that a domain name service could be updated automatically when the IP changes. This would allow a slug to host a site like "www.myslug.net" or something like that. It comes down to passing in the passwords when prompted.... Any "expect" experts out there? :^)

to:

Here's what I did. Feel free to make improvements, especially in Step 1. If there's a way to get this info from a router directly instead of indirectly via a website as described, then I'm all ears! :^) I'm also interested in a way of directly scripting a Lynx session so that a domain name service could be updated automatically when the IP changes. This would allow a slug to host a site like "www.myslug.net" or something like that. It comes down to passing in the passwords when prompted.... Any "expect" experts out there? :^)

August 20, 2005, at 04:23 PM by Dutch --
Deleted lines 48-49:

Deleted line 50:
August 20, 2005, at 04:22 PM by Dutch --
Changed lines 53-58 from:

$ cat rat.cgi

  1. !/usr/bin/perl

use Carp; use CGI; $q = new CGI; print "Content-type: text/plain\n\n".$ENV{'REMOTE_ADDR'}."\n";

to:
 #!/usr/bin/perl
 use Carp;
 use CGI;
 $q = new CGI;
 print "Content-type: text/plain\n\n".$ENV{'REMOTE_ADDR'}."\n";
August 20, 2005, at 04:20 PM by Dutch --
Changed lines 203-204 from:

Well, I just couldn't stand this, get yourself an account at dyndns.org and run this as a cronjob:

to:

Well, I just couldn't stand this, get yourself an account at dyndns.org and run this as a cronjob (courtesy of Malfi):

August 20, 2005, at 04:17 PM by Dutch --
Changed lines 33-34 from:

PHP version:

to:

PHP version (courtesy of tman):

Changed lines 47-48 from:

The script portions will look different in some other language, but the HTML ought to be the same, since all you want on the page is the IP address....

to:

Perl version (courtesy of Roy Silvernail):

Deleted lines 50-55:

Step 2:

This script generates a tiny web page with the links to your site based on your gateway's IP when passed your gateway's IP as a parameter:


Added lines 53-74:

$ cat rat.cgi

  1. !/usr/bin/perl

use Carp; use CGI; $q = new CGI; print "Content-type: text/plain\n\n".$ENV{'REMOTE_ADDR'}."\n"; (:tableend:)


The script portions will look different in some other language, but the HTML ought to be the same, since all you want on the page is the IP address....


Step 2:

This script generates a tiny web page with the links to your site based on your gateway's IP when passed your gateway's IP as a parameter:


(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

August 20, 2005, at 01:55 PM by tman --
Deleted line 128:
 current_ip=`cat temp_ip`
Changed lines 181-182 from:

This script assumes that your files are in your /root directory. Modify the localHtmlFile value as necessary if you put them somewhere else, but make sure you keep the scripts all in the same folder. It also creates two files, "remote_ip" and "temp_ip" to hold the previous IP address and the IP address you're comparing it to. If it finds that they are the same, it exits without FTPing the HTML file to your web host.

to:

This script assumes that your files are in your /root directory. Modify the localHtmlFile value as necessary if you put them somewhere else, but make sure you keep the scripts all in the same folder. It also creates two files, "router_ip" and "temp_ip" to hold the previous IP address and the IP address you're comparing it to. If it finds that they are the same, it exits without FTPing the HTML file to your web host.

August 20, 2005, at 01:51 PM by tman --
Changed lines 122-123 from:
 ip_page_url = http://www.somewhere-where-your-page-is.com/remote-ip.asp
to:
 ip_page_url=http://www.somewhere-where-your-page-is.com/remote-ip.asp
August 20, 2005, at 01:48 PM by tman --
Added lines 11-12:

ASP version:

Changed lines 33-42 from:

Your example's script portions will look different in some other language, but the HTML ought to be the same, since all you want on the page is the IP address....


Step 2:

This script generates a tiny web page with the links to your site based on your gateway's IP when passed your gateway's IP as a parameter:


to:

PHP version:

Deleted lines 36-51:
 #!/bin/sh
 if [ -n "$1" ]
 then
   url=$1
 else
   url=ERROR
 fi

 if [ -n "$2" ]
 then
   port=$2
 else
   port=80
 fi

 cat > dyn-ip.html << EOF
Changed lines 38-58 from:
  <head>
   <title>Link to My uNSLUng NSLU2's Web Site</title>
  </head>
  <body bgcolor="#000033">
   <table width="420" border="2" cellpadding="3" cellspacing="0" bgcolor="#F6F6F6">
    <tr align="center">
     <td>
      <a href="http://$url:$port/">My uNSLUng NSLU2 Homepage</a>
     </td>
    </tr>
    <tr align="center">
     <td>
      <p class="quote">
       This link may be bad from time to time, but it is dynamically 
       updated on the 42nd minute of every hour, so try back then if
       it doesn't work!
      </p>
     </td>
    </tr>
   </table>
  </body>
to:
 <head>
 <title>IP</title>
 </head>
 <body><?php echo $_SERVER['REMOTE_ADDR']; ?></body>
Deleted line 42:
 EOF
Changed lines 47-52 from:

Side notes about the above script:

1. It can also be used on the command line to create a small page with a link to any site you wish, simply by passing it the site's address (minus the "http://" part, of course), and with a little modification (taking out the table tags and changing the first output redirect to append), it could be used to collect a list of links....

2. If you have your web server on a port different than 80, add a second command line parameter and pass the port number in

to:

The script portions will look different in some other language, but the HTML ought to be the same, since all you want on the page is the IP address....

Changed lines 51-54 from:

Step 3:

Use this script (in a cron job, perhaps) to check your IP on that page you set up in Step 1 and, only if the IP address has changed, upload a web page created "on the fly" by the script in Step 2:

to:

Step 2:

This script generates a tiny web page with the links to your site based on your gateway's IP when passed your gateway's IP as a parameter:

Changed line 56 from:
to:
Changed lines 60-78 from:
 # Change the following link to where you put the remote IP script from above.
 ip_page_url = http://www.somewhere-where-your-page-is.com/remote-ip.asp

 #
 # get the current IP of the router
 current_ip=`lynx -accept_all_cookies -dump $ip_page_url
 #
 echo $current_ip > temp_ip
 current_ip=`cat temp_ip`
 #
 # get the old IP of the router
 old_ip=`cat router_ip`
 #
 Set_Led beep1
 sleep 1
 #
 # compare to see if update is necessary
 if [[ $current_ip != $old_ip ]]
to:
 if [ -n "$1" ]
Changed lines 62-94 from:
 # uncomment following line for user feedback or debugging
 #    echo "$current_ip different from $old_ip so running update script"
    Set_Led beep1
    sleep 1
    Set_Led beep1
 #
    echo $current_ip > /router_ip
 #
    echo `date` : $current_ip >> /share/hdd/data/syslog/router_ip_history
 #
 # uncomment following line for user feedback or debugging
 #   echo "wrote current ip $current_ip to router_ip"
 #
 # uncomment following line for user feedback or debugging
 #   echo "generating dyn-ip.html"
    generate-dyn_ip_html $current_ip
 #
    remote="www.somewhere-where-your-page-is.com"
    localHtmlFile="/root/dyn-ip.html"
    htmlFile="dyn-ip.shtm"
 #
 # uncomment following lines for user feedback or debugging
 #   echo "attempting to put $localHtmlFile to $remote/$htmlFile"
 #   echo "attempting to put $localHtmlFile to $remote/$targetdir/$htmlFile"
 #
    ftp $remote << EOF
 put $localHtmlFile $htmlFile
 exit
 EOF
 #
 # uncomment following line for user feedback or debugging
 #   echo "completed ftp session"
 #
to:
   url=$1
Changed lines 64-66 from:
 # uncomment following line for user feedback or debugging
 #   echo "$current_ip same as $old_ip so exiting update script"
    Set_Led beep1
to:
   url=ERROR
Changed lines 66-89 from:

(:tableend:)


This script assumes that your files are in your /root directory. Modify the localHtmlFile value as necessary if you put them somewhere else, but make sure you keep the scripts all in the same folder. It also creates two files, "remote_ip" and "temp_ip" to hold the previous IP address and the IP address you're comparing it to. If it finds that they are the same, it exits without FTPing the HTML file to your web host.

I hope this helps!


Well, I just couldn't stand this, get yourself an account at dyndns.org and run this as a cronjob:
(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

 #!/bin/sh

 user=your_dyndns_username
 pass=your_dyndns_password
 host=your_dyndns_hostname

 IP=`wget -qO - http://whatsmyip.smokingmedia.com/ | \
  grep "TITLE" | \
  sed -e "s#^[^0-9]\+\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)[^0-9]\+...\$#\1#g"`
 if [ "`cat /tmp/dyndns.ip`" != "$IP" ]
to:
 if [ -n "$2" ]
Changed lines 69-72 from:
  wget --no-check-certificate -q -O - \
  https://$user:$pass@members.dyndns.org/nic/update?system=dyndns&hostname=$host&myip=$IP" \
  >> /tmp/dyndns.update.log 2> /dev/null
  echo -n $IP > /tmp/dyndns.ip
to:
   port=$2
 else
   port=80
Added lines 73-98:
 cat > dyn-ip.html << EOF
 <html>
  <head>
   <title>Link to My uNSLUng NSLU2's Web Site</title>
  </head>
  <body bgcolor="#000033">
   <table width="420" border="2" cellpadding="3" cellspacing="0" bgcolor="#F6F6F6">
    <tr align="center">
     <td>
      <a href="http://$url:$port/">My uNSLUng NSLU2 Homepage</a>
     </td>
    </tr>
    <tr align="center">
     <td>
      <p class="quote">
       This link may be bad from time to time, but it is dynamically 
       updated on the 42nd minute of every hour, so try back then if
       it doesn't work!
      </p>
     </td>
    </tr>
   </table>
  </body>
 </html>
 EOF
Added lines 103-211:

Side notes about the above script:

1. It can also be used on the command line to create a small page with a link to any site you wish, simply by passing it the site's address (minus the "http://" part, of course), and with a little modification (taking out the table tags and changing the first output redirect to append), it could be used to collect a list of links....

2. If you have your web server on a port different than 80, add a second command line parameter and pass the port number in


Step 3:

Use this script (in a cron job, perhaps) to check your IP on that page you set up in Step 1 and, only if the IP address has changed, upload a web page created "on the fly" by the script in Step 2:


(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

 #!/bin/sh

 # Change the following link to where you put the remote IP script from above.
 ip_page_url = http://www.somewhere-where-your-page-is.com/remote-ip.asp

 #
 # get the current IP of the router
 current_ip=`lynx -accept_all_cookies -dump $ip_page_url`
 #
 echo $current_ip > temp_ip
 current_ip=`cat temp_ip`
 #
 # get the old IP of the router
 old_ip=`cat router_ip`
 #
 Set_Led beep1
 sleep 1
 #
 # compare to see if update is necessary
 if [[ $current_ip != $old_ip ]]
 then
 # uncomment following line for user feedback or debugging
 #    echo "$current_ip different from $old_ip so running update script"
    Set_Led beep1
    sleep 1
    Set_Led beep1
 #
    echo $current_ip > /router_ip
 #
    echo `date` : $current_ip >> /share/hdd/data/syslog/router_ip_history
 #
 # uncomment following line for user feedback or debugging
 #   echo "wrote current ip $current_ip to router_ip"
 #
 # uncomment following line for user feedback or debugging
 #   echo "generating dyn-ip.html"
    generate-dyn_ip_html $current_ip
 #
    remote="www.somewhere-where-your-page-is.com"
    localHtmlFile="/root/dyn-ip.html"
    htmlFile="dyn-ip.shtm"
 #
 # uncomment following lines for user feedback or debugging
 #   echo "attempting to put $localHtmlFile to $remote/$htmlFile"
 #   echo "attempting to put $localHtmlFile to $remote/$targetdir/$htmlFile"
 #
    ftp $remote << EOF
 put $localHtmlFile $htmlFile
 exit
 EOF
 #
 # uncomment following line for user feedback or debugging
 #   echo "completed ftp session"
 #
 else
 # uncomment following line for user feedback or debugging
 #   echo "$current_ip same as $old_ip so exiting update script"
    Set_Led beep1
 fi

(:tableend:)


This script assumes that your files are in your /root directory. Modify the localHtmlFile value as necessary if you put them somewhere else, but make sure you keep the scripts all in the same folder. It also creates two files, "remote_ip" and "temp_ip" to hold the previous IP address and the IP address you're comparing it to. If it finds that they are the same, it exits without FTPing the HTML file to your web host.

I hope this helps!


Well, I just couldn't stand this, get yourself an account at dyndns.org and run this as a cronjob:
(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

 #!/bin/sh

 user=your_dyndns_username
 pass=your_dyndns_password
 host=your_dyndns_hostname

 IP=`wget -qO - http://whatsmyip.smokingmedia.com/ | \
  grep "TITLE" | \
  sed -e "s#^[^0-9]\+\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)[^0-9]\+...\$#\1#g"`
 if [ "`cat /tmp/dyndns.ip`" != "$IP" ]
 then
  wget --no-check-certificate -q -O - \
  https://$user:$pass@members.dyndns.org/nic/update?system=dyndns&hostname=$host&myip=$IP" \
  >> /tmp/dyndns.update.log 2> /dev/null
  echo -n $IP > /tmp/dyndns.ip
 fi

(:tableend:)


August 20, 2005, at 01:46 PM by tman --
Changed lines 1-8 from:

Here's what I did. Feel free to make improvements, especially in Step 1.
If there's a way to get this info from a router directly instead of indirectly via a
website as decribed, then I'm all ears! :^) I'm also interested in a way of directly
scripting a Lynx session so that a domain name service could be updated automatically
when the IP changes. This would allow a slug to host a site like "www.myslug.net" or
something like that. It comes down to passing in the passwords when prompted....
Any "expect" experts out there? :^)

to:

Here's what I did. Feel free to make improvements, especially in Step 1. If there's a way to get this info from a router directly instead of indirectly via a website as decribed, then I'm all ears! :^) I'm also interested in a way of directly scripting a Lynx session so that a domain name service could be updated automatically when the IP changes. This would allow a slug to host a site like "www.myslug.net" or something like that. It comes down to passing in the passwords when prompted.... Any "expect" experts out there? :^)

Changed lines 7-11 from:

Set up a page on a web hosting site that has some sort of active server side scripting
technology, be it .ASP, .PHP, or whatever, that can read the server variable "REMOTE_ADDR"
to get the IP address assigned to your gateway/router/cablemodem/56Kmodem. I used .ASP,
since my web host works with that, and here it is:

to:

Set up a page on a web hosting site that has some sort of active server side scripting technology, be it ASP, PHP, or whatever, that can read the server variable "REMOTE_ADDR" to get the IP address assigned to your gateway/router/cablemodem/modem. I used .ASP, since my web host works with that, and here it is:

Changed lines 11-25 from:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>IP</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<%
dim address
'
address = Request.ServerVariables("REMOTE_ADDR")
'
%>
</head>
<body><% response.write address %></body>
</html>
to:

(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

 <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
 <html>
 <head>
 <title>IP</title>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 <%
 dim address
 '
 address = Request.ServerVariables("REMOTE_ADDR")
 '
 %>
 </head>
 <body><% response.write address %></body>
 </html>

(:tableend:)

Changed lines 31-33 from:

Your example's script portions will look different in some other language, but the HTML ought
to be the same, since all you want on the page is the IP address....

to:

Your example's script portions will look different in some other language, but the HTML ought to be the same, since all you want on the page is the IP address....

Changed lines 37-39 from:

This script generates a tiny web page with the links to your site based on your gateway's IP when
passed your gateway's IP as a parameter:

to:

This script generates a tiny web page with the links to your site based on your gateway's IP when passed your gateway's IP as a parameter:

Changed lines 41-67 from:
#!/bin/ash
#
echo "<html>" > dyn-ip.html
echo " <head>" >> dyn-ip.html
echo " <title>Link to My uNSLUng NSLU2's Web Site</title>" >> dyn-ip.html
echo " </head>" >> dyn-ip.html
echo " <body bgcolor=#000033>" >> dyn-ip.html
echo " <table width=420 border=2 cellpadding=3 cellspacing=0 bgcolor=#F6F6F6>" >> dyn-ip.html
echo " <tr align=center>" >> dyn-ip.html
echo " <td>" >> dyn-ip.html
echo " <a href=http://$1>My uNSLUng NSLU2 Homepage</a>" >> dyn-ip.html
echo " </td>" >> dyn-ip.html
echo " </tr>" >> dyn-ip.html
echo " <tr align=center>" >> dyn-ip.html
echo " <td>" >> dyn-ip.html
echo " <p class='Quote'>This link may be bad from " >> dyn-ip.html
echo " time to time, but it is dynamically " >> dyn-ip.html
echo " updated on the 42nd minute of every hour, " >> dyn-ip.html
echo " so try back then if it doesn't work!</p>" >> dyn-ip.html
echo " </td>" >> dyn-ip.html
echo " </tr>" >> dyn-ip.html
echo " </table>" >> dyn-ip.html
echo " </body>" >> dyn-ip.html
echo "</html>" >> dyn-ip.html
#
chmod 644 dyn-ip.html
to:

(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

 #!/bin/sh
 if [ -n "$1" ]
 then
   url=$1
 else
   url=ERROR
 fi

 if [ -n "$2" ]
 then
   port=$2
 else
   port=80
 fi

 cat > dyn-ip.html << EOF
 <html>
  <head>
   <title>Link to My uNSLUng NSLU2's Web Site</title>
  </head>
  <body bgcolor="#000033">
   <table width="420" border="2" cellpadding="3" cellspacing="0" bgcolor="#F6F6F6">
    <tr align="center">
     <td>
      <a href="http://$url:$port/">My uNSLUng NSLU2 Homepage</a>
     </td>
    </tr>
    <tr align="center">
     <td>
      <p class="quote">
       This link may be bad from time to time, but it is dynamically 
       updated on the 42nd minute of every hour, so try back then if
       it doesn't work!
      </p>
     </td>
    </tr>
   </table>
  </body>
 </html>
 EOF

(:tableend:)

Changed lines 89-97 from:

1. It can also be used on the command line to create a small page with a link to any site you wish,
simply by passing it the site's address (minus the "http://" part, of course), and with a little
modification (taking out the table tags and changing the first output redirect to append), it could be
used to collect a list of links....

2. If you have your web server on a port different than 80, you can either add a second command line
parameter and pass the port number in or hardcode it in (placing it after $1 in the link, adding a
colon as necessary).

to:

1. It can also be used on the command line to create a small page with a link to any site you wish, simply by passing it the site's address (minus the "http://" part, of course), and with a little modification (taking out the table tags and changing the first output redirect to append), it could be used to collect a list of links....

2. If you have your web server on a port different than 80, add a second command line parameter and pass the port number in

Changed lines 97-99 from:

Use this script (in a cron job, perhaps) to check your IP on that page you set up in Step 1 and, only if
the IP address has changed, upload a web page created "on the fly" by the script in Step 2:

to:

Use this script (in a cron job, perhaps) to check your IP on that page you set up in Step 1 and, only if the IP address has changed, upload a web page created "on the fly" by the script in Step 2:

Changed lines 101-156 from:
#!/bin/ash
#
# get the current IP of the router
current_ip=`lynx -accept_all_cookies -dump http://www.somewhere-where-your-page-is.com/remote-ip.asp`
#
echo $current_ip > temp_ip
current_ip=`cat temp_ip`
#
# get the old IP of the router
old_ip=`cat router_ip`
#
Set_Led beep1
sleep 1
#
# compare to see if update is necessary
if [[ $current_ip != $old_ip ]]
then
# uncomment following line for user feedback or debugging
# echo "$current_ip different from $old_ip so running update script"
Set_Led beep1
sleep 1
Set_Led beep1
#
echo $current_ip > /router_ip
#
echo `date` : $current_ip >> /share/hdd/data/syslog/router_ip_history
#
# uncomment following line for user feedback or debugging
# echo "wrote current ip $current_ip to router_ip"
#
# uncomment following line for user feedback or debugging
# echo "generating dyn-ip.html"
generate-dyn_ip_html $current_ip
#
remote="www.somewhere-where-your-page-is.com"
localHtmlFile="/root/dyn-ip.html"
htmlFile="dyn-ip.shtm"
#
# uncomment following lines for user feedback or debugging
# echo "attempting to put $localHtmlFile to $remote/$htmlFile"
# echo "attempting to put $localHtmlFile to $remote/$targetdir/$htmlFile"
#
ftp $remote << END_SCRIPT
put $localHtmlFile $htmlFile
exit
END_SCRIPT
#
# uncomment following line for user feedback or debugging
# echo "completed ftp session"
#
else
# uncomment following line for user feedback or debugging
# echo "$current_ip same as $old_ip so exiting update script"
Set_Led beep1
fi
to:

(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

 #!/bin/sh

 # Change the following link to where you put the remote IP script from above.
 ip_page_url = http://www.somewhere-where-your-page-is.com/remote-ip.asp

 #
 # get the current IP of the router
 current_ip=`lynx -accept_all_cookies -dump $ip_page_url
 #
 echo $current_ip > temp_ip
 current_ip=`cat temp_ip`
 #
 # get the old IP of the router
 old_ip=`cat router_ip`
 #
 Set_Led beep1
 sleep 1
 #
 # compare to see if update is necessary
 if [[ $current_ip != $old_ip ]]
 then
 # uncomment following line for user feedback or debugging
 #    echo "$current_ip different from $old_ip so running update script"
    Set_Led beep1
    sleep 1
    Set_Led beep1
 #
    echo $current_ip > /router_ip
 #
    echo `date` : $current_ip >> /share/hdd/data/syslog/router_ip_history
 #
 # uncomment following line for user feedback or debugging
 #   echo "wrote current ip $current_ip to router_ip"
 #
 # uncomment following line for user feedback or debugging
 #   echo "generating dyn-ip.html"
    generate-dyn_ip_html $current_ip
 #
    remote="www.somewhere-where-your-page-is.com"
    localHtmlFile="/root/dyn-ip.html"
    htmlFile="dyn-ip.shtm"
 #
 # uncomment following lines for user feedback or debugging
 #   echo "attempting to put $localHtmlFile to $remote/$htmlFile"
 #   echo "attempting to put $localHtmlFile to $remote/$targetdir/$htmlFile"
 #
    ftp $remote << EOF
 put $localHtmlFile $htmlFile
 exit
 EOF
 #
 # uncomment following line for user feedback or debugging
 #   echo "completed ftp session"
 #
 else
 # uncomment following line for user feedback or debugging
 #   echo "$current_ip same as $old_ip so exiting update script"
    Set_Led beep1
 fi

(:tableend:)

Changed lines 166-171 from:

This script assumes that your files are in your /root directory. Modify the localHtmlFile value as
necessary if you put them somewhere else, but make sure you keep the scripts all in the same folder.
It also creates two files, "remote_ip" and "temp_ip" to hold the previous IP address and the IP address
you're comparing it to. If it finds that they are the same, it exits without FTPing the HTML file
to your web host.

to:

This script assumes that your files are in your /root directory. Modify the localHtmlFile value as necessary if you put them somewhere else, but make sure you keep the scripts all in the same folder. It also creates two files, "remote_ip" and "temp_ip" to hold the previous IP address and the IP address you're comparing it to. If it finds that they are the same, it exits without FTPing the HTML file to your web host.

Changed lines 173-180 from:

#!/bin/sh
IP=`wget -qO - http://whatsmyip.smokingmedia.com/ | grep "TITLE" | sed -e "s#^[^0-9]\+\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)[^0-9]\+...\$#\1#g"`
if [ "`cat /tmp/dyndns.ip`" != "$IP" ]
then
wget --no-check-certificate -q -O - https://login:password@members.dyndns.org/nic/update?system=dyndns&hostname=host.dyndns.org&myip=$IP" >> /tmp/dyndns.update.log 2> /dev/null
echo -n $IP > /tmp/dyndns.ip
fi

to:

(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

 #!/bin/sh

 user=your_dyndns_username
 pass=your_dyndns_password
 host=your_dyndns_hostname

 IP=`wget -qO - http://whatsmyip.smokingmedia.com/ | \
  grep "TITLE" | \
  sed -e "s#^[^0-9]\+\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)[^0-9]\+...\$#\1#g"`
 if [ "`cat /tmp/dyndns.ip`" != "$IP" ]
 then
  wget --no-check-certificate -q -O - \
  https://$user:$pass@members.dyndns.org/nic/update?system=dyndns&hostname=$host&myip=$IP" \
  >> /tmp/dyndns.update.log 2> /dev/null
  echo -n $IP > /tmp/dyndns.ip
 fi

(:tableend:)

Changed lines 200-201 from:

It should be possible by simply getting the IP from the router/firewall, and posting the IP to the
appropriate place to ensure that your domain is looking for you where you currently are....

to:

It should be possible by simply getting the IP from the router/firewall, and posting the IP to the appropriate place to ensure that your domain is looking for you where you currently are....

August 20, 2005, at 08:02 AM by Dutch --
Changed lines 1-2 from:

Here's what I did. Feel free to make improvements, especially in Step 1. If there's a way to get this info from a router directly instead of indirectly via a website as decribed, then I'm all ears! :^) I'm also interested in a way of directly scripting a Lynx session so that a domain name service could be updated automatically when the IP changes. This would allow a slug to host a site like "www.myslug.net" or something like that. It comes down to passing in the passwords when prompted.... Any "expect" experts out there? :^)

to:

Here's what I did. Feel free to make improvements, especially in Step 1.
If there's a way to get this info from a router directly instead of indirectly via a
website as decribed, then I'm all ears! :^) I'm also interested in a way of directly
scripting a Lynx session so that a domain name service could be updated automatically
when the IP changes. This would allow a slug to host a site like "www.myslug.net" or
something like that. It comes down to passing in the passwords when prompted....
Any "expect" experts out there? :^)

Changed lines 13-14 from:

Set up a page on a web hosting site that has some sort of active server side scripting technology, be it .ASP, .PHP, or whatever, that can read the server variable "REMOTE_ADDR" to get the IP address assigned to your gateway/router/cablemodem/56Kmodem. I used .ASP, since my web host works with that, and here it is:

to:

Set up a page on a web hosting site that has some sort of active server side scripting
technology, be it .ASP, .PHP, or whatever, that can read the server variable "REMOTE_ADDR"
to get the IP address assigned to your gateway/router/cablemodem/56Kmodem. I used .ASP,
since my web host works with that, and here it is:

Changed lines 37-38 from:

Your example's script portions will look different in some other language, but the HTML ought to be the same, since all you want on the page is the IP address....

to:

Your example's script portions will look different in some other language, but the HTML ought
to be the same, since all you want on the page is the IP address....

Changed lines 44-45 from:

This script generates a tiny web page with the links to your site based on your gateway's IP when passed your gateway's IP as a parameter:

to:

This script generates a tiny web page with the links to your site based on your gateway's IP when
passed your gateway's IP as a parameter:

Changed lines 80-83 from:

1. It can also be used on the command line to create a small page with a link to any site you wish, simply by passing it the site's address (minus the "http://" part, of course), and with a little modification (taking out the table tags and changing the first output redirect to append), it could be used to collect a list of links....

2. If you have your web server on a port different than 80, you can either add a second command line parameter and pass the port number in or hardcode it in (placing it after $1 in the link, adding a colon as necessary).

to:

1. It can also be used on the command line to create a small page with a link to any site you wish,
simply by passing it the site's address (minus the "http://" part, of course), and with a little
modification (taking out the table tags and changing the first output redirect to append), it could be
used to collect a list of links....

2. If you have your web server on a port different than 80, you can either add a second command line
parameter and pass the port number in or hardcode it in (placing it after $1 in the link, adding a
colon as necessary).

Changed lines 93-94 from:

Use this script (in a cron job, perhaps) to check your IP on that page you set up in Step 1 and, only if the IP address has changed, upload a web page created "on the fly" by the script in Step 2:

to:

Use this script (in a cron job, perhaps) to check your IP on that page you set up in Step 1 and, only if
the IP address has changed, upload a web page created "on the fly" by the script in Step 2:

Changed lines 156-157 from:

This script assumes that your files are in your /root directory. Modify the localHtmlFile value as necessary if you put them somewhere else, but make sure you keep the scripts all in the same folder. It also creates two files, "remote_ip" and "temp_ip" to hold the previous IP address and the IP address you're comparing it to. If it finds that they are the same, it exits without FTPing the HTML file to your web host.

to:

This script assumes that your files are in your /root directory. Modify the localHtmlFile value as
necessary if you put them somewhere else, but make sure you keep the scripts all in the same folder.
It also creates two files, "remote_ip" and "temp_ip" to hold the previous IP address and the IP address
you're comparing it to. If it finds that they are the same, it exits without FTPing the HTML file
to your web host.

Changed lines 181-182 from:

It should be possible by simply getting the IP from the router/firewall, and posting the IP to the appropriate place to ensure that your domain is looking for you where you currently are....

to:

It should be possible by simply getting the IP from the router/firewall, and posting the IP to the
appropriate place to ensure that your domain is looking for you where you currently are....

August 20, 2005, at 07:54 AM by Dutch --
Deleted lines 0-12:

Well, I just couldn't stand this, get yourself an account at dyndns.org and run this as a cronjob:
#!/bin/sh
IP=`wget -qO - http://whatsmyip.smokingmedia.com/ | grep "TITLE" | sed -e "s#^[^0-9]\+\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)[^0-9]\+...\$#\1#g"`
if [ "`cat /tmp/dyndns.ip`" != "$IP" ]
then
wget --no-check-certificate -q -O - https://login:password@members.dyndns.org/nic/update?system=dyndns&hostname=host.dyndns.org&myip=$IP" >> /tmp/dyndns.update.log 2> /dev/null
echo -n $IP > /tmp/dyndns.ip
fi


Added lines 143-160:

Well, I just couldn't stand this, get yourself an account at dyndns.org and run this as a cronjob:
#!/bin/sh
IP=`wget -qO - http://whatsmyip.smokingmedia.com/ | grep "TITLE" | sed -e "s#^[^0-9]\+\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)[^0-9]\+...\$#\1#g"`
if [ "`cat /tmp/dyndns.ip`" != "$IP" ]
then
wget --no-check-certificate -q -O - https://login:password@members.dyndns.org/nic/update?system=dyndns&hostname=host.dyndns.org&myip=$IP" >> /tmp/dyndns.update.log 2> /dev/null
echo -n $IP > /tmp/dyndns.ip
fi


Malfi--

That's good, but where's the fun in using a service? :^)

It should be possible by simply getting the IP from the router/firewall, and posting the IP to the appropriate place to ensure that your domain is looking for you where you currently are....

July 30, 2005, at 10:54 PM by Malfi -- added a hint to dyndns for this poor soul
Added lines 1-11:

Well, I just couldn't stand this, get yourself an account at dyndns.org and run this as a cronjob:
#!/bin/sh
IP=`wget -qO - http://whatsmyip.smokingmedia.com/ | grep "TITLE" | sed -e "s#^[^0-9]\+\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)[^0-9]\+...\$#\1#g"`
if [ "`cat /tmp/dyndns.ip`" != "$IP" ]
then
wget --no-check-certificate -q -O - https://login:password@members.dyndns.org/nic/update?system=dyndns&hostname=host.dyndns.org&myip=$IP" >> /tmp/dyndns.update.log 2> /dev/null
echo -n $IP > /tmp/dyndns.ip
fi

July 26, 2005, at 10:42 PM by Dutch --
Changed lines 100-101 from:
# echo "$current_ip different from $old_ip so running update script" # for debugging
to:
# uncomment following line for user feedback or debugging
# echo "$current_ip different from $old_ip so running update script"
Changed lines 110-111 from:
# echo "wrote current ip $current_ip to router_ip" # for debugging
to:
# uncomment following line for user feedback or debugging
# echo "wrote current ip $current_ip to router_ip"
Changed lines 113-114 from:
# echo "generating dyn-ip.html" # for debugging
to:
# uncomment following line for user feedback or debugging
# echo "generating dyn-ip.html"
Changed line 117 from:
remote="www.somewhere-where-your-page-is.com.com"
to:
remote="www.somewhere-where-your-page-is.com"
Changed lines 121-122 from:
# echo "attempting to put $localHtmlFile to $remote/$htmlFile" # for debugging
# echo "attempting to put $localHtmlFile to $remote/$targetdir/$htmlFile" # for debugging
to:
# uncomment following lines for user feedback or debugging
# echo "attempting to put $localHtmlFile to $remote/$htmlFile"
# echo "attempting to put $localHtmlFile to $remote/$targetdir/$htmlFile"
Changed lines 130-131 from:
# echo "completed ftp session" # for debugging
to:
# uncomment following line for user feedback or debugging
# echo "completed ftp session"
Changed lines 134-135 from:
# echo "$current_ip same as $old_ip so exiting update script" # for debugging
to:
# uncomment following line for user feedback or debugging
# echo "$current_ip same as $old_ip so exiting update script"
July 06, 2005, at 01:57 AM by Dutch --
Changed line 21 from:
address = Request.ServerVariables?("REMOTE_ADDR")
to:
address = Request.ServerVariables("REMOTE_ADDR")
Changed line 47 from:
echo " <table width=420 border=2 cellpadding=3 cellspacing=0 bgcolor=#F6F6F6?>" >> dyn-ip.html
to:
echo " <table width=420 border=2 cellpadding=3 cellspacing=0 bgcolor=#F6F6F6>" >> dyn-ip.html
Changed line 50 from:
echo " <a href=http://$1>My uNSLUng NSLU2 Homepage</a>" >> dyn-ip.html
to:
echo " <a href=http://$1>My uNSLUng NSLU2 Homepage</a>" >> dyn-ip.html
Changed lines 71-72 from:

1. It can also be used on the command line to create a small page with a link to any site you wish, simply by passing it the site's address (minus the "http://" part, of course), and with a little modification (taking out the table tags and changing the first output redirect to append), it could be used to collect a list of links....

to:

1. It can also be used on the command line to create a small page with a link to any site you wish, simply by passing it the site's address (minus the "http://" part, of course), and with a little modification (taking out the table tags and changing the first output redirect to append), it could be used to collect a list of links....

Changed line 86 from:
current_ip=`lynx -accept_all_cookies -dump http://www.somewhere-where-your-page-is.com/remote-ip.asp`
to:
current_ip=`lynx -accept_all_cookies -dump http://www.somewhere-where-your-page-is.com/remote-ip.asp`
Changed line 88 from:
echo $current_ip > temp_ip
to:
echo $current_ip > temp_ip
Changed line 98 from:
to:
if [[ $current_ip != $old_ip ]]
Changed line 107 from:
echo `date` : $current_ip >> /share/hdd/data/syslog/router_ip_history
to:
echo `date` : $current_ip >> /share/hdd/data/syslog/router_ip_history
Changed lines 135-136 from:

This script assumes that your files are in your /root directory. Modify the localHtmlFile value as necessary if you put them somewhere else, but make sure you keep the scripts all in the same folder. It also creates two files, "remote_ip" and "temp_ip" to hold the previous IP address and the IP address you're comparing it to. If it finds that they are the same, it exits without FTPing? the HTML file to your web host.

to:

This script assumes that your files are in your /root directory. Modify the localHtmlFile value as necessary if you put them somewhere else, but make sure you keep the scripts all in the same folder. It also creates two files, "remote_ip" and "temp_ip" to hold the previous IP address and the IP address you're comparing it to. If it finds that they are the same, it exits without FTPing the HTML file to your web host.

July 04, 2005, at 06:53 AM by Dutch --
Changed line 114 from:
remote="www.mywebsite.com"
to:
remote="www.somewhere-where-your-page-is.com.com"
July 04, 2005, at 06:52 AM by Dutch --
Deleted lines 0-3:

HowTo... SetUpYourOwnStaticLinkToYourSiteAtADynamicIP

Here's what I did. Feel free to make improvements, especially in Step 1. If there's a way to get this info from a router directly instead of indirectly via a website as decribed, then I'm all ears! :^) I'm also interested in a way of directly scripting a Lynx session so that a domain name service could be updated automatically when the IP changes. This would allow a slug to host a site like "www.myslug.net" or something like that. It comes down to passing in the passwords when prompted.... Any "expect" experts out there? :^)

Added lines 3-6:

Here's what I did. Feel free to make improvements, especially in Step 1. If there's a way to get this info from a router directly instead of indirectly via a website as decribed, then I'm all ears! :^) I'm also interested in a way of directly scripting a Lynx session so that a domain name service could be updated automatically when the IP changes. This would allow a slug to host a site like "www.myslug.net" or something like that. It comes down to passing in the passwords when prompted.... Any "expect" experts out there? :^)


July 04, 2005, at 06:47 AM by Dutch --
Changed line 86 from:
current_ip=`lynx -accept_all_cookies -dump http://www.nyquist-plot.com/remote-ip.asp`
to:
current_ip=`lynx -accept_all_cookies -dump http://www.somewhere-where-your-page-is.com/remote-ip.asp`
July 04, 2005, at 06:45 AM by Dutch --
Changed lines 1-4 from:
to:
July 04, 2005, at 06:45 AM by Dutch --
Added lines 1-140:

HowTo...

SetUpYourOwnStaticLinkToYourSiteAtADynamicIP

Here's what I did. Feel free to make improvements, especially in Step 1. If there's a way to get this info from a router directly instead of indirectly via a website as decribed, then I'm all ears! :^) I'm also interested in a way of directly scripting a Lynx session so that a domain name service could be updated automatically when the IP changes. This would allow a slug to host a site like "www.myslug.net" or something like that. It comes down to passing in the passwords when prompted.... Any "expect" experts out there? :^)


Step 1:

Set up a page on a web hosting site that has some sort of active server side scripting technology, be it .ASP, .PHP, or whatever, that can read the server variable "REMOTE_ADDR" to get the IP address assigned to your gateway/router/cablemodem/56Kmodem. I used .ASP, since my web host works with that, and here it is:


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>IP</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<%
dim address
'
address = Request.ServerVariables?("REMOTE_ADDR")
'
%>
</head>
<body><% response.write address %></body>
</html>

Your example's script portions will look different in some other language, but the HTML ought to be the same, since all you want on the page is the IP address....


Step 2:

This script generates a tiny web page with the links to your site based on your gateway's IP when passed your gateway's IP as a parameter:


#!/bin/ash
#
echo "<html>" > dyn-ip.html
echo " <head>" >> dyn-ip.html
echo " <title>Link to My uNSLUng NSLU2's Web Site</title>" >> dyn-ip.html
echo " </head>" >> dyn-ip.html
echo " <body bgcolor=#000033>" >> dyn-ip.html
echo " <table width=420 border=2 cellpadding=3 cellspacing=0 bgcolor=#F6F6F6?>" >> dyn-ip.html
echo " <tr align=center>" >> dyn-ip.html
echo " <td>" >> dyn-ip.html
echo " <a href=http://$1>My uNSLUng NSLU2 Homepage</a>" >> dyn-ip.html
echo " </td>" >> dyn-ip.html
echo " </tr>" >> dyn-ip.html
echo " <tr align=center>" >> dyn-ip.html
echo " <td>" >> dyn-ip.html
echo " <p class='Quote'>This link may be bad from " >> dyn-ip.html
echo " time to time, but it is dynamically " >> dyn-ip.html
echo " updated on the 42nd minute of every hour, " >> dyn-ip.html
echo " so try back then if it doesn't work!</p>" >> dyn-ip.html
echo " </td>" >> dyn-ip.html
echo " </tr>" >> dyn-ip.html
echo " </table>" >> dyn-ip.html
echo " </body>" >> dyn-ip.html
echo "</html>" >> dyn-ip.html
#
chmod 644 dyn-ip.html

Side notes about the above script:

1. It can also be used on the command line to create a small page with a link to any site you wish, simply by passing it the site's address (minus the "http://" part, of course), and with a little modification (taking out the table tags and changing the first output redirect to append), it could be used to collect a list of links....

2. If you have your web server on a port different than 80, you can either add a second command line parameter and pass the port number in or hardcode it in (placing it after $1 in the link, adding a colon as necessary).


Step 3:

Use this script (in a cron job, perhaps) to check your IP on that page you set up in Step 1 and, only if the IP address has changed, upload a web page created "on the fly" by the script in Step 2:


#!/bin/ash
#
# get the current IP of the router
current_ip=`lynx -accept_all_cookies -dump http://www.nyquist-plot.com/remote-ip.asp`
#
echo $current_ip > temp_ip
current_ip=`cat temp_ip`
#
# get the old IP of the router
old_ip=`cat router_ip`
#
Set_Led beep1
sleep 1
#
# compare to see if update is necessary
then
# echo "$current_ip different from $old_ip so running update script" # for debugging
Set_Led beep1
sleep 1
Set_Led beep1
#
echo $current_ip > /router_ip
#
echo `date` : $current_ip >> /share/hdd/data/syslog/router_ip_history
#
# echo "wrote current ip $current_ip to router_ip" # for debugging
#
# echo "generating dyn-ip.html" # for debugging
generate-dyn_ip_html $current_ip
#
remote="www.mywebsite.com"
localHtmlFile="/root/dyn-ip.html"
htmlFile="dyn-ip.shtm"
#
# echo "attempting to put $localHtmlFile to $remote/$htmlFile" # for debugging
# echo "attempting to put $localHtmlFile to $remote/$targetdir/$htmlFile" # for debugging
#
ftp $remote << END_SCRIPT
put $localHtmlFile $htmlFile
exit
END_SCRIPT
#
# echo "completed ftp session" # for debugging
#
else
# echo "$current_ip same as $old_ip so exiting update script" # for debugging
Set_Led beep1
fi

This script assumes that your files are in your /root directory. Modify the localHtmlFile value as necessary if you put them somewhere else, but make sure you keep the scripts all in the same folder. It also creates two files, "remote_ip" and "temp_ip" to hold the previous IP address and the IP address you're comparing it to. If it finds that they are the same, it exits without FTPing? the HTML file to your web host.

I hope this helps!

view · edit · print · history · Last edited by SRS.
Based on work by SRS, Thomas Reitmayr, balleyne, Dutch, Steve G, Daniel Deremiah, Stein, Psychodad, MattMcNeill, James Fu, tman, and Malfi.
Originally by Dutch.
Page last modified on October 14, 2008, at 06:42 AM