Monday, May 23, 2011

Configuring DNS Servers on OS X via SSH

Need to set up/change the DNS servers on a Mac OS X system, using SSH.  Command to use is networksetup.  For instance:

$ networksetup /?

for all it's gory details.

What concerns me today is just DNS config for the system.  So, without further adiou, commands are in bold:

user:~ localhost$ networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
Ethernet 1
Ethernet 2
*Built-in Serial Port (1)
FireWire
user:~ localhost$ networksetup -getdnsservers Ethernet\ 1  (observe your character escape sequences)
192.168.1.10
192.168.1.9
user:~ localhost$ networksetup -getdnsservers Ethernet\ 2
192.168.1.10
192.168.1.9
user:~ localhost$ sudo networksetup -setdnsservers Ethernet\ 1 10.75.66.2
Password:
user:~ localhost$ networksetup -getdnsservers Ethernet\ 1
10.75.66.2
user:~ localhost$ sudo networksetup -setdnsservers Ethernet\ 2 10.75.66.2
user:~ localhost$ networksetup -getdnsservers Ethernet\ 2
10.75.66.2
user:~ localhost$

No comments:

Post a Comment