/etc/hosts site blocking

In windows and linux I can block sites by adding the domain to /ect/hosts and pointing to loaclhost eg
127.0.0.1 blockthis.com
Anyone know how to get this to work in Tiger
thanks

Exactly the same in OS X. There is a hosts file located in the /etc/ directory. Open the Terminal application (Utilities folder) and at the prompt enter:
sudo pico /etc/hosts
You will be asked to authenticate with your admin password which will not be echoed.
When the editor opens the files simply enter the sites you wish to block using the format you posted: 127.0.0.1 block.site.com.
Enter each desired site on a separate line. When finished press CTRL-X. You will be prompted to save changes. Respond "y". You will be prompted again to save the filename, respond "y". Pico will quit. You can verify your changes by entering:
cat /etc/hosts
This will list the contents of the hosts file.
Note that underlying OS X is a Unix operating system, so most anything you know how to do in Linix is done the same way in OS X, except that access must be through the Terminal application.

Similar Messages

  • Block URL's with /private/etc/hosts

    Hello,
    i need to edit /private/etc/hosts in 100 mac's on my network.
    the objective is to block their access to some websites, using this basic edit on hosts file.
    is there a way to do this edit and add blocked urls, or to send a new hosts file, using ARD?
    thks

    hello, i have edit my hosts file like this:
    +# 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 rapidshare.com+
    +127.0.0.1 rapidshare.de+
    +127.0.0.1 megaupload.com+
    +127.0.0.1 limewire.com+
    +127.0.0.1 vuze.com+
    +127.0.0.1 acquisitionx.com+
    +127.0.0.1 easy-share.com+
    +127.0.0.1 depositfiles.com+
    +127.0.0.1 mediafire.com+
    +127.0.0.1 38.114.196.10+
    +127.0.0.1 78.140.135.10+
    +127.0.0.1 78.140.135.26+
    +127.0.0.1 78.140.135.27+
    +127.0.0.1 78.140.135.49+
    +127.0.0.1 88.208.23.39+
    +127.0.0.1 85.17.216.46+
    +127.0.0.1 216.92.69.218+
    +127.0.0.1 81.19.29.23+
    +127.0.0.1 64.156.82.109+
    +127.0.0.1 209.222.148.136+
    +127.0.0.1 209.222.148.137+
    +127.0.0.1 209.222.148.138+
    +127.0.0.1 209.222.148.139+
    +127.0.0.1 209.222.148.135+
    +127.0.0.1 130.117.156.250+
    +127.0.0.1 195.122.131.16+
    +127.0.0.1 195.122.131.17+
    +127.0.0.1 195.122.131.18+
    +127.0.0.1 195.122.131.17+
    +127.0.0.1 195.122.131.18+
    +127.0.0.1 195.122.131.19+
    +127.0.0.1 195.122.131.20+
    +127.0.0.1 195.122.131.21+
    +127.0.0.1 195.122.131.22+
    +127.0.0.1 195.122.131.2+
    +127.0.0.1 195.122.131.3+
    +127.0.0.1 195.122.131.4+
    +127.0.0.1 195.122.131.5+
    +127.0.0.1 195.122.131.6+
    +127.0.0.1 195.122.131.7+
    +127.0.0.1 195.122.131.8+
    +127.0.0.1 195.122.131.9+
    +127.0.0.1 195.122.131.10+
    +127.0.0.1 195.122.131.11+
    +127.0.0.1 195.122.131.12+
    +127.0.0.1 195.122.131.13+
    +127.0.0.1 195.122.131.14+
    +127.0.0.1 195.122.131.15+
    +255.255.255.255 broadcasthost+
    +::1 localhost+
    +fe80::1%lo0 localhost+
    I have copy it to /etc/ and /private/etc/, replacing both hosts files.
    I reboot the machine, and try to enter sites with Safari and Firefox. Sometimes i cant enter (as required), sometimes i can.
    Do you have any idea why is this happening?

  • Blocking Ad servers via etc/host file not working

    In Snow Leopard I add a list of ad servers and direct them to 127.0.0.1 via the /ect/host file.
    I've configured the host file on my mac mini server and it doesn't work.
    i just want to block ads when using browsers ON the Mini.
    How can I achieve this?

    Yeah; that's an old-time Windows and Unix hack.
    There are ad-blocking extensions for all major web browsers, and those are easier to manage and maintain.
    Off the top, I'd have to check the search order to see if I was getting a response from remote DNS or from /etc/hosts here.
    If you're running a Mac OS X Server box, you're hopefully also running DNS services, and if you're running DNS services, then that's going to be where this hackery gets implemented. Add bogus zones. And if DNS gets an answer from its cache, I wouldn't tend to expect it to go read /etc/hosts (for performance reasons), for that matter.
    There may well be an ad-blocking DNS server around you can forward queries to, too; I haven't looked for that.
    If you make changes to your local /etc/hosts setup, try issuing the following to clear the cache:
    dnscacheutil -flushcache
    I'd recommend installing an ad-blocker. /etc/hosts is an old-school approach and can end up causing weirdnesses on errors, particularly if your box is (also) a DNS server for your LAN. (Also realize that Apple isn't documenting the /etc/hosts file in the Mac OS X Server 10.6 networking manual.)

  • ? iweb09 vs my hosted site's address wtout extra /welcome/sitename etc

    iweb 09 vs my own hosted site's address wtout extra /welcome/sitename etc
    Rqst for Solutions: Need to upload and have my community and visitors go to our new sites wtout the extraneous iweb09 extras on url /welcome/sitename etc for example http://www.nigeriadiasporavotes.org/votes/Welcome.html
    Will, reasonably, prefer a simple and direct
    http://www.nigeriadiasporavotes.org
    I've tried cyberduck and iweb's ftp
    A successful solution will then allow me to to move my main sites to iweb, especially www.USAfricaonline.com
    Chido
    www.USAfricaonline.com

    Unfortunately, the only way in which you are going to get the url http://www.domain.com is by publishing your site to MME and using masked web forwarding.
    If you upload to an external server using Cyberduck, then yes, you can get rid of the extra site name, but just clicking on your site folder and uploading the contents rather than the whole site folder. Do not upload the separate index file either. Then your url will be http://www.domain.com/welcome.html.
    There is then nothing you can do about page names displaying - there is no uploaded website that does not display http://www.domain.com/pagename.html or php or whatever - this is the way that url's and the web works - if you have a site with more than one page, then this is just how it works and there is nothing you can do.
    I suppose what you can try if your site is only one page is not having a link on the site at all. I see that as you have used one of the template options and the links are included at the top - one link Welcome on your site. If you only have one page and you are not going anywhere, then you do not need one link on the site. What you can do is go back into iWeb and open the Inspector and then click on Page and hide links, so there are none. If you only have one page, then you don't need an index file, so take the links out in iWeb and then publish to a folder again and then upload just the contents of your site folder or whatever it is called 'Votes'? You don't need to upload the separate index file and you could try removing totally, the index file within the uploaded contents of your site folder and seeing if this works to provide you with a url of http://www.domain.com. It might work without the link and index file.
    Other than this, then there is nothing you can do about page names being displayed after your domain name - this is normal - you can however remove the extra sitename by uploading contents rather than the whole site folder.
    Your only other option is then to publish to MME and use masked web forwarding instead, which would give you www.domain.com for all you pages, so no bookmarking of individual pages, just the whole site instead.

  • Conf file added to /etc/apache2/sites get overwritten

    So I need to make some modification and additions to virtual host to support svn. The module are running and and I added my needed changes to a <Location "/svn"> block. Everything works great. Until I make any other changes is the Server Admin to the Sites section. It overwrites my custom changes to my 0001any_443svn.mydomain.com.conf. So I tried creating an all new conf file based on the auto generated one. Then removed the auto generated file. Again, it changed my custom file, and renamed it in the 0000_any sequence. Errr.
    Is there some other location I can place this custom virtual host file that will not get overwritten by Server Admin?

    Don't add your svn virtual host file to /etc/apache2/sites, add it to /etc/apache2, and edit the httpd.conf file to include that virtual host file directly.

  • Lil' script to update adblockfilter, adblocking via /etc/hosts file

    hi, i've recently changed to adblocking via the hosts file (which works great btw), but i was missing  filtersetupdating like in firefox, so i've created with my limited scripting skills this one...
    # lil' script to update /etc/hosts adblock-filter
    #hosts adblock filter taken from this site...
    wget --directory-prefix=/tmp http://www.mvps.org/winhelp2002/hosts.txt
    #Backup /etc/hosts to /tmp
    cp /etc/hosts /tmp
    #standard static hosts file
    echo '# /etc/hosts: static lookup table for host names' > /etc/hosts
    echo '#' >> /etc/hosts
    echo '#<ip-address> <hostname.domain.org> <hostname>' >> /etc/hosts
    echo '127.0.0.1 localhost.localdomain localhost' >> /etc/hosts
    #add custom statc host configuration here
    echo ' ' >> /etc/hosts
    echo '###Ad-Blocking###' >> /etc/hosts
    cat /tmp/hosts.txt >> /etc/hosts
    echo '# End of file' >> /etc/hosts
    rm /tmp/hosts.txt
    enjoy!

    hosts_udate
    #!/bin/bash
    # 2012 Ontobelli for this script
    # make hosts temporal directory
    HOSTSDIR=~/.hostsupdate
    mkdir -p "${HOSTSDIR}"
    # make temporary directory
    TMPDIR=/tmp/hostsupdate
    mkdir -p "${TMPDIR}"
    # set output file
    OUTPUTFILE="${TMPDIR}/hosts"
    # set temporal file
    TMPFILE="${TMPDIR}/tmpfile"
    if [ ! -f "${HOSTSDIR}/hosts.local" ]; then
    echo "You need to create "${HOSTSDIR}"/hosts.local containing the hosts you wish to keep!"
    exit 0
    fi
    # download the mvps.org hosts file.
    wget -c -O "${HOSTSDIR}/hosts.mvps" "http://winhelp2002.mvps.org/hosts.txt"
    # download hpHOSTS
    wget -c -O "${HOSTSDIR}/hosts.hphosts" "http://support.it-mate.co.uk/downloads/HOSTS.txt"
    # download hpHOSTS Partial
    wget -c -O "${HOSTSDIR}/hosts.partial" "http://hosts-file.net/hphosts-partial.asp"
    # download hpHOSTS ad/tracking servers
    wget -c -O "${HOSTSDIR}/hosts.adservers" "http://hosts-file.net/ad_servers.asp"
    # download the pgl.yoyo.org hosts Peter Lowe - AdServers
    wget -c -O "${HOSTSDIR}/hosts.yoyo" "http://pgl.yoyo.org/as/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
    # download SysCtl Cameleon hosts
    wget -c -O "${HOSTSDIR}/hosts.sysctl" "http://sysctl.org/cameleon/hosts"
    # cat entries in a single file
    cat "${HOSTSDIR}/hosts.mvps" > "${TMPFILE}0"
    cat "${HOSTSDIR}/hosts.hphosts" >> "${TMPFILE}0"
    cat "${HOSTSDIR}/hosts.partial" >> "${TMPFILE}0"
    cat "${HOSTSDIR}/hosts.adservers" >> "${TMPFILE}0"
    cat "${HOSTSDIR}/hosts.yoyo" >> "${TMPFILE}0"
    cat "${HOSTSDIR}/hosts.sysctl" >> "${TMPFILE}0"
    # tabs to space
    sed -e 's/ / /g' "${TMPFILE}0" > "${TMPFILE}1"
    # find relevant lines without comments
    grep ^127.0.0.1 "${TMPFILE}1" > "${TMPFILE}2"
    # remove duplicate spaces
    cat "${TMPFILE}2" | tr -s [:space:] > "${TMPFILE}3"
    # remove carriage returns
    cat "${TMPFILE}3" | tr -d "\r" > "${TMPFILE}4"
    # 0.0.0.0 is nicer than constantly knocking on localhosts' door.
    sed -e 's/127.0.0.1 /0.0.0.0 /g' "${TMPFILE}4" > "${TMPFILE}5"
    # remove inline comments
    cut -d ' ' -f -2 "${TMPFILE}5" > "${TMPFILE}6"
    # sort blocklist entries and remove duplicates
    sort "${TMPFILE}6" | uniq > "${TMPFILE}7"
    # remove unneeded blocked sites
    grep -Ev ' dl.dropbox.com| host_you_want_to_whitelist' "${TMPFILE}7" > "${TMPFILE}9"
    # write the user's hosts.local to head, then the blacklists
    cat "${HOSTSDIR}"/hosts.local > "${OUTPUTFILE}"
    cat "${TMPFILE}9" >> "${OUTPUTFILE}"
    echo -e "# end of file" >> "${OUTPUTFILE}"
    # move to /etc/hosts
    mv "${OUTPUTFILE}" /etc/hosts
    # delete temporary directory
    rm -r -f "${TMPDIR}"
    hosts.local
    # /etc/hosts: static lookup table for host names
    #<ip> <hostname.domain.org> <hostname>
    127.0.0.1 localhost.localdomain localhost YOURHOSTSNAMEHERE
    ::1 localhost.localdomain localhost YOURHOSTSNAMEHERE
    # YOUR PERSONAL list
    # blocked list
    Create an alias in your ~/.bashrc
    alias hu='sudo /root/.hostsupdate/hosts_update'
    Run
    # hu <enter>
    Script and cache must be located in /root/.hostsupdate or modify scrip accordingly
    Cheers.
    Last edited by ontobelli (2012-02-15 09:15:17)

  • Editing /etc/hosts

    On OS X client I routinely edit /etc/hosts to add names for my various servers, local and remote, as well as to block some of the better known malware and virus sites and the more egregious Internet hucksters -- er, ad sites.
    10.1.10.47 rama
    10.1.10.48 athene
    144.15.97.289 web yogurt davone
    127.0.0.1 scum.sucker.com
    127.0.0.1 evil.banners.net
    etc.
    I'm hesitant to do the same thing on Server (for example, I know better than to manually edit /etc/apache2/http.conf). My current hosts file in client is over 2500 lines, so if I have to manage this through Server Admin I'd like to get started now.

    Ever since I started using OS X Server, I haven't touched /etc/hosts. I would use the DNS server to deal with the scum.suckers.com, and Workgroup Manager (and DNS again, unfortunately) to manage the actual hosts on your network. I'm curious on the efficacy of managing 2500 actual hosts with Workgroup Manager, though.

  • Google and related sites blocked?

    I just got my iMac back from the Apple Store today; they had to migrate my data over to a new one, since the old one had a bad DVD drive. Anyway, everything works great...except that Google.com and all of its associated sites (YouTube, etc) are now blocked. I get a "problem loading page/unable to connect" error immediately, every time. I get the same issue with Yahoo's homepage, but searching via Firefox's search box works fine for Yahoo. Pinging google.com in Terminal works fine. I've tried accessing the sites with other computers on my network, and had no problems there. The iMac's HOSTS file is clean, too.
    Any thoughts???

    That was the first thing I checked; all clear. Though oddly enough, after my comp's been off for a few hours, it works now. Very strange.

  • Error: Device 768 (vbd) could not be connected. /etc/xen/scripts/block fail

    Hello OTN,
    After converting/exporting machines from VMware and importing them into OVM i am receiving errors on some of the machines when powering on.
    Here is the complete error message:
    Start - /OVS/running_pool/dirkwin
    PowerOn Failed : Result - failed:<Exception: return=>failed:<Exception: ['xm', 'create', '/var/ovs/mount/483E943AE684484EAD7255356E8F24CC/running_pool/machinename/vm.cfg'] => Error: Device 768 (vbd) could not be connected. /etc/xen/scripts/block failed; error detected.
    >
    StackTrace:
    File "/opt/ovs-agent-2.3/OVSXXenVM.py", line 57, in xen_start_vm
    run_cmd(args=cmd)
    File "/opt/ovs-agent-2.3/OVSCommons.py", line 85, in run_cmd
    raise Exception('%s => %s' % (cmdlist, p.childerr.read()))
    >
    StackTrace:
    File "/opt/ovs-agent-2.3/OVSSiteVM.py", line 131, in start_vm
    raise e
    Searching for this error turned up different solutions but none of them worked.
    One mentioned OVM not being able to handle spaces in vm names but this is not a working solution as most of the machines are just regular names without spaces or special characters.
    Also interesting, sometimes this error does not turn up when powering on BUT the machine just powers off again and returns to its turned off state. Next power on the error returns.
    OS types vary from S10, Win XP and RedHat so a possible connection to the error being the host OS is not there.
    Harddrive types are set to auto. The vm.cfg's of functioning machines do not differ from non functioning machines besides the actual vm name in the vm.cfg
    Any idea to this error or how to solve it ?
    Thanks
    -Stephan

    Hello Sebastian,
    This is one of the vm.cfg which will abort due to the above mentioned error:
    acpi = 1
    apic = 1
    builder = 'hvm'
    device_model = '/usr/lib/xen/bin/qemu-dm'
    disk = ['file:/var/ovs/mount/483E943AE684484EAD7255356E8F24CC/running_pool/vmname/vmname.img,hda,w',
    ',hdc:cdrom,r',
    kernel = '/usr/lib/xen/boot/hvmloader'
    memory = '2048'
    name = 'vmname'
    on_crash = 'restart'
    on_reboot = 'restart'
    pae = 1
    serial = 'pty'
    timer_mode = '0'
    usbdevice = 'tablet'
    uuid = 'a2a62bcb-f9ab-4ec3-8574-7415985cdf0a'
    vcpus = 1
    vif = ['bridge=xenbr0,mac=xx:xx:xx:xx:xx:xx,type=ioemu']
    vif_other_config = []
    vnc = 1
    vncconsole = 1
    vnclisten = '0.0.0.0'
    vncpasswd = 'xx'
    vncunused = 1
    The xend.log also turned up nothing concerning this error. no messages were written into it. No other log has been created by xen in the /var/log/xen directory concerning an issue with the current machine.
    Thanks for your help !
    -Stephan
    ps:mac address + pw is commented out
    Edited by: Stephan Becker on Aug 5, 2010 7:11 AM

  • Adding the /etc/host.deny file like linux in solaris 10.

    Dears,
    I need to add a file which will works like the file of /etc/hosts.deny of Linux in Solaris.
    If it is possible in the same manner please let me know that, and if it need some other trick to deny a specific host to access the system please tell me the way to do that.
    Eagerly waiting to hear from you.
    BR//
    Sohel.

    IPfilter can deny a specific IP address access to the host - enable IPFilter with svcadm and edit the /etc/ipf/ipf.conf file to add the IP to block. An example could be:
    block in log quick on bnx0 proto tcp from 192.168.1.5/32 to any
    I use IPfilter to pass and block all sorts of specific IP addresses as well as block/allow specific ports (like only specific hosts can use port 22, ssh).

  • /etc/hosts Prank Gone Wrong, need help restoring files to original

    Some friends were messing around on my computer and playing a joke on me
    using the sudo pico /etc/hosts command they were able to send me from sites I wanted to visit, like facebook, to sites I didnt want to visit..
    what they wrote was:
    67.55.108.167 facebook.com
    67.55.108.167 www.facebook.com
    I have since deleted it but the every time I go to facebook from another sight I am still redirected. The odd part is that I can go to facebook, but only after ive been redirected. What I mean is, I try to go to facebook, get redirected, then try to go to facebook right away. If I do that it works fine. Also Safari is the only internet browser that is effected. Opera and Firefox are both un effected. I tried uninstalling and reinstalling safari as well as using the same command as they did, but in reverse. Still no luck. Any suggestion? Unfortunately they didnt back up the /etc/hosts before they edited it

    You might also want to flush your DNS cache
    dscacheutil -flushcache
    Also make that password change.
    Look in System Preferences -> Accounts to see if your friends added any new admin accounts or granted an existing account admin access.
    If they know how to create ssh-keygen keys, they could have deposited a key in your /private/var/root/.ssh/authorized_keys2 file.
    There are any number of additional tricks they could have done, if they had admin access. I'm just scratching the surface.
    If you do trust these friends, then most likely they just played with /etc/hosts. If they are the kind of friends that get malicious, I would consider the "nuke and pave" reinstall.

  • How to use /etc/hosts file

    how to get Mac OS "X" 10.6.x to use /etc/hosts file and/or /etc/resolv.conf file(s) (ala Unix-style); instead of using some other mechanism?

    I 'thought' that SnowLeopard (somewhere in the "Support" arena) told me that 10.6 (SnowLeopard) did NOT use /etc/hosts, but I am corrected, and now understand through a number of replies here (Apple-Support-Discussions) and other responses that SnowLeopard (10.6 (I'm at 10.6.7) DOES USE /etc/hosts... - AND YES _ I'm attempting to prevent some things, and have some web-site-development-things go to a local-server, etc. etc. etc. - but - I guess my 'answer' was supplied by a number of people and that my ...nix background and my familiarity with /etc/hosts is fine and working well...
    thanks to one and all who helped! - I'm now also well-acquainted with dscl, dscacheutil, and other such utilities...
    THANKSSSSS!!!!!!!

  • Is there a similar file to windows\ssytem32\drivers\etc\hosts in OS X

    Hi,
    I am running a Windows 2003 Server with several websites. I would like to view my websites from my new Imac, however I keep getting prompted for the user name and password for the router.
    In windows on my old computer I could edit the file C:\Windows\System32\Drivers\etc\hosts with the IP address and URL of the site and it would open. Is there a similar file in the Mac OS X 10.5.7 software.
    Many Thanks in anticipation

    {quote:title=Herr Lazaro wrote: > So if /etc/hosts works reliably I'll probably switch to it}{quote}
    Adding host records by editing the /etc/hosts file is not entirely reliably. Since Leopard, some people have reported issues of the added host records "mysteriously" disappearing, or Apache not being able to properly resolve the added hosts. The bigger issue is that the modifications in the /etc/hosts file can create unwanted side effects in the normal functioning of services like the mail server and others.
    Since Leopard, there has been an alternate way to add host records using the dscl utility. In fact, by many, it is considered the better, more reliable, and safer method.
    You can read this recent article to see how its done:
    http://tomafro.net/2009/07/dscl-the-easy-way-to-add-hosts-on-osx
    There are a number of additional articles on the web about using dscl for adding host records to OS X.
    The choice, of course, is yours. If you are using the /etc/hosts file without issue, then it might be safe to continue doing so. But, if your system starts experiencing domain name resolution issues or problems with services such as the mail server, you should consider switching to and using the dslocal database to manage your host records.

  • /etc/hosts entries ignored

    My Mac Pro, OSX 10.5.8, is ignoring entries in the /etc/hosts/ file. I have been all over the net and not found the definitive solution to this for 10.5.8
    I know that 10.5.8 does not use /etc/resolv.conf in the expected way, so adding at the top of resolv.conf the line 'order hosts/bind' does not work.
    This is a super handy trick for the work I do (I do lots of conversions and migrations of websites and databases) and I have come to depend on my Mac resolving from the hosts file first, before going on to normal DNS.
    Any pointers would be very helpful.
    -Bosco

    That is probably because the *NetInfo Manager* application is no longer used. I use host file entries for ad blocking (in Snow Leopard, too), and it works just fine.
    The OP may have improper entries or is doing something like using a text file with non-Unix line endings, but without further feedback it is hard to say.

  • [SOLVED] Strange line in /etc/hosts

    I was checking my /etc/hosts when I came across this line:
    64.50.236.214 releases.mozilla.org
    Should that line be there? Is it safe?
    That ip points to a mirror site.
    Last edited by Skoll (2010-01-14 19:54:14)

    toxygen wrote:you didn't add it?  you can always comment it out with a hash # and see if it gives you problems (restart network afterwards (sudo /etc/rc.d/network restart)).  doesnt look like it would do any harm though, other than limiting you to that one mirror
    No, I didn't. That's why I was so worried.
    Edit: I can download plugins with Firefox even without that line. I found out that my brother had used an arch live cd to change /etc/hosts because he couldn't download plugins, the problem mcmillan mentioned.
    Thank you guys for quick answers.
    Last edited by Skoll (2010-01-14 19:53:39)

Maybe you are looking for