News for hackers. Stuff that matters.
Re:OS X DNS cache reset script by cel1ne on Tuesday June 14, 2016 @11:32AM (#11902655)
In 10.10 Apple replaced the then 12-year-old mDNSResponder, which does DNS (apart from other things) with "discoveryd", which had issues so they reverted the change.

http://arstechnica.com/apple/2015/01/why-dns-in-os-x-10-10-i...

http://arstechnica.com/apple/2015/05/new-os-x-beta-dumps-dis...

https://support.apple.com/en-us/HT202516

Re:OS X DNS cache reset script by eventi on Tuesday June 14, 2016 @11:38AM (#11902696)
Do you remember when it JUST FUCKING WORKED before 10.6?
Re:OS X DNS cache reset script by cel1ne on Tuesday June 14, 2016 @11:43AM (#11902742)
Yes. I think it changed because they introduced Airdrop.
Re:OS X DNS cache reset script by eventi on Tuesday June 14, 2016 @12:00PM (#11902886)
Ugh - Airdrop which you have to disable in any decently dense Wifi environment
Re:OS X DNS cache reset script by mmastrac on Tuesday June 14, 2016 @12:17PM (#11903052)
If I want a video call to work properly I have to:

  sudo ifconfig awdl0 down
Re:OS X DNS cache reset script by draw_down on Tuesday June 14, 2016 @12:47PM (#11903282)
Hmm? As far as I know it's not "on" until you open an Airdrop window in Finder.
Re:OS X DNS cache reset script by coldtea on Tuesday June 14, 2016 @06:10PM (#11905737)
Don't let sense get in the way of cargo cult.
Re:OS X DNS cache reset script by pschastain on Tuesday June 14, 2016 @11:56AM (#11902847)
What a worthless link. How about an explanation of the problem? Stop what? Not resetting? Why is a reset necessary? And why the double-negative? Why not "noreallyjustfuckingresetitalready"?
Re:OS X DNS cache reset script by mzs on Tuesday June 14, 2016 @12:54PM (#11903341)
OS X has like 4 commands to flush the DNS cache depending on version. It's a PITA. This script runs the right thing on each.
Re:OS X DNS cache reset script by pschastain on Tuesday June 14, 2016 @02:26PM (#11904136)
Even more reason to clarify.
Re:OS X DNS cache reset script by ddlsmurf on Tuesday June 14, 2016 @12:44PM (#11903258)
Well if you had ran into that problem the link would be very touching to you too. The stop is referring to the constant changing and difficulty in diagnosing resolution under os x (or whatever it's called)
Re:OS X DNS cache reset script by pschastain on Tuesday June 14, 2016 @02:28PM (#11904162)
Maybe, except the author doesn't clarify what exactly the problem is, or that s/he's offering a solution. A solution is only viable if it's both discoverable and understandable.
Re:OS X DNS cache reset script by eventi on Tuesday June 14, 2016 @11:59AM (#11902878)
I don't understand
Re:OS X DNS cache reset script by pschastain on Tuesday June 14, 2016 @02:26PM (#11904145)
Exactly. And the author doesn't bother to explain.
Re:OS X DNS cache reset script by coldtea on Tuesday June 14, 2016 @06:13PM (#11905760)
The author didn't care and it's not their day job to explain.

They just put it out there, which is more than other people did.

If someone feels it needs an added explanation, they can add it themselves.

Some, who had faced similar issue at some time or another, will understand immediately what this is, anyway.

Re:OS X DNS cache reset script by akshatpradhan on Tuesday June 14, 2016 @02:57PM (#11904404)
Too bad they didn't address the DNS problem in the Keynote. This is a bit of an exaggeration, but I do feel I've spun mDNSResponder more often than using their Messages app.

That's not a positive feeling. Especially if you're with a client and your browser stops resolving and your client is watching you open up terminal to spin mDNSResponder

Re:OS X DNS cache reset script by germanier on Tuesday June 14, 2016 @11:27AM (#11902591)
Could someone add some context please? I see that apparently the method to flush the DNS cache changes between versions. Is there a deeper reason why this is necessary?
Re:OS X DNS cache reset script by sirn on Tuesday June 14, 2016 @11:34AM (#11902669)
Basically:

* Snow Leopard and earlier use lookupd for DNS resolving (`dscacheutil -flushcache`)

* Since Lion, they switched from lookupd to mDNSResponder, presumably for Bonjour protocol support (`killall -HUP mDNSResponder`)

* Yosemite switched to discoveryd that basically is a rewrite of mDNSResponder (`discoveryutil mdnsflushcache`)

* Due to a lot of problems with discoveryd, they switched from discoveryd back to mDNSResponder since v10.10.4 (so we're back to `killall HUP mDNSResponder`)

https://support.apple.com/en-us/HT202516

Re:OS X DNS cache reset script by trebor on Tuesday June 14, 2016 @11:31AM (#11902641)
I'm not sure. The `dscacheutil -flushcache` command he lists for Snow Leopard still works for me (OS X Yosemite here).
Re:OS X DNS cache reset script by NEDM64 on Tuesday June 14, 2016 @11:37AM (#11902691)
And it still works for me on macOS 10.12.

So I see absolutely no point here.

Re:OS X DNS cache reset script by masklinn on Tuesday June 14, 2016 @11:44AM (#11902754)
The command doesn't fail but does it actually flush the DNS cache, or does it flush the Directory Cache which isn't used for DNS anymore (or possibly at all, on my El Cap machine flushing succeeds but any query of the cache content or its statistics replies "Unable to get details from the cache node")
Re:OS X DNS cache reset script by sirn on Tuesday June 14, 2016 @12:23PM (#11903100)
The command did flush the Directory Service cache, but DNS is no longer part of it. You can still use its query command though.

    dscacheutil -q host -a name www.example.com
On the topic, easiest way to see if dscacheutil -flushcache work or not is to probably do something like:

    dscacheutil -q host -a name www.example.com
    # Make sure it's in the cache prior to running.
    
    sudo dscacheutil -flushcache
    dscacheutil -q host -a name www.example.com
    # Notice if there's a slight delay for the lookup.
    
    sudo killall -HUP mDNSResponder
    dscacheutil -q host -a name www.example.com
    # Notice if there's a slight delay for the lookup.
Re:OS X DNS cache reset script by simook on Tuesday June 14, 2016 @11:32AM (#11902650)
"macOS" has a tendency to cache stale DNS. But over the years they have changed the commands to flush the cache, so you end up googling how to clear the cache, checking your version of osx, and pray to the DNS gods that it will work this time.
Re:OS X DNS cache reset script by dgant on Tuesday June 14, 2016 @11:26AM (#11902584)
What's the context of this?
Re:OS X DNS cache reset script by ajmurmann on Tuesday June 14, 2016 @11:31AM (#11902639)
The content is that it's tricky to truly flush the DNS cache on OS X and the command to do it gets changed a lot with new releases. It's very annoying because it makes working with DNS very painful.
Re:OS X DNS cache reset script by heavymark on Tuesday June 14, 2016 @11:38AM (#11902700)
Any time I need to flush dns cache, I simply google "flush dns cache mac" and top result shows you the simply command to run: https://support.apple.com/en-us/HT202516

Having a simple command such as "reset dnscache" or something of course would be nice, but since it can already be done in a matter of seconds with a quick google I can't imagine it's that much of concern for apple of many developers compared to other issues.

Re:OS X DNS cache reset script by post_break on Tuesday June 14, 2016 @11:56AM (#11902850)
What if ping was different on every build of linux. Shit gets old.
Re:OS X DNS cache reset script by honkhonkpants on Tuesday June 14, 2016 @11:57AM (#11902866)
I guess that's really handy if your dns cache doesn't include a poisoned record for Google. Otherwise it's useless.
Re:OS X DNS cache reset script by bluedino on Tuesday June 14, 2016 @11:29AM (#11902619)
The process seems to change every version of OS X for some reason. So basically this script runs the appropriate command for whichever version you are using.
Re:OS X DNS cache reset script by 27182818284 on Tuesday June 14, 2016 @11:31AM (#11902637)
I've personally found myself Googling it at least once for each version.

It gets more annoying if you want to explain it to a non-technical OS X user. Maybe this little repo will help them converge on a command alias for the future

Re:OS X DNS cache reset script by justinsaccount on Tuesday June 14, 2016 @11:37AM (#11902689)
I'd just do

  dscacheutil -flushcache || \
  discoveryutil mdnsflushcache || \
  killall -HUP mDNSResponder
Re:OS X DNS cache reset script by eventi on Tuesday June 14, 2016 @11:39AM (#11902715)
SO MUCH TYPING
Re:OS X DNS cache reset script by drauh on Tuesday June 14, 2016 @11:47AM (#11902783)
alias d='dscacheutil -flushcache || discoveryutil mdnsflushcache || killall -HUP mDNSResponder'
Re:OS X DNS cache reset script by Navarr on Tuesday June 14, 2016 @12:04PM (#11902919)
Just copy/paste it from the internet.

Nothing bad could possibly happen. [1]

[1]: http://thejh.net/misc/website-terminal-copy-paste

Re:OS X DNS cache reset script by eventi on Tuesday June 14, 2016 @12:19PM (#11903073)
You might be interrested in an unreleased security tool I've been working on

Install with

curl http://issh.it/yadummy | sh

Re:OS X DNS cache reset script by coldtea on Tuesday June 14, 2016 @06:17PM (#11905784)
How is that any different than installing any opaque binary app?

It all comes downs to whether you trust the source.

At least with the "curl http://xxx | sh" method you can also examine the contents of the script before running it, and even opt to run it after downloading it and checking it locally.

With binary apps off of internet sites, which is what people install and use dozens of times a month, no such luck.

Re:OS X DNS cache reset script by _asummers on Tuesday June 14, 2016 @07:13PM (#11906107)
In this case, you have no idea if the connection is MITM'd because of http. You must assume the source untrustworthy, because you don't know who it is. Additionally, assuming the page's source (from which you copy this command) is over http, you must assume the website has compromised (e.g.) your clipboard on copy and you're pasting in malicious unicode characters or whatever. People should have an inherent distrust of binary blobs, too, for whatever that's worth. Same caveats over serving the download over http, with the added benefit of not being able to read the source (necessarily), with the added bonus of now having to assume the build machine has not been compromised.
Re:OS X DNS cache reset script by coldtea on Tuesday June 14, 2016 @08:40PM (#11906483)
>People should have an inherent distrust of binary blobs, too, for whatever that's worth.

All you said are true for binary blobs as well. The page could be MITM, etc.

"curl xxx | sh" style deployment has all the same disadvantages of binary blogs, but has the added advantage that you can download and check the code before executing it.

Re:OS X DNS cache reset script by kormoc on Wednesday June 15, 2016 @02:56AM (#11907593)
Re:OS X DNS cache reset script by sscotth on Tuesday June 14, 2016 @12:03PM (#11902913)
alias dns_flush="dscacheutil -flushcache &> /dev/null ; discoveryutil mdnsflushcache &> /dev/null ; killall -HUP mDNSResponder &> /dev/null ; true"
Re:OS X DNS cache reset script by protomyth on Tuesday June 14, 2016 @11:46AM (#11902766)
aliases are your friend
Re:OS X DNS cache reset script by eventi on Tuesday June 14, 2016 @11:50AM (#11902808)
aliases make you week
Re:OS X DNS cache reset script by jahewson on Tuesday June 14, 2016 @11:57AM (#11902870)
But they help you avoid typos such as "week".
Re:OS X DNS cache reset script by lamontcg on Tuesday June 14, 2016 @09:43PM (#11906680)
Could OSX just have a way to disable negative caching completely? All it does is troll me when I'm on bad wifi and the DNS lookup for www.google.com gets dropped and that negative response is cached. Can we just stop doing that?

I can't recall the last time I had a positive cache entry issue, but the last time the dropped DNS lookup for www.google.com happened to me was like 2 days ago...

Re:OS X DNS cache reset script by bluedino on Tuesday June 14, 2016 @11:30AM (#11902628)
Actually, this should be included with the Mavericks+ version

    sudo discoveryutil udnsflushcaches
Re:OS X DNS cache reset script by protomyth on Tuesday June 14, 2016 @11:26AM (#11902583)
This is quite nice (I went with an alias myself). Does anyone know if it changed again in macOS?
Re:OS X DNS cache reset script by macinjosh on Tuesday June 14, 2016 @11:38AM (#11902701)
I am running Sierra right now and `killall HUP mDNSResponder` doesn't work but `sudo dscacheutil -flushcache` does.
Re:OS X DNS cache reset script by NEDM64 on Tuesday June 14, 2016 @11:38AM (#11902698)
No.
Re:OS X DNS cache reset script by nickhalfasleep on Tuesday June 14, 2016 @11:40AM (#11902723)
Also, just think about how we get all new browser user agents because of this.
Re:OS X DNS cache reset script by coherentpony on Tuesday June 14, 2016 @11:51AM (#11902814)
It's good practice to include

    set -eu
    set -o pipefail
to avoid the default ON ERROR RESUME NEXT behaviour of bash.
Re:OS X DNS cache reset script by Macha on Tuesday June 14, 2016 @01:09PM (#11903461)
Is that behaviour not the point here? The script tries the first command,then the second if that fails,etc.
Re:OS X DNS cache reset script by _asummers on Tuesday June 14, 2016 @07:14PM (#11906118)
One should also create traps on exit, to revert the system to a good state in the event of pipefail.
Re:OS X DNS cache reset script by stonogo on Tuesday June 14, 2016 @11:59AM (#11902880)
Please stop with the cargo-cult shell scripting. That's not all those options do.
Re:OS X DNS cache reset script by Someone1234 on Tuesday June 14, 2016 @12:19PM (#11903071)
Perhaps an explanation would have been more constructive than an insult.
Re:OS X DNS cache reset script by stonogo on Tuesday June 14, 2016 @01:40PM (#11903759)
Yes, I owe an explanation, but the guy advocating pasting bash settings into every script doesn't.
Re:OS X DNS cache reset script by coldtea on Tuesday June 14, 2016 @06:22PM (#11905818)
He gave an explanation of what they do. It might be wrong, but you haven't given any alternative one.

Besides he is right, and those are useful additions to almost any script that you want to stop on error, undefined vars, etc.

Re:OS X DNS cache reset script by jrcii on Tuesday June 14, 2016 @11:31AM (#11902629)
I have in my .bash_profile for this purpose: alias cleardns='dscacheutil -flushcache' but this solution is way funnier.
Re:OS X DNS cache reset script by eventi on Tuesday June 14, 2016 @11:45AM (#11902761)
I think you understand my true intentions, jrcii
Re:OS X DNS cache reset script by underyx on Tuesday June 14, 2016 @11:38AM (#11902694)
>(or whatever your name is)

Why is changing names seen as a negative thing? My company also changed its name a month ago, and several customers leaving negative feedback said included this phrase or something similar, while to my recollection none of the positive feedback (which we have way more of) took mention of the name change.

Re:OS X DNS cache reset script by fps on Tuesday June 14, 2016 @11:47AM (#11902782)
When a company renames itself, everyone that works with that company needs to make changes. Financial records, password and account management, , internal documentation, integrations, etc all have to change. Plus, eduction on the change takes time. People who occasionally interact with the company are going to be confused for months afterwards. It's very rare that something positive comes out of the name change for existing customers. The same thing is likely for product renames - platform version detection in software, browser/OS categorization in analytics tools, documentation, etc. It just makes work for everyone involved.

And what's the point? MacOS X was a decent name, with good recognition and trust. If people were interested in understanding the back story to the name, they could, but the 'X' didn't scream '10' to people who weren't familiar with the history, so there wasn't a ton of confusion.

Re:OS X DNS cache reset script by alayne on Tuesday June 14, 2016 @11:56AM (#11902851)
This isn't a company changing names.

Branding changes product names all the time. MacOS X was nonsensical. I'm glad they changed it.

Re:OS X DNS cache reset script by davidivadavid on Tuesday June 14, 2016 @12:10PM (#11902974)
It's not seen universally as a negative thing (by people who know about branding and marketing).

It is, however, used as a negative thing by people who would vent regardless of the name change, and just want to emphasize they care so little about you that they can't even remember your name("or whatever you're called"). It's just some classic disgruntled customer stuff.

Re:OS X DNS cache reset script by mvid on Tuesday June 14, 2016 @11:41AM (#11902732)
Because, what is the point? It is a chore to learn a new name, provides no value to the consumer, and has a feeling of ego/vanity.
Re:OS X DNS cache reset script by _ZeD_ on Tuesday June 14, 2016 @11:40AM (#11902725)
"A rose by any other name would smell as sweet"

basically, it's a no-feature change, so an unnecessary one, so a "bad" one.

Re:OS X DNS cache reset script by blakesterz on Tuesday June 14, 2016 @11:25AM (#11902573)

       echo "¯\_(ツ)_/¯"
Something about seeing the shrug emoji in code just cracks me up every time.
Re:OS X DNS cache reset script by gruez on Tuesday June 14, 2016 @11:27AM (#11902597)
Thats not an emoji.
Re:OS X DNS cache reset script by deanCommie on Tuesday June 14, 2016 @11:32AM (#11902649)
Yikes, you are absolutely right, but I think the way that language is fluid we are at most 5 years away from "kids" not being able to recognize the term "smiley". Emoji is becoming the defacto catch-all term.
Re:OS X DNS cache reset script by throwanem on Tuesday June 14, 2016 @11:31AM (#11902631)
Indeed: https://en.wikipedia.org/wiki/Emoticon#Japanese_style

> There is also the \(°O°)\, indicating a hooligan or crazed behaviour, and the (ノ◕ヮ◕)ノ*:・゚.

Re:OS X DNS cache reset script by nutheracc on Tuesday June 14, 2016 @11:32AM (#11902657)
Well now I have to ask... Presumably that's ascii art, and :) is an emoji. And :-) is also an emoji. So how many characters/rows before an emoji becomes ascii art? Also, I take it emoji is the ascii, and emoticon is the image. Also, emoji sounds plural to me - I take it it's not.
Re:OS X DNS cache reset script by sirn on Tuesday June 14, 2016 @11:43AM (#11902746)
In Japanese, they call ASCII-art style smiley and a pictogram separately. The ASCII-art one is "kaomoji" (where kao means "face" and "moji" is letter) while the pictogram is strictly an emoji (where "e" means "picture").

Of course, one could argue that since the word is now being used internationally, it's not necessary for them to be interpret in the same way as its roots.

Re:OS X DNS cache reset script by huxley on Tuesday June 14, 2016 @11:51AM (#11902812)
¯\_(ツ)_/¯ is a type of emoticon referred to as kaomoji common in Asia (and now worldwide), but like the happy face :-) it is an emoticon (kaomoji use a wider character set than the ASCII commonly used in Western emoticons)

Emoji is a Japanese loan word 絵文字 (literally picture character), you can read more about them:

https://en.wikipedia.org/wiki/Emoji

Emoji in English can used as a singular or plural word but you can also write emojis.

Re:OS X DNS cache reset script by hamms on Tuesday June 14, 2016 @11:48AM (#11902788)
You have it backwards: ¯\_(ツ)_/¯, :), and :-) are all examples of emoticons. Emoji are the images.
Re:OS X DNS cache reset script by Sylos on Tuesday June 14, 2016 @11:59AM (#11902882)
Emoji are the images that you often see spammed all over the place: , , , , , ... And "Emoji" is actually plural. "Emojis" is sometimes used as plural, but it's actually wrong.

Emoticons are then usually made up out of multiple ASCII-symbols, although general Unicode is by now also in use: :), :-), :|, :[ ...

And then for the "ㄟ(ツ)ㄏ"-Emoticon, you can get more specific about it and call it "Kaomoji". Kaomoji are not Emoji, even though the two sound related, and are actually a more horizontal style of Emoticons, so basically any Emoticon which you can read without turning your head: ㄟ(ツ)ㄏ, ^^, (っ´▽`)っ, (╯°□°)╯︵ ┻━┻, ఠ_ఠ ...

Re:OS X DNS cache reset script by Zikes on Tuesday June 14, 2016 @11:48AM (#11902786)
An emoji is the name for an image/drawing which represents a single specific unicode character, not a series of characters. The name comes from Japanese e (絵, "picture") + moji (文字, "character") [1]

Multi-character ones would be called smileys, emotes, or emoticons. The confusion comes from the fact that many messengers will automatically replace multi-character emotes with an emoji.

[1] https://en.wikipedia.org/wiki/Emoji

Re:OS X DNS cache reset script by tantalor on Tuesday June 14, 2016 @11:44AM (#11902753)
The term emoticon refers to a series of text characters (typically punctuation or symbols) that is meant to represent a facial expression or gesture (sometimes when viewed sideways), such as ;-).

Emoticons predate Unicode and emoji, but were later adapted to include Unicode characters.

http://unicode.org/reports/tr51/#Emoticons

Re:OS X DNS cache reset script by dghughes on Tuesday June 14, 2016 @11:56AM (#11902857)
All I know is in the mid 90s on IRC we called a :) an emoticon.
Re:OS X DNS cache reset script by cptskippy on Tuesday June 14, 2016 @11:49AM (#11902796)
Those aren't emoji, they're emoticons.
Re:OS X DNS cache reset script by dllthomas on Tuesday June 14, 2016 @11:42AM (#11902735)
Re:OS X DNS cache reset script by eventi on Tuesday June 14, 2016 @11:40AM (#11902718)
Yore welcome
Re:OS X DNS cache reset script by miketheman on Tuesday June 14, 2016 @12:04PM (#11902924)
Someone renamed this. Why?
Re:OS X DNS cache reset script by dang on Tuesday June 14, 2016 @12:09PM (#11902970)
We did. The original title, "Please OS X (or whatever your name is) just fucking reset your DNS cache please", is obviously baity, which means it breaks the HN guidelines. Please read https://news.ycombinator.com/newsguidelines.html. When a title is misleading or linkbait, one should change it to something accurate and neutral.
Re:OS X DNS cache reset script by miketheman on Tuesday June 14, 2016 @12:21PM (#11903088)
Thanks for the update. Would the removal of "fucking" allowed the original title to remain? I feel that the title spurred the interest, as evidenced by the amount of discussion. The new title is not nearly as interesting, nor does it convey the author's vision and rage accurately.
Re:OS X DNS cache reset script by pvg on Tuesday June 14, 2016 @01:52PM (#11903868)
The title rather than the content spurring the interest is pretty much the point of the 'no clickbait titles' guideline. The content itself is hardly in the 'gratifies intellectual curiosity' category.
Re:OS X DNS cache reset script by dang on Tuesday June 14, 2016 @02:10PM (#11904021)
> Would the removal of "fucking" allowed the original title to remain?

No, it isn't the profanity we care about, but the baitiness. Titles that stir up drama or controversy aren't a good fit for HN—the discussions are inevitably primed by the titles, and those are the kind of discussions we hope to avoid.