Created
          November 29, 2011 06:48 
        
      - 
      
 - 
        
Save dakatsuka/1403754 to your computer and use it in GitHub Desktop.  
    EC2でDDNS
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/sh | |
| DNS_KEY=/path/to/example.com.key | |
| DOMAIN=example.com | |
| USER_DATA=`/usr/bin/curl -s http://169.254.169.254/latest/user-data` | |
| HOSTNAME=`echo $USER_DATA` | |
| hostname $HOSTNAME.$DOMAIN | |
| LOCIP=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/local-ipv4` | |
| echo $DNS_KEY | |
| cat<<EOF | /usr/bin/nsupdate -k $DNS_KEY -v | |
| server dns1.$DOMAIN | |
| update delete $HOSTNAME.$DOMAIN A | |
| update add $HOSTNAME.$DOMAIN 60 A $LOCIP | |
| send | |
| EOF | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment