Configure DNS & Search Domains in TCP/IP Settings via Terminal?

I've been having a long standing battle trying to find out what is wrong with my machine, it's been running like a dog for a while and having recently added 2 new Macs to our network i recall that there was a setting missing - namely within the TCP/IP settings for the Built In Ethernet, the DNS Servers and Search Domains are not configured on my machine, but are on the new ones i've added (mine was my new foray into Macs so i maybe set it up wrong!)

However the main problem occurs when i try to edit the settings for the above from within System Preferences -> Network, i get a spinning beach ball of doom and have to Force Quit. Yet oddly i can access the setting fine when i am at home and not connected to the AD of the Windows Server Environment... which makes me think the events could be linked.... i thought it may have been Parallels and it's NAT settings, but given that all works perfectly at home i'm not so sure. Hence, as a process of elimination i'd like to try and get the correct settings for Search Domain etc to see if it helps, before i flatten the machine and reinstall Tiger completely!

However the main problem occurs when i try to editthe settings for the above from within SystemPreferences -> Network, i get a spinning beach ballof doom and have to Force Quit.

Yes, you can change your DNS settings manually. The place to start is by modifying the file /etc/resolv.conf. When you put in a DNS server with System Preferences, this is the file that gets modified. The first line should be "domain local". Any search domains and the rest should be "nameserver IP.ad.re.ss".

You can avoid the whole lookup thing by putting entries in /etc/hosts. But DNS was designed as a way to avoid copying /etc/hosts all over the net. And I could be wrong, anyway. You need to check your lookupd configuration. Enter "lookupd -configuration" and look for the host configuration. It will list the order in which things are checked. By default, the Flat File (FF) agent is checked before DNS, but that can be changed. Of course, the cache should always be checked first.

I'm going to look at your other post now. Sounds like you've been having a lot of trouble.

I read your other post - wow, what a mess! It sounds to me like a problem with launchd and AD. One of the criticisms of launchd is that it does too much. In the days of init and rc startup was divided into groups of tasks. Now launchd handles everything but only on demand. It sounds like a circular dependency - like A depends upon B, B depends upon C, but C depends upon A.

While this approach will work, the OS rewrites /etc/resolv.conf each time the network changes (e.g. you reboot, change network locations, etc.), so any changes you make there are only temporary. It might be enough to overcome your problem, but it's not the best way.

The recommend way is via the command line utility networksetup which provides access to all network preferences. The specific command you want will be something like:

Where 'Built-in Ethernet' is the name of the interface settings (as per System Preferences -> Network), and '1.2.3.4 9.88.77.66' represents the IP addresses of two DNS servers to use (adjust as appropriate).

While this approach will work, the OS rewrites/etc/resolv.conf each time the network changes (e.g.you reboot, change network locations, etc.), so anychanges you make there are only temporary. It mightbe enough to overcome your problem, but it's not thebest way.

Mine seems to be persistent. I did notice it's a symlink to /var/run/resolv.conf, but the contents remain the same after rebooting.

The recommend way is via the command line utilitynetworksetup which provides access to allnetwork preferences.

I like that. I found it in /System/Library and made a symlink from /usr/sbin. I'm going to spend some time looking at it. For something that's the recommended way, it sure was hard to find. Inside something called ARDAgent.app, in the Support directory. Also, there's systemsetup. Is that a recommended way to acceess system preferences?

I opted for the easy choice, which did work... and have added the Search Domain info etc whilst at home... and touch wood today things seem to be working better, i can easily access network preferences etc and have had no hanging apps as yet...

I did try and use different locations for work and home, but sadly i ended up with a spinning beach ball of doom when i tried to change the location at work, so it was a slightly pointless exercise!!!

The lookupd -configuration printout is as follows (no idea if it's useful in any way!)

I opted for the easy choice, which did work... andhave added the Search Domain info etc whilst athome... and touch wood today things seem to beworking better, i can easily access networkpreferences etc and have had no hanging apps asyet...

Let's see. It certainly is beginning to sound like circular dependencies.

Well i realize oure already in to this so i dont know where you stand at the moment. But the first thing i would do is un bind that machine from the active directory. Then youse local machine account to edit preferences. Not a network account. When youre done then bind the machine back to AD again and set it up like you did the machines that are working well at the moment. There may be something going on here thats deeper than this but its hard to say if we dont even know whats screwing up for sure.

It might be that you're calling netinfo to bind to AD, but netinfo needs to do a name lookup to find it. Before .local was added to the DNS search domains, DNS would fail. Then your resolver would go to the next item in the list. That would be netinfo, which might be currently blocked waiting for an address. Deadlock.

More Like This

Retrieving data ...

This site contains user submitted content, comments and opinions and is for informational purposes only.
Apple may provide or recommend responses as a possible solution based on the information provided; every potential issue may involve several factors not detailed in the conversations captured in an electronic forum and Apple can therefore provide no guarantee as to the efficacy of any proposed solutions on the community forums.
Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.