Hot answers tagged

90

It turns out the solution was to bounce mDNSResponder: sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist This was obtained by a different coworker from this Server Fault question. OS X 10.10.0 – 10.10.3, Yosemite Apparently, mDNSResponder ...


65

There are several ways - here are two: cat /etc/resolv.conf -or- scutil --dns


58

/private/etc/hosts seems to be working normally for me in Yosemite (version 10.10.1). It's not necessary to flush the cache or reset discoveryd (the DNS resolver in Yosemite); sudo fs_usage | grep private/etc/hosts shows discoveryd reading the file immediately after I save changes to it. [Update: discoveryd was only used in OS X versions 10.10.0 - 10.10.3. ...


42

This question seems a bit old, but I'm going to answer it anyways as I had a similar problem: Yes, this works. Your first problem is that you obviously have the wrong IP (8.8.8.8 instead of 203.12.160.35) in /etc/resolver/apple.com. Verify that the contents of this file is really: nameserver 203.12.160.35 Then scutil --dns should have an entry like this: ...


26

Why they made this change, I don't know, but it's driven me crazy for a while. I don't know why things work for host, but not ping, but I think it has to do with the nature of these two utilities. Ping is a simple (although very helpful) diagnostic utility for dropping packets on the wire that should get echoed back to you. The hostname lookup ...


25

nslookup, host, and dig are perfectly good DNS query tools in OS X, but they all query DNS directly rather than going through OS X's internal resolution system. As a result, they don't check the /etc/hosts file, or resolve Bonjour/mDNS names (those ending in .local). The standard (quick 'n dirty) way to test resolution is to use ping, since it'll resolve the ...


23

Since discoveryutil was replaced by its predecessor mDNSResponder in 10.10.4 use sudo killall -HUP mDNSResponder again (like in Lion/Mountain Lion/Mavericks) to flush the DNS cache.


22

Once you have setup different Network Loacations as per Adam Rice's solution, you can quickly switch between the locations using top menubar option "Apple > Location".


20

You can have multiple network configurations and switch between them on your Mac. Open the Network prefpane, and you'll see that there's a popup menu at the top (probably says "default" or something). Let's say you get this set up the way you like it for home use. Pull down that menu to Edit Location…, double-click on the name, and give it an obvious name ...


19

To get the settings: networksetup -getdnsservers Airport To change them: networksetup -setdnsservers Airport xx.xx.xx.xx These settings are non-persistent, so you could clear your manual settings, let the public wi-fi DNS do its thing, then use the -setdnsservers to set it to what you want until next time.


18

According to the the hosts(5) manual page, the /etc/hosts file is used by mDNSResponder. Your attempts are correctly flushing the computer wide cache but you also need to flush the browser's private cache. After each edit of /etc/hosts reset the mDNSResponder cache using this Apple technical note, OS X: How to reset the DNS cache: sudo dscacheutil -...


18

Since 10.10.1, the simplest way to fix this is to add --AlwaysAppendSearchDomains to ProgramArguments in plist file /System/Library/LaunchDaemons/com.apple.discoveryd.plist Then restart com.apple.discoveryd.plist with: sudo launchctl unload /System/Library/LaunchDaemons/com.apple.discoveryd.plist sudo launchctl load /System/Library/LaunchDaemons/com.apple....


16

I have discovered another wrinkle with this issue. In order to fix the problem I was having, I had to ADD IPv6 style hosts file entries. It seems that Safari will overlook IPv4 entries IF you have an IPv6 network configuration setup. You must add duplicate entries that resolve to IPv6 localhost address in /etc/hosts. IPv4 entry 127.68.56.101 facebook.com ...


12

If you are using Juno Pulse VPN client, /etc/hosts gets over-written by /etc/jnpr-pulse-hosts.bak


11

Yep. You can do this, /etc/resolver is your friend. $ man 5 resolver: domain Domain name associated with this resolver configuration. This option is normally not required by the Mac OS X DNS search system when the resolver configuration is read from a file in the /etc/resolver directory. In that case the file name is used as the domain name. ...


11

I was able to fix this issue by explicitly setting the HostName using scutil to be the same value as LocalHostName: $ scutil --set HostName $(scutil --get LocalHostName) Now: $ sudo scutil --set HostName MacBook-Pro $ time python -c 'import socket; print(socket.getfqdn())' MacBook-Pro python -c 'import socket; print(socket.getfqdn())' 0.01s user 0.00s ...


10

Actually, I think you might want to use scutil --dns scutil -r hostname These commands use the dynamic store in configd, as opposed to the flatfiles in /etc, which often are only read in single user mode and for non networked systems. man scutil # or scutil --help


10

What you want to do is Add a Network Location for work. You can then easily switch between them using the Location submenu of the  menu. If you really wanted, you could set up a script to switch locations based on network, but really, how lazy do you want to be? ;)


10

You can flush the local DNS cache with the following command: dscacheutil -flushcache How long a DNS entry is cached typically depends on the TTL of that DNS record, which is configured by the DNS admin of the relevant hostname. You can find out the (remaining) TTL of any given DNS record with the dig command: dig apple.stackexchange.com In the answer ...


10

sudo dscacheutil -flushcache does nothing useful related to DNS cache entries - at least in non-LDAP environments and 10.9-10.13. sudo killall -HUP mDNSResponder sends a hang up to mDNSResponder, launchd will restart the daemon and the DNS cache will be cleared as spillover effect. This can easily be tested with the following command sequence: sudo ...


9

From the host(1) man page: Mac OS X NOTICE The host command does not use the host name and address resolution or the DNS query routing mechanisms used by other processes running on Mac OS X. The results of name or address queries printed by host may differ from those found by other processes that use the Mac OS X native name and address ...


9

I'll cover the no-jailbreak scenario and leave editing or another answer for someone that knows how to change this by modifying iOS. Without a jailbreak, no. The cellular data is governed by APN settings. You can change these with the iPhone configuration utility and some learning. The Wi-Fi settings are easy to override using the device itself, but it's ...


9

As a tool to help you find the culprit, here is a dtrace oneliner which prints the pid and name of any process which opens a file for writing, together with the filename: dtrace -qn 'syscall::open*:entry /arg1&3/ { printf("%d %s %s\n", pid, execname, copyinstr(arg0)); }' It needs to be run as root (e.g., with sudo). Pipe it into grep hosts to avoid ...


9

It took a LOT of Googling and digging to get this, but I finally found a solution that works. DHCP overrides the LocalHostName system property, but not the HostName property. By default the HostName is not set in macOS Sierra, so you can set it as well as LocalHostName and ComputerName using scutil: sudo scutil --set HostName yourcomputername sudo scutil --...


9

How can I set up my DNS servers to be configured differently for each wireless network? Set and Change in Network Preferences You can set your own custom DNS settings on a location basis by defining a "Location" in Network Preferences You would then enter your preferred DNS settings (click "Advanced") under the DNS tab: After you create set the ...


8

You can not get authority section if you don't query on authoritative servers. For example authoritative servers for the google.com are; dig @l.gtld-servers.net google.com Result will include these lines; ;; AUTHORITY SECTION: google.com. 172800 IN NS ns2.google.com. google.com. 172800 IN NS ns1.google.com. google.com. 172800 IN NS ...


8

Do you use Cisco's AnyConnect VPN client? If so, you need to edit /etc/hosts.ac instead, and let it copy that to the live file. See this MacOSXHints article, and these previous questions. EDIT: I can't find anything specifically about Janos Pulse, but Juniper's Network Connect messes with /etc/hosts, and I suspect Pulse may do the same thing. According to ...


8

in OSX Mavericks (10.9 - actually 10.6.3 up, I believe) if you want to see the active DNS configuration: scutil --dns The -first- entry (resolver #1) is reportedly the active configuration...though I've seen plenty of cases where that's not the case. from man scutil The --dns option reports the current DNS configuration. The first listed resolver(5) ...


8

Check your hosts file, because probably it's malformed. It should look similar to this one: ## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 127.0.0.1 youtube.com 127.0.0.1 www.youtube.com 255.255.255.255 broadcasthost ::1 ...


8

If using a third-party utility is not an issue for you, then I recommend giving these a try: arp-scan (available via Homebrew) brew install arp-scan arp-scan --localnet fing (download and install the "Desktop Embedded CLI" package from fing.com or via Homebrew brew cask install fing) sudo fing -r 1 -d true -o table,text Both utilities have a number of ...


Only top voted, non community-wiki answers of a minimum length are eligible