Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I frequently (at least once per day) need to edit my hosts file, and typing my password every time is getting annoying. I know how to change the permissions to allow myself to write to the file, and I'm aware of the security implications.

My question: will I break anything by modifying the ACLs on /etc/hosts through the Finder?

I'm running OS X Lion 10.7.3.

(Since someone is going to ask, I have a Windows 7 VM in VMware Fusion that likes to change its local connection IP address every time it resumes from suspend (VM pause) or reboots.)

share|improve this question
"Windows 7 VM in VMware Fusion that likes to change its local connection IP" instead of altering your hosts file, why don't you assign the OS (Windows) a static IP or reserve one through your router (the latter is what I do to all devices connecting to my Airport)? –  cksum Feb 22 '12 at 18:46
@cksum The VM has two IPs: as I understand it, one for it to connect to the network (a 192. address behind VMware's NAT) and one for it to connect directly to the Mac host OS (a 172. address; this is the one I care about). I didn't set this up and it works for the most part, so I'm loath to do anything that might wreck it. –  CajunLuke Feb 22 '12 at 18:51
That doesn't sound right. An internal IP connects to your LAN (non-routable IP). If you want to connect to your machine, you'd always use for a loopback. I don't use VMWare but your machine wouldn't have an IP with a different subnet like that. That division is made by your router (to whatever you set it to, either 172, 192, or 10). So if it's set to assign 172, all machines on that network would be part of that subnet. If everything is using DHCP, then the router determines the subnet. Fire up network preferences in Windows and have a look. –  cksum Feb 22 '12 at 18:59
There are actually three networks in use: the 10. network that is the actual, physical network that the Mac is plugged into, the 192. network that is the VMware NAT so Windows can talk to the network, and the 172. network that is between the Mac host and the VM guest to make communication between them work whether you're on Ethernet or WiFi or not on a network at all. –  CajunLuke Feb 22 '12 at 21:00
add comment

2 Answers

up vote 3 down vote accepted

Nothing will break (or hasn't for me whenever I resort to this on occasion) - you'll have to remember to re-do the permissions if and when the OS updates that file systematically. You'll also want to watch the permissions if you ever "repair permissions" since that file is likely recorded in a system receipt. I'd go so far as to set a launchd task to daily enforce your "custom" permissions if you feel it's worth that much work and log something to the console about the need for this "adjustment"

This is a far faster and simpler (and therefore probably better) solution to setting up your own DNS or NIS even though a trip down memory lane would be fun for a few moments:

  • cd /var/yp
  • make
share|improve this answer
Why is editing the hosts file better than a bespoke DNS or NIS server? Is that a case of less complexity being generally better? –  CajunLuke Feb 22 '12 at 18:53
I'd say it's simpler, less prone to needing maintenance, and requires less initial learning. Running your own DNS can be much better and NIS is so old, I wouldn't recommend it other than for a record of how things used to be. It can be of use in large organizations where you have many small islands of grouped servers needing central but distributed user/group/host management yet don't want to use LDAP. –  bmike Feb 22 '12 at 18:55
add comment

IMO, you're doing it wrong. mDNS, static IP addresses, all sorts of options are better, but if you insist on making /etc/hosts writable and are willing to accept the problems that this can introduce, why not?

Every time a 'repairPermissions' from diskutil is called, you may have to reset them.

share|improve this answer
I figured a static IP would work, but this is my work computer and I didn't set up the VM's networking, so I'm afraid I'll break it. (I know very little to nothing about networking.) –  CajunLuke Feb 22 '12 at 18:43
I am with asdf. Just go to networking preferences in Windows and instead of using DHCP, set it to a static IP. Router level reservation would be better but some don't support it. –  cksum Feb 22 '12 at 18:48
There isn't a real router - VMware is doing all the routery, NATty stuff. –  CajunLuke Feb 22 '12 at 18:54
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.