3

my hosts file looks like this

it should open facebook if you try to open google

173.252.110.27 google.com
##
# 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
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost

also after I added that first line I did:

dscacheutil -flushcache; sudo killall -HUP mDNSResponder

on a OSX 10.8.5 but it doesn't changes anything.

I searched for a while and found different things none helped me.

On this link: Hosts file in OSX Lion not blocking as expected there is a good answer but I don't know how to check which file format I have.

So the question is: - is there something wrong with my hosts file? - how do I check which file format I've got

Thank you!

1 Answer 1

3

The hosts file does not support wildcards, so you have to map each domain and subdomain, which means, you need to add

173.252.110.27   www.google.com

as well. If you are redirect to a local version of google, eg like www.google.fr, you need to add that as well.

You can edit the host file easily from a terminal window without changing the file format to RichText or similar by running the following command:

$ sudo nano /private/etc/hosts

You need to enter your password. Afterwards, add your changes at the end of the file, not the beginning.

At the end, flush you DNS cache or reboot your mac.

4
  • thanks for your answer, it still doesn't work. I've edited the hosts file with vi, should be the same as nano? also now it is at the end. didn't reboot my mac yet but tried with the above flush cache
    – caramba
    Commented Apr 22, 2014 at 14:33
  • vi should be ok. Flushing only the DNS cache should be ok as well. Did you restart your web client / browser?
    – suit4
    Commented Apr 22, 2014 at 14:53
  • now it works, tried for hours, restarting the browser and adding it to the end as you mentioned did the trick... thanks!
    – caramba
    Commented Apr 22, 2014 at 15:00
  • 1
    Actually, google.com isn't a wildcard. *.google.com would be.
    – bot47
    Commented Apr 23, 2014 at 5:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .