Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • Are you sure you require changes to the hosts file as opposed to e.g. modifying the host entries via dscl directly?
    – Daniel Beck
    Commented Jan 22, 2012 at 16:39
  • I was not aware of the dscl command, I will have to research on that as well. Commented Jan 22, 2012 at 18:36
  • See e.g. here. Internally, OS X uses its directory services, which you can control using dscl, for which /etc/hosts is simply one of the available data sources, providing (of course) hostname/IP address mappings. Setting up a script that writes to dscl and flushes the cache might work better in your situation than keeping multiple copies of the hosts file, or rewriting it all the time.
    – Daniel Beck
    Commented Jan 22, 2012 at 18:39
  • @DanielBeck: Good point! I wasn't aware of all the capabilities of dscl.
    – Karolos
    Commented Jan 22, 2012 at 19:33
  • Let me know how it works, if you want to try doing it that way. Haven't tried it myself, so I don't post it as an answer. Good luck!
    – Daniel Beck
    Commented Jan 22, 2012 at 19:35