Linux/DNS
< Linux
Linux DNS
Host lookup:
host www.google.com host 4.2.2.2
Dig Host lookup:
dig www.google.com dig -x 4.2.2.2
Use DNS cachse
service nscd start
Clear DNS cache:
service nscd restart
Resolve an IP that may be in /etc/hosts or DNS: (part of MySQL Server package)
/usr/bin/resolveip -s [HOSTNAME]
nametoip or whatip: (Python script)
Bind DNS Server
See BIND
Dynamic DNS
nsupdate
server 10.50.10.74 update add send quite
References:
- HOWTO Manage Dynamic DNS with nsupdate - Consultancy.EdVoncken.NET - http://consultancy.edvoncken.net/index.php/HOWTO_Manage_Dynamic_DNS_with_nsupdate
FIO Solution
/tmp/nsupdate.txt
server 10.50.10.74 update delete fb-uefi-8.oeey.com A update add fb-uefi-8.oeey.com 86400 IN A 10.50.143.58 update delete fb-uefi-08.oeey.com A update add fb-uefi-08.oeey.com 86400 IN A 10.50.143.58 send update add 58.143.50.10.in-addr.arpa 86400 PTR fb-uefi-8.oeey.com send server 10.50.10.75 update delete fb-uefi-8.oeey.com A update add fb-uefi-8.oeey.com 86400 IN A 10.50.143.58 update delete fb-uefi-08.oeey.com A update add fb-uefi-08.oeey.com 86400 IN A 10.50.143.58 send update add 58.143.50.10.in-addr.arpa 86400 PTR fb-uefi-8.oeey.com send quit
Delete ptr:
# nsupdate server 10.50.10.74 update delete 84.44.50.10.in-addr.arpa 86400 PTR esx1-bench.oeey.com. send server 10.50.10.75 update delete 84.44.50.10.in-addr.arpa 86400 PTR esx1-bench.oeey.com. send quit
cron:
30 2 * * * /usr/local/bin/DDNSupdate.sh
/usr/local/bin/DDNSupdate.sh:
#!/bin/bash DOMAIN=int.oeey.com NAMESERVERS="10.50.10.74 10.50.10.75" if [[ $1 == "" || $2 == "" ]]; then echo "Usage: $0 <ip> <hostname1> [name2] [name3] [name4]" exit 1 fi #let's break down the IP so we can make a reverse lookup record oct1=$(echo $1 | cut -d\. -f1) oct2=$(echo $1 | cut -d\. -f2) oct3=$(echo $1 | cut -d\. -f3) oct4=$(echo $1 | cut -d\. -f4) reverseEntry=$(echo "$oct4.$oct3.$oct2.$oct1.in-addr.arpa") > nsupdate.txt for NAMESERVER in $NAMESERVERS ; do echo "server $NAMESERVER" >> nsupdate.txt echo "update delete $2.$DOMAIN A" >> nsupdate.txt echo "update add $2.$DOMAIN 86400 IN A $1" >> nsupdate.txt if [ $3 ]; then echo "update delete $3.$DOMAIN A" >> nsupdate.txt echo "update add $3.$DOMAIN 86400 IN A $1" >> nsupdate.txt fi if [ $4 ]; then echo "update delete $4.$DOMAIN A" >> nsupdate.txt echo "update add $4.$DOMAIN 86400 IN A $1" >> nsupdate.txt fi if [ $5 ]; then echo "update delete $5.$DOMAIN A" >> nsupdate.txt echo "update add $5.$DOMAIN 86400 IN A $1" >> nsupdate.txt fi echo "send" >> nsupdate.txt echo "update add $reverseEntry 86400 PTR $2.$DOMAIN" >> nsupdate.txt echo "send" >> nsupdate.txt done echo "quit" >> nsupdate.txt #cat nsupdate.txt echo "Updating $1 with $2.$DOMAIN $3 $4 $5" nsupdate nsupdate.txt rm -f nsupdate.txt
/usr/local/bin/updateNS.sh (OLD)
#!/bin/bash if [[ $1 != "" && $2 != "" ]]; then #let's break down the IP so we can make a reverse lookup record oct1=$(echo $1 | cut -d\. -f1) oct2=$(echo $1 | cut -d\. -f2) oct3=$(echo $1 | cut -d\. -f3) oct4=$(echo $1 | cut -d\. -f4) reverseEntry=$(echo "$oct4.$oct3.$oct2.$oct1.in-addr.arpa") echo "server 10.50.10.74" > /tmp/nsupdate.txt echo "update delete $2.oeey.com A" >> /tmp/nsupdate.txt echo "update add $2.oeey.com 86400 IN A $1" >> /tmp/nsupdate.txt if [ $3 ]; then echo "update delete $3.oeey.com A" >> /tmp/nsupdate.txt echo "update add $3.oeey.com 86400 IN A $1" >> /tmp/nsupdate.txt fi if [ $4 ]; then echo "update delete $4.oeey.com A" >> /tmp/nsupdate.txt echo "update add $4.oeey.com 86400 IN A $1" >> /tmp/nsupdate.txt fi if [ $5 ]; then echo "update delete $5.oeey.com A" >> /tmp/nsupdate.txt echo "update add $5.oeey.com 86400 IN A $1" >> /tmp/nsupdate.txt fi echo "send" >> /tmp/nsupdate.txt echo "update add $reverseEntry 86400 PTR $2.oeey.com" >> /tmp/nsupdate.txt echo "send" >> /tmp/nsupdate.txt echo "server 10.50.10.75" >> /tmp/nsupdate.txt echo "update delete $2.oeey.com A" >> /tmp/nsupdate.txt echo "update add $2.oeey.com 86400 IN A $1" >> /tmp/nsupdate.txt if [ $3 ]; then echo "update delete $3.oeey.com A" >> /tmp/nsupdate.txt echo "update add $3.oeey.com 86400 IN A $1" >> /tmp/nsupdate.txt fi if [ $4 ]; then echo "update delete $4.oeey.com A" >> /tmp/nsupdate.txt echo "update add $4.oeey.com 86400 IN A $1" >> /tmp/nsupdate.txt fi if [ $5 ]; then echo "update delete $5.oeey.com A" >> /tmp/nsupdate.txt echo "update add $5.oeey.com 86400 IN A $1" >> /tmp/nsupdate.txt fi echo "send" >> /tmp/nsupdate.txt echo "update add $reverseEntry 86400 PTR $2.oeey.com" >> /tmp/nsupdate.txt echo "send" >> /tmp/nsupdate.txt echo "quit" >> /tmp/nsupdate.txt #cat /tmp/nsupdate.txt nsupdate /tmp/nsupdate.txt fi
/usr/local/bin/removeNS.sh:
#!/bin/bash if [[ $1 != "" && $2 != "" ]]; then #let's break down the IP so we can make a reverse lookup record oct1=$(echo $1 | cut -d\. -f1) oct2=$(echo $1 | cut -d\. -f2) oct3=$(echo $1 | cut -d\. -f3) oct4=$(echo $1 | cut -d\. -f4) reverseEntry=$(echo "$oct4.$oct3.$oct2.$oct1.in-addr.arpa") echo "server 10.50.10.74" > /tmp/nsupdate.txt echo "update delete $2.oeey.com A" >> /tmp/nsupdate.txt if [ $3 ]; then echo "update delete $3.oeey.com A" >> /tmp/nsupdate.txt fi if [ $4 ]; then echo "update delete $4.oeey.com A" >> /tmp/nsupdate.txt fi if [ $5 ]; then echo "update delete $5.oeey.com A" >> /tmp/nsupdate.txt fi echo "send" >> /tmp/nsupdate.txt #echo "update delete $reverseEntry PTR" >> /tmp/nsupdate.txt echo "update delete $reverseEntry PTR $2.oeey.com" >> /tmp/nsupdate.txt echo "send" >> /tmp/nsupdate.txt echo "server 10.50.10.75" >> /tmp/nsupdate.txt echo "update delete $2.oeey.com A" >> /tmp/nsupdate.txt if [ $3 ]; then echo "update delete $3.oeey.com A" >> /tmp/nsupdate.txt fi if [ $4 ]; then echo "update delete $4.oeey.com A" >> /tmp/nsupdate.txt fi if [ $5 ]; then echo "update delete $5.oeey.com A" >> /tmp/nsupdate.txt fi echo "send" >> /tmp/nsupdate.txt #echo "update delete $reverseEntry PTR" >> /tmp/nsupdate.txt echo "update delete $reverseEntry PTR $2.oeey.com" >> /tmp/nsupdate.txt echo "send" >> /tmp/nsupdate.txt echo "quit" >> /tmp/nsupdate.txt #cat /tmp/nsupdate.txt nsupdate /tmp/nsupdate.txt fi
TO READ
Linux DNS:
- http://www.aboutdebian.com/dns.htm
- http://linuxreviews.org/howtos/djbdns_guide/
- http://www.networkcomputing.com/unixworld/tutorial/013/013.part1.html
- http://www.yolinux.com/TUTORIALS/LinuxTutorialWebSiteConfig.html
- http://www.troubleshooters.com/linux/dns.htm
- http://www.faqs.org/docs/securing/chap21sec162.html
- http://www.howtoforge.com/installing_a_lamp_system_with_fedora_core_6_p4
- http://www.howtoforge.com/linux_bind9_and_caching_nameserver?s=d68cf70813735ba6a11dc8676fce989b&
- http://wiki.apache.org/spamassassin/CachingNameserver
- http://www.stevesearle.com/tech/centos5.0.svr.html
- http://sipx-wiki.calivia.com/index.php/HowTo_Configure_DHCP_and_DNS_Servers