Skip to content

Instantly share code, notes, and snippets.

@shaon

shaon/dnsupdate.sh

Last active Dec 17, 2015
Embed
What would you like to do?
#!/bin/bash
echo "zone euca.example.net" > /tmp/dnsupdate
echo "server 10.17.198.5" >> /tmp/dnsupdate
echo "update delete `hostname`" >> /tmp/dnsupdate
echo "update add `hostname` 86400 A `hostname -I`" >> /tmp/dnsupdate
echo "debug yes" >> /tmp/dnsupdate
echo "send" >> /tmp/dnsupdate
/usr/bin/nsupdate -v /tmp/dnsupdate
sed -i 's/DNS1=\"10.100.100.254\"/#DNS2=\"10.100.100.254\"'/ /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i '/#DNS2=\"10.100.100.254\"/a DNS1=\"10.17.198.5\"' /etc/sysconfig/network-scripts/ifcfg-eth0
service network restart
#!/bin/bash
echo "zone 17.10.in-addr.arpa" > /tmp/dnsupdate
echo "server 10.17.198.5" >> /tmp/dnsupdate
REVADDR=$(echo `hostname -I` | cut -f1 -d " " | awk -F. '{print $4"."$3"."$2"."$1}')
ARPAADDR="$REVADDR.in-addr.arpa"
echo "update delete $ARPAADDR" >> /tmp/dnsupdate
echo "update add $ARPAADDR 86400 IN PTR `hostname -f`." >> /tmp/dnsupdate
echo "send" >> /tmp/dnsupdate
/usr/bin/nsupdate -v /tmp/dnsupdate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment