Hot answers tagged

80

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


64

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


45

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


36

Update There's a very simple way to simply SSH to a BTMM/iCloud computer: In Terminal, in the Shell menu select New Remote Connection... (cmd+shift+K). From here you can browse by ssh/sftp/ftp/telnet hosts on the local or BTMM network. This is obviously much easier for the individual apps that support iCloud/BTMM lookup (e.g. you'll also see file shares ...


28

Wake for wifi network access (aka Wake on Demand but with Wifi) allows your computer to be brought out of sleep mode when someone else on the network requests access to a service on your computer eg. File sharing. From this Apple KB article Wake on Demand helps you save energy and reduce costs while still ensuring full access to all your shared files ...


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


24

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


19

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


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


18

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


16

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


15

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


15

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


14

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


13

This isn't my preferred method, but the Terminal app also polls your iCloud account for all Back To My Mac computers that it has a current registration. Under the Shell menu - New Remote Connection... ⇧+⌘+K This is quite handy to set up a new ssh/sftp connection home when you are not on the local internet or your dns server won't look up the AAAA records ...


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


13

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


12

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


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


11

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


10

Here's the answer to your question… I just learned a nifty way to find your BTMM domain name echo show Setup:/Network/BackToMyMac | scutil | sed -n 's/.* : *\(.*\).$/\1/p' source: https://gist.github.com/1856804 by skyisle But here's why that still doesn't help you… However, note that even if you know the BackToMyMac domain, you can only use it if you ...


10

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

This has changed a little with 10.7 and you'll want to note that this uses IPv6 almost entirely so test with ping6 and traceroute6 to debug things. It's no longer done via @computername.mobilemename.members.mac.com, it's now done via members.btmm.icloud.com, and its no longer as simple as your mobilemename. Step 1: Find out your iCloud BTMM domain Either ...


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


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

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


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


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