This discussion is locked
macsense

Q: Unix command in ARD to remove DNS Servers from Network prefs?

I need to know how to send a unix command to remove DNS Servers in Network preferences. I need the DNS Servers field to be blank. Can this be done?

Mac OS X (10.3.9)

Posted on Feb 23, 2006 2:57 PM

Close

Q: Unix command in ARD to remove DNS Servers from Network prefs?

  • All replies
  • Helpful answers

  • by Templeton Peck,

    Templeton Peck Templeton Peck Feb 23, 2006 3:19 PM in response to macsense
    Level 9 (62,070 points)
    Feb 23, 2006 3:19 PM in response to macsense
    networksetup -setdnsservers <networkservice> <dns1> [dns2] [...]

    Set the <networkservice> DNS servers to <dns1> [dns2] [...]. Any number of dns servers can be specified. Specify "Empty" for <dns1> to clear all DSN entries.

    So if you check the Ethernet connection you'd send the command: networksetup -getdnsservers Built-in\ Ethernet

    For more options, send the Unix command networksetup -help to the client computer.
  • by varjak paw,

    varjak paw varjak paw Feb 23, 2006 3:19 PM in response to macsense
    Level 10 (169,876 points)
    Feb 23, 2006 3:19 PM in response to macsense
    Send:

    networksetup -setdnsservers <networkservice> <dns1> [dns2] [...]

    as root. Specify "Empty" for <dns1> to clear all DNS entries.

    ---------

    To see more commands like this, go to Terminal and enter

    /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/netw orksetup -help

    /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/syst emsetup -help

    or from within the Remote Desktop Admin in the Send Unix Command window type:

    networksetup -help
    systemsetup -help
  • by macsense,

    macsense macsense Feb 23, 2006 4:06 PM in response to varjak paw
    Level 1 (9 points)
    Mac App Store
    Feb 23, 2006 4:06 PM in response to varjak paw
    Thanks for this help. I'm getting a syntax error when running it however. I think the problem is with the "Empty" command. Do you mean to replace <dns1> with <Empty> or <"> or something else. I tried the first two and they failed.
  • by varjak paw,

    varjak paw varjak paw Feb 24, 2006 8:23 AM in response to macsense
    Level 10 (169,876 points)
    Feb 24, 2006 8:23 AM in response to macsense
    Sorry I apparently wasn't clear, but I meant it exactly as I put it; in quotation marks, sans the brackets.

    So if you're using the built-in Ethernet port, the syntax would be (exactly as shown):

    networksetup -setdnsservers "Built-in Ethernet" "Empty"
  • by macsense,

    macsense macsense Feb 24, 2006 8:57 AM in response to varjak paw
    Level 1 (9 points)
    Mac App Store
    Feb 24, 2006 8:57 AM in response to varjak paw
    Thank you Dave. You have been very helpful. This solution works perfectly now. Where do I find out more information about what goes in these parameters? I also couldn't figure out what went into the <networkservice> parameter.

    Thanks!
  • by Templeton Peck,

    Templeton Peck Templeton Peck Feb 24, 2006 10:09 AM in response to macsense
    Level 9 (62,070 points)
    Feb 24, 2006 10:09 AM in response to macsense
    The <networkservice> parameter would be the interface that you're wanting to change, such as "Built-in Ethernet" or "Airport."
  • by varjak paw,

    varjak paw varjak paw Feb 24, 2006 10:25 AM in response to macsense
    Level 10 (169,876 points)
    Feb 24, 2006 10:25 AM in response to macsense
    And <dns1>, <dns2> etc are the IP addresses of your domain name servers, should you wish to specific any in the future.

    Regards.
  • by macsense,

    macsense macsense Mar 1, 2006 10:34 AM in response to varjak paw
    Level 1 (9 points)
    Mac App Store
    Mar 1, 2006 10:34 AM in response to varjak paw
    After the unix command to remove the DNS servers I wish to reboot the workstations. Here is what I'm using now.

    networksetup -setdnsservers "Built-in Ethernet" "Empty"
    sudo shutdown -r now

    This appears to do the trick and restart the workstation however in ARD the task keeps showing that it is still processing long after the machine has rebooted. Is there a trick to get the unix command to quit after restarting?

    Thanks again.
  • by varjak paw,

    varjak paw varjak paw Mar 1, 2006 11:34 AM in response to macsense
    Level 10 (169,876 points)
    Mar 1, 2006 11:34 AM in response to macsense
    It may be that the restart is happening before the ARD client has a chance to report that the command has succeeded. How long does the change take to clear if you don't immediately restart the system?
  • by macsense,

    macsense macsense Mar 1, 2006 2:11 PM in response to varjak paw
    Level 1 (9 points)
    Mac App Store
    Mar 1, 2006 2:11 PM in response to varjak paw
    That makes sense. I tried...

    networksetup -setdnsservers "Built-in Ethernet" "Empty"
    sleep 20
    sudo shutdown -r now

    which causes the system to pause 20 seconds before restarting and it still does it. Even running the sudo shutdown -r now by itself causes the problem. So even sending a restart command may not allow enough time for ARD to report back before the machine restarts. Hmmmm....
  • by Beth Ernst,

    Beth Ernst Beth Ernst Mar 23, 2006 6:30 AM in response to macsense
    Level 1 (49 points)
    Mar 23, 2006 6:30 AM in response to macsense
    Our network administrator is getting ready to change the IP address of our DNS server. This means I have over 30 Macs that will be needing changes to their DNS settings. Since each machine is setup with limited access to the system prefs, that means I have to go to each machine and log in as the admin user to make this change. In the interest of saving time, is this something I can do with Remote Desktop and how? Would I use the same commands in this post and replace dns1 with our DNS' new IP address? Will this distrupt the users access to the network when I do so?

    Thanks for any help.
    Beth
  • by varjak paw,

    varjak paw varjak paw Mar 23, 2006 8:24 AM in response to Beth Ernst
    Level 10 (169,876 points)
    Mar 23, 2006 8:24 AM in response to Beth Ernst
    Would I use the same commands in this post and replace dns1 with our DNS' new IP address?

    Correct.

    Will this distrupt the users access to the network when I do so?

    Probably not, but it would probably be a good idea to do this when people aren't using their computers just in case something does go wrong.
  • by Beth Ernst,

    Beth Ernst Beth Ernst Mar 24, 2006 12:20 PM in response to varjak paw
    Level 1 (49 points)
    Mar 24, 2006 12:20 PM in response to varjak paw
    Thanks Dave! Worked like a charm!
  • by varjak paw,

    varjak paw varjak paw Mar 24, 2006 12:40 PM in response to Beth Ernst
    Level 10 (169,876 points)
    Mar 24, 2006 12:40 PM in response to Beth Ernst
    Glad it helped, Beth. Cheers.