Skip to main content
Question

need to modify the setDNSServers script in the resource kit to allow two servers.

  • April 26, 2011
  • 7 replies
  • 37 views

Eyoung
Forum|alt.badge.img+10

Is there a way to set multiple entries in this script? I need to hardcode 2 DNS servers. If I comma separate the 2 addresses in the values field it errors out as a bad IP.

# HARDCODED VALUES ARE SET HERE
networkInterface="Ethernet"
dnsServer="206.119.7.227, 204.180.94.186"

any thoughts?

...........................................................
There are grammatical errors even in his silence. - Stanislaw J. Lec

Eric Young
eyoung1 at mac.com

7 replies

Forum|alt.badge.img+5
  • Contributor
  • April 26, 2011

I'm not using the script from the resource kit, but I have used:

networksetup -setdnsservers "$service" 206.119.7.227 204.180.94.186

$service is your interface, or currently active interface. Maybe you just
don't need the comma? Not sure what that script is doing with the
variable...

Jon


Eyoung
Forum|alt.badge.img+10
  • Author
  • Contributor
  • April 26, 2011

that was my first thought too. it does not parse the second set of quotes right.

Script Result: /private/tmp/Ethernetdnsset.sh: line 87: 204.180.94.186: command not found
Error: No DNS server has been specified.

~~~~~~~~~~
A cynic is a man who, when he smells flowers, looks around for a coffin. --H. L. Mencken

Eric Young
eyoung at thayer.org


Eyoung
Forum|alt.badge.img+10
  • Author
  • Contributor
  • April 26, 2011

errors as with a comma.

_-------------------_____---------------_----------__
Puritanism: The haunting fear that someone, somewhere, may be happy. - HL Mencken

Eric Young
eyoung at thayer.org


leslie_h
Forum|alt.badge.img+14
  • Employee
  • April 26, 2011

Similar to Jon, the following works for me:

#/bin/bash

servers="206.119.7.227 204.180.94.186";networksetup -setdnsservers "Ethernet" $servers

What OS version are you testing on?

Leslie N. Helou
Senior Systems Engineer
Bell Techlogix
8888 Keystone Crossing, Suite 1700
Indianapolis, IN 46240
317.704.6408


Forum|alt.badge.img+12
  • Contributor
  • April 26, 2011

Don't know if this is of any use, but we supply our dns servers as part of our dhcp along with search domains, so no local configuration required.

Sean


Eyoung
Forum|alt.badge.img+10
  • Author
  • Contributor
  • April 26, 2011

every script can be replaced by another script.... only smaller.

works perfectly, thanks.


Eyoung
Forum|alt.badge.img+10
  • Author
  • Contributor
  • April 26, 2011

as do we... but there is a ghost in the machine for some of our subnets that makes letting the client pull the info unreliable at best. The network admin does not believe in ghosts... so I get to hard code them :-)

-----------------------------------------------------------
Seven Dirty Habits of Highly Effluent People 1. Never follow your passion, but by all means bring it with you.
2. Beware of teamwork.
3. Vomit proudly and whenever necessary.
4. Be careful, but don't be fooled--safety is never first.
5. Think about what you are doing--never how.
6. Ignore advice such as "Work smart, not hard." It's dangerous--and moronic.
7. Consider quitting. --Mike Rowe

Eric Young
eyoung1 at mac.com