User Tools

Site Tools


wan_ip_retrieval_and_dynamic_dns_mdns

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
wan_ip_retrieval_and_dynamic_dns_mdns [2021/03/22 06:51] – created hc9wan_ip_retrieval_and_dynamic_dns_mdns [2021/03/22 06:58] (current) hc9
Line 3: Line 3:
 There are myriad ways to automatically keep your **mdns** updated on SDF. Below are a couple: There are myriad ways to automatically keep your **mdns** updated on SDF. Below are a couple:
  
-The first script depends on passwordless SSH logons. Also, make sure the file permissions for your scripts are executable. For more info, see the SDF tutorial on [[http://sdf.org/index.cgi?tutorials/permissions|File Permissions]].+The first script depends on passwordless SSH logons. Also, make sure the file permissions for your scripts are executable. For more info, see the SDF tutorial on [[permissions|File Permissions]].
  
 === Script 1 === === Script 1 ===
Line 10: Line 10:
  
 <code> <code>
-  echo $SSH_CLIENT+echo $SSH_CLIENT
 </code> </code>
  
 <code> <code>
-  echo $SSH_CONNECTION+echo $SSH_CONNECTION
 </code> </code>
      
Line 22: Line 22:
  
 <code> <code>
-  #!/bin/sh +#!/bin/sh 
-  IP=$(echo $SSH_CLIENT | awk '{print $1}'+IP=$(echo $SSH_CLIENT | awk '{print $1}'
-  OLDIP=$(cat ~/bin/.ip) +OLDIP=$(cat ~/bin/.ip) 
-  if [ "$IP" != "$OLDIP" ] ; +if [ "$IP" != "$OLDIP" ] ; 
-  then +then 
-          echo "$IP" > ~/bin/.ip +        echo "$IP" > ~/bin/.ip 
-          mdns "$IP" +        mdns "$IP" 
-  fi+fi
 </code> </code>
  
Line 37: Line 37:
  
 <code> <code>
-  #!/bin/ksh +#!/bin/ksh 
-  ssh me@remote.host '~/bin/ip' >/dev/null+ssh me@remote.host '~/bin/ip' >/dev/null
 </code> </code>
  
Line 44: Line 44:
  
 <code> <code>
-  #!/bin/ksh +#!/bin/ksh 
-  ssh me@remote.host '~/bin/ip' >>$HOME/logs/ip_update+ssh me@remote.host '~/bin/ip' >>$HOME/logs/ip_update
 </code> </code>
  
Line 51: Line 51:
  
 <code> <code>
-  * */24 * * * $HOME/bin/ipset+* */24 * * * $HOME/bin/ipset
 </code> </code>
  
Line 59: Line 59:
  
 <code> <code>
-  IP=$(ssh me@remote.host 'echo $SSH_CLIENT' | awk '{print $1}'+IP=$(ssh me@remote.host 'echo $SSH_CLIENT' | awk '{print $1}'
-  echo $IP+echo $IP
 </code> </code>
  
Line 84: Line 84:
  
 <code> <code>
-  #!/bin/sh +#!/bin/sh 
-  # GPL 2007,2009 Yargo C Bonetti +# GPL 2007,2009 Yargo C Bonetti 
-  # Use however you like, at your own risk! +# Use however you like, at your own risk! 
-  OLDIP=./.oldip +OLDIP=./.oldip 
-  DNSCOM=mdns +DNSCOM=mdns 
-  LOGF=./.setmdns.log +LOGF=./.setmdns.log 
-  KEYWORD=setmdns +KEYWORD=setmdns 
-  LOGNAME=${LOGNAME:-${HTTP_HOST%%.*}} +LOGNAME=${LOGNAME:-${HTTP_HOST%%.*}} 
-  HOME=`finger $LOGNAME|awk '/^Directory:/{print $2}'+HOME=`finger $LOGNAME|awk '/^Directory:/{print $2}'
-  export LOGNAME HOME +export LOGNAME HOME 
-  echo "`date -u +%c`     $REMOTE_ADDR    $QUERY_STRING" >>$LOGF +echo "`date -u +%c`     $REMOTE_ADDR    $QUERY_STRING" >>$LOGF 
-  chmod 600 $LOGF +chmod 600 $LOGF 
-  cat <&1 >/dev/null ; then +cat <&1 >/dev/null ; then 
-   if [ -d "$HOME" ] ; then + if [ -d "$HOME" ] ; then 
-    if [ "$REMOTE_ADDR" = "`cat $OLDIP`" ] ; then +  if [ "$REMOTE_ADDR" = "`cat $OLDIP`" ] ; then 
-     echo "Keeping ip at $REMOTE_ADDR" +   echo "Keeping ip at $REMOTE_ADDR"
-    else +
-     $DNSCOM $REMOTE_ADDR +
-     echo $REMOTE_ADDR >$OLDIP +
-    fi +
-   else echo "no $DNSCOM due to bad HOME=$HOME" +
-   fi+
   else   else
-   echo $QUERY_STRING+   $DNSCOM $REMOTE_ADDR 
 +   echo $REMOTE_ADDR >$OLDIP
   fi   fi
 + else echo "no $DNSCOM due to bad HOME=$HOME"
 + fi
 +else
 + echo $QUERY_STRING
 +fi
 </code> </code>
  
 $Id: mdns-tutorial.html,v 1.19 2019/09/29 15:35:43 amrowsell Exp $ [[http://sdf.org/?tutorials/mdns-tutorial|WAN IP Retrieval and Dynamic DNS (mdns)]] - traditional link (using [[wp>Revision_Control_System|RCS]]) $Id: mdns-tutorial.html,v 1.19 2019/09/29 15:35:43 amrowsell Exp $ [[http://sdf.org/?tutorials/mdns-tutorial|WAN IP Retrieval and Dynamic DNS (mdns)]] - traditional link (using [[wp>Revision_Control_System|RCS]])
  
wan_ip_retrieval_and_dynamic_dns_mdns.1616395874.txt.gz · Last modified: 2021/03/22 06:51 by hc9