Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Configure DNS lookups from the terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Configure DNS lookups from the terminal
Authored by: emzy on Sep 15, '05 12:41:55PM

Here my little Shell Script to Set the DNS.
See the Power of the Shell:

Filename: setdsn
-------------------------------------------------
#!/bin/bash

# Script is used to set the Nameserver Lookup under Max OS X 10.4 with the Console
# Script by Stephan Oeste <stephan@oeste.de>

if [ $# -lt 2 ] ; then
echo "Use: $0 <domain> <1.Nameserver> [2.Nameserver]"
echo "Example Use: $0 example.tld 1.2.3.4 1.2.3.5"
exit 1
fi

PSID=$( (scutil | grep PrimaryService | sed -e 's/.*PrimaryService : //')<< EOF
open
get State:/Network/Global/IPv4
d.show
quit
EOF
)

scutil << EOF
open
d.init
d.add ServerAddresses * $2 $3
d.add DomainName $1
set State:/Network/Service/$PSID/DNS
quit
EOF
-------------------------------------------------

Create the file
chmod +x setdns

And then use ist with (Example): setdns domain.com 12.23.34.45

CU Emzy



[ Reply to This | # ]
Configure DNS lookups from the terminal
Authored by: DylanMuir on Sep 20, '05 07:01:29PM

Cool, Emzy.

You may be interested, I contributed some scripts to openvpn.org for automatically dsitributing the nameserver configuration over the openvpn tunnel. You won't have to set the resolver configuration manually in that case. But your script should be great for fixing a stuffed config...

D.



[ Reply to This | # ]