Hot answers tagged

92

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 ...


73

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


61

/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. ...


43

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: ...


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.


19

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....


17

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 ...


14

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 ...


13

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 ...


13

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 ...


12

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


12

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 ...


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

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

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

Had this same issue. I think the local DNS cache had bad data from my previous testing. It was quickly fixed by: sudo killall -HUP mDNSResponder


10

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 ...


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 --...


8

I've experienced the same problem… And while restarting mDNSResponder does seem to "work", restarting it a couple of times every hour sort of sucks. So, for now, I've "solved" the problem by running dnsmasq locally. To do that: Build dnsmasq (download the tgz and make or brew install dnsmasq) Put this in a dnsmasq.conf file: resolv-file=resolv.conf user=...


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

For me it's in the file /etc/pulse-hosts.bak You have to edit this file to customize your hosts directives When you are going to reconnect/connect using the Pulse Secure VPN, it's going to merge the directives from the /etc/pulse-hosts.bak with the content from Pulse directives and creates the /etc/hosts 2018 Update With the newer version of ...


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) ...


7

Name resolution under OSX (and UNIX in general) is taken from the IP addresses of the DNSs in the file located in /etc/resolv.conf (which OS X automatically generates as far as I can remember). Since you've tried virtually anything that comes to my mind, I'd like to ask you: Can you ping the DNS you want to use? What is/are the IP address(es) of the DNS(...


7

I had the same problem on my Mac, and after fixing it I have figured out that it was caused by FortiClient (VPN client). Even when FortiClient was disconnected - it's DNS still appeared in the scutil. The solution for me was: scutil > list ".*DNS" This will show you a list of all DNS configs, that will look something like: subKey [0] = State:/Network/...


7

Open System Preferences and click the Network icon. Select your network in the list on the left, and make sure that it says "Using DHCP" in the drop-down list after "Configure IPv4:" If you've made any changes, click the "Apply" button and then the "Show All" button to make sure everything is saved.


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