Montag, 16. Juli 2012

[Scripting] IP and reverse

I currently writing a script that does the initial server setup. As we using kerberos it is needed to have the IP and the PTR record setup. So i first did a big ugly host | cut -d something -f 4 which was could easily run into trouble if theres a change in the domain. So i searched for an more easier way, and found dig.

dig x +short ${NAME}.${DOMAIN}

simply returns the IP

jstephan@linux-cyqa:~> dig x +short

and if you want the PTR its easy too

dig -x ${IPADDRESS} +short

which will return

jstephan@linux-cyqa:~> dig -x +short

After that i do an simple if in my bash script

if [ '$REVIP' == '${NAME}.${DOMAIN}' ]; then