Skip to content

Instantly share code, notes, and snippets.

@shaon
Last active December 17, 2015 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaon/539ef62af8238327196b to your computer and use it in GitHub Desktop.
Save shaon/539ef62af8238327196b to your computer and use it in GitHub Desktop.
#!/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