logging { channel bind_log { file "/var/log/named/named.log"; print-time yes; print-category yes; print-severity yes; }; channel update_debug { file "/var/log/named/update-debug.log"; severity debug 3; print-time yes; print-category yes; print-severity yes; }; channel security_info { file "/var/log/named/security-info.log"; severity info; print-time yes; print-category yes; print-severity yes; }; category default { bind_log;}; category xfer-in { bind_log;}; category xfer-out { bind_log;}; category update { update_debug;}; category security { security_info;}; };
/etc/init.d/bind9 restart
dnssec-keygen -a HMAC-MD5 -b 512 -r /dev/urandom -n USER example.com
Kexample.com.+157+10000.key Kexample.com.+157+10000.private
#!/bin/bash # DNS_KEY="/etc/bind/key/Kexample.com.+157+10000.private" # DOMAIN=example.com # HOSTNAME=site1 # 2 , ( DNS) #USER_DATA=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/local-hostname` #HOSTNAME=`echo $USER_DATA` # hostname $HOSTNAME.$DOMAIN echo : $HOSTNAME.$DOMAIN PUBIP=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/public-ipv4` echo : $PUBIP cat<<EOF | /usr/bin/nsupdate -k $DNS_KEY -v server ns1.$DOMAIN zone $DOMAIN update delete $HOSTNAME.$DOMAIN A update add $HOSTNAME.$DOMAIN 60 A $PUBIP send EOF LOCIP=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/local-ipv4` echo : $LOCIP cat<<EOF | /usr/bin/nsupdate -k $DNS_KEY -v server ns1.$DOMAIN zone $DOMAIN update delete local.$HOSTNAME.$DOMAIN A update add local.$HOSTNAME.$DOMAIN 60 A $LOCIP send EOF
key example.com. { algorithm HMAC-MD5; secret "ynl7o+JFPekH4iUaptw7z12xLhkUBJTmqbmTYa1xe+Gpt26HVaff+qQW hlmWcvAUeYdg19B+M4YeFrfhAvlcLQ=="; }; zone "example.com" { type master; file "/etc/bind/master/example.com"; allow-update { key example.com.; }; allow-query { any; }; };
example.com. IN KEY 0 3 157 ynl7o+JFPekH4iUaptw7z12xLhkUBJTmqbmTYa1xe+Gpt26HVaff+qQW hlmWcvAUeYdg19B+M4YeFrfhAvlcLQ==
26-Jan-2013 22:53:27.780 update-security: info: client 192.168.254.1#58180: signer "example.com" approved 26-Jan-2013 22:53:27.782 general: error: /etc/bind/master/example.com.jnl: create: permission denied 26-Jan-2013 22:53:27.881 update-security: info: client 192.168.254.1#52062: signer "example.com" approved 26-Jan-2013 22:53:27.883 general: error: /etc/bind/master/example.com.jnl: create: permission denied
26-Jan-2013 22:53:27.780 update: info: client 192.168.254.1#58180: updating zone 'example.com/IN': deleting rrset at 'flussonic.example.com' A 26-Jan-2013 22:53:27.781 update: info: client 192.168.254.1#58180: updating zone 'example.com/IN': adding an RR at 'flussonic.example.com' A 26-Jan-2013 22:53:27.781 update: debug 3: client 192.168.254.1#58180: updating zone 'example.com/IN': checking for NSEC3PARAM changes 26-Jan-2013 22:53:27.782 update: info: client 192.168.254.1#58180: updating zone 'example.com/IN': error: journal open failed: unexpected error 26-Jan-2013 22:53:27.882 update: info: client 192.168.254.1#52062: updating zone 'example.com/IN': deleting rrset at 'local.flussonic.example.com' A 26-Jan-2013 22:53:27.882 update: info: client 192.168.254.1#52062: updating zone 'example.com/IN': adding an RR at 'local.flussonic.example.com' A 26-Jan-2013 22:53:27.882 update: debug 3: client 192.168.254.1#52062: updating zone 'example.com/IN': checking for NSEC3PARAM changes 26-Jan-2013 22:53:27.883 update: info: client 192.168.254.1#52062: updating zone 'example.com/IN': error: journal open failed: unexpected error
/etc/bind/** r,
/etc/bind/** rw,
/etc/init.d/apparmor restart /etc/init.d/bind9 restart
chmod +x ec2-hostname.sh cp ec2-hostname.sh /etc/init.d/ update-rc.d ec2-hostname.sh defaults
@echo off Setlocal enabledelayedexpansion rem set DNS_KEY="Kexample.com.+157+10000.private" rem set DOMAIN=example.com rem set HOSTNAME=site1 echo : %HOSTNAME%.%DOMAIN% for /F "Delims=" %%P In ('curl -s http://169.254.169.254/latest/meta-data/public-ipv4') Do Set PUBIP=%%~P echo : %PUBIP% ( @echo server ns1.%DOMAIN% @echo zone %DOMAIN% @echo update delete %HOSTNAME%.%DOMAIN% A @echo update add %HOSTNAME%.%DOMAIN% 60 A %PUBIP% @echo send ) | nsupdate -k %DNS_KEY% -v for /F "Delims=" %%L In ('curl -s http://169.254.169.254/latest/meta-data/local-ipv4') Do Set LOCIP=%%~L echo : %LOCIP% ( @echo server ns1.%DOMAIN% @echo zone %DOMAIN% @echo update delete local.%HOSTNAME%.%DOMAIN% A @echo update add local.%HOSTNAME%.%DOMAIN% 60 A %LOCIP% @echo send ) | nsupdate -k %DNS_KEY% -v :eof
libisc.dll liblwres.dll libisccfg.dll libbind9.dll libeay32.dll libdns.dll libxml2.dll nsupdate.exe
Source: https://habr.com/ru/post/167349/
All Articles