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.)

Similar Messages

  • 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)

  • Content Filter block attachment .scr/.cab etc... not working inside archive

    Hi,
    We have trouble that Content Filter for blocking attachments executable, scr, and cab is not working if .exe, .scr, or.cab are inside 7zip, zip or rar archive.
    How deep inside attachment ESA goes, if any?
    Antivirus config is set to 5 and some viruses passed like CryptoWall as .scr and .cab.
    So, we are blocking that extension but this time they were inside archive.  

    Hello Juraj,
    I apologise for the inconvenience.
    Currently if there are viral definitions within the attachment, the AV engine would be the first line of defence, if you for some reason notice some viral attachments bypassing your ESA, please open a TAC case so we can escalate the sample to Sophos for you to capture.
    As per content filtering.
    The scan depth on how deep it will go into a system is defined in 'scanconfig' in the CLI.
    This will show your current recursion depth.
    As per .cab and .7z attachments not being properly captured if .scr or .exe are inside it
    Currently there are some Enh request to allow the unpacking/decompression of these archive files to capture things inside it, at the moment the request is still undergoing review.
    As a temporary measure you can proactively send .7z and .cab files to the quarantine for your administrative review -- 
    The ESA will however be able to seek the executable should it be shrouded inside the .rar/.gzip and .zip archives however.
    I hope this helps.
    Regards,
    Matthew

  • The new entries made in /etc/hosts file is not picked up by Weblogic.

    Hi All,
    I have come across a scenario where i have changed the IP address of a particular host name (which was already present in etc/hosts) to point to a new IP address.
    After i did this change, when i do a telnet test to the same hostname, i can see it is getting connected to the new IP to which i changed. But my service which is deployed on weblogic 10.0 still keeps sending requests to the old IP which i commented in the etc/hosts file instead of the new IP address.
    My question is will weblogic cache the data in etc/hosts file somewhere?
    Thanks in anticipation..
    Madhu

    Application deployed on weblogic server will pick the IP address of the server on which the application is deployed .
    IP address or listen address for weblogic server can be configured in 3 different ways :
    Listen Address : Blank --- This means that the server will listen to all the interfaces available on the Machine .
    Listen Address : IP address or Hostname --- The server will listen only to the specified IP address or the hostname .
    Listen Address : : localhost --- The server will be listening only on localhost address and will not be accessible remotely .
    Please check what it the listen address specified at you end.
    Thanks,
    Sandeep

  • Can SID show up in /etc/hosts file?

    Experts:
    I am looking into a /etc/hosts which has something I never saw before.
    Every entry in that /etc/hosts file has a format as follows:
    123.23.456.678   CHERRY      CHERRY.RIO.COM  SID  CHERRY.BRAVO.NET
    For example:
    123.23.456.678   CHERRY      CHERRY.RIO.COM  PRO  CHERRY.BRAVO.NET
    Observation:
    1) each entry has 2 aliases ;
    2) "nslookup CHERRY.RIO.COM "
          2a) will return the correct IP address IF I run this nslookup on the server
          2b) will say "non-exist domain" on my PC
    3) "nslookup CHERRY.BRAVO.NET"
          3a)  will say "non-exist domain"  IF I run nslookup on the server
          3b) will give the correct IP address on my PC
    4) WHY SID (here is PRD) gets into the hosts file?  Would it cause some issues?
    Thank you for help.

    Hi,
    The nslookup is trying to resolve the address via the DNS. If you are not using a DNS, you cannot resolve this hostname via your local machine.. In order to do that, you should add the entry to your local hosts file.
    I don't think there is any harm in using aliasses in that way, but it looks rather strange though..
    Ask your system administrator why the setup of the hosts file is like this. He is responsible for this..
    Kind regards,
    Mark

  • Editing etc\hosts file on windows xp for apps. problem post installation.

    Hi all,
    I was able to install 11.5.10.2 apps on my win xp prof machine. During that process I had to edit the etc/hosts file in windows directory as a work around for that domain name field during installation. Also added the primary DNS suffix as 'suneel.com' . I gave the domain name as 'suneel.com' during installation. The RapidWiz is taking localhost as the system name and referring to this system as localhost.suneel.com, though the actual system name is 'websoft-xp' .
    The host file on Apps machine has the following entries:
    127.0.0.1 localhost
    127.0.0.1 localhost.suneel.com suneel.com
    127.0.0.1 websoft-xp.suneel.com
    So when I connect to apps login server from other systems in lan, I've to edit their hosts file and add an entry for localhost.suneel.com to point to its ip address or else the apps throws an error after logging in as operations/welcome using a different url say 192.168.1.4:8000 . Is there a way to get around this issue?
    More over I'm not able connect to VIS db from other systems. The oracle clients give an error 'No listner' at this address. (The original listener was listening at localhost.suneel.com:1521). So I tried to create a new listerner from Net Manager that actually listens at websoft-xp (the real system name) but it throws me an error 'A valid log file is required' while saving the network configuration and prevents me from saving the network configuration.
    Did I do something wrong with the hosts file during installation or did i miss any entries in that file thats causing this? Any solutions for the above problems will be appreciated?
    Thanks
    Suneel
    Message was edited by:
    suneelgv

    Well I tried that option but for some reason it didn't work for me. It kept giving the tns:connection closed error. Then I searched in metalink and found this note : Note:333158.1
    It suggested setting tcp.validnode_checking = no
    in sqlnet.ora. in
    F:\oracle\visdb\9.2.0\network\admin\VIS_websoft-xp
    And it works. Hope this helps someone facing a similar problem. Good luck.
    BTW how do I run autoconfig?
    Thanks,
    Suneel Gundlapalli

  • 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!!!!!!!

  • Make nslookup read /etc/hosts file

    Dear,
    OS: OUL5x64
    my nslookup resolve the name thru dns server.
    question :
    how to make nslookup resolves name through /etc/hosts file.
    i do have /etc/resolv.conf and /etc/nsswitch.conf file
    here is my nsswitch.conf
    /etc/nsswitch.conf
    #hosts: db files nisplus nis dns
    hosts: files
    but it never uses the file to resolve the name.
    how can i force it to read /etc/hosts file first
    Thanks in advance!

    Perhaps it would help to elaborate on WHY you want nslookup to use the /etc/hosts file?
    If you look at the the name of the nslookup utility, it quite probably is an abbreviation of "nameserver lookup". That strongly suggests it is a tool for querying nameservers.
    NOT a tool to debug the name lookups of your operating system.
    On the platforms I use (I don't use HPUX), you can query and set the nameserver nslookup uses. I would consider it a bug if the nslookup tool uses /etc/hosts if set in nsswitch.conf.
    this is how I lookup what server is set for the utility:
    $ nslookup
    serverDefault server: 10.0.1.1
    Address: 10.0.1.1#53this is how nslookup responds to a query:
    nu.nlServer:        10.0.1.1
    Address:     10.0.1.1#53
    Non-authoritative answer:
    Name:     nu.nl
    Address: 62.69.184.53
    Name:     nu.nl
    Address: 62.69.179.198(I don't know how the "jive quote" comes in, it is supposed to be a "bigger than" sign)

  • Solaris10.. need to remove "::1 localhost" from /etc/hosts file

    I know i have IPV6 disabled (through install options) but i still see "::1 localhost" entry in the /etc/hosts file.. This is related to localhost with IPV6 address ::1.. why it is still there.. what is it's impact.. how can i remove it if i decide to remove..
    Thanks, appreciate help.
    S.

    It could be there if you linked /etc/hosts (or /etc/inet/hosts to /etc/inet/ipnodes). Or recreated the hosts-file from ipnodes (or it could be there by default and removed by my jumpstart, which means i would be unaware of it :-)
    And no, you don't need it if you are not running IPv6, in fact removing it will eliminate a few error messages.
    On all non-IPv6 systems i install i link /etc/inet/ipnodes to /etc/inet/hosts, in order to eliminate errors when changing IP addresses of the host and odd resolv-conflicts (which also removes any reference to ::1), and so far i have never experienced any issue with that.
    .7/M. x2000 :)

  • Strange entry in the /etc/hosts file

    Hi,
    While doing some testings with my network this afternoon, I noticed that there's this strange line in my /etc/hosts file:
    ::1 localhost
    Anybody has any idea what the "::1" is for? The only thing related to network that I had recently installed is VPN Tracker. Could it be VPN Tracker that added that line to the hosts file?
    Thanks in advance for your help!
    Frank
    PowerBook G4   Mac OS X (10.4.8)  

    It's supposed to be there, here's a fresh install's complete hosts file...
    # 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 "
    Not sure what it means... may be a 16 bit number though! :-D

  • Which localhost line shuold be used in the /etc/hosts file on Solaris Sparc

    Hi There,
    I would like to know which line should be use in the /etc/hosts file:
    127.0.0.1 localhost
    127.0.0.1 localhost.localdomain localhost
    Thanks :-)
    J

    user560159 wrote:
    Hi There,
    I would like to know which line should be use in the /etc/hosts file:
    127.0.0.1 localhost
    127.0.0.1 localhost.localdomain localhost
    Thanks :-)
    JThe format for the hosts file is
    ipaddress alias1 alias2 alias3 alias4 Most shops will just have two aliases, one with just the machine name, one with the fully qualified domain.machine name. In reality, you can do whatever makes sense:
    [root@vmlnx01 ~]# cat /etc/hosts
    # Do not remove the following line, or various programs
    # that require network functionality wil fail
    127.0.0.1       localhost.localdomain localhost
    [root@vmlnx01 ~]# ping localhost
    PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
    64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=1.96 ms
    [root@vmlnx01 ~]# ping localhost.localdomain
    PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
    64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=0.094 ms
    [root@vmlnx01 ~]# vi /etc/hosts
    <<<< adding an alias 'fred' >>>>>
    [root@vmlnx01 ~]# cat /etc/hosts
    # Do not remove the following line, or various programs
    # that require network functionality wil fail
    127.0.0.1       localhost.localdomain localhost fred
    [root@vmlnx01 ~]# ping fred
    PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
    64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=0.306 ms
    64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=2 ttl=64 time=0.093 ms
    64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=3 ttl=64 time=0.092 msDoes the order of the aliases have any meaning? I leave that quick experiment as an exercise for the student.

  • Trying to figure out how this got into my /etc/hosts file!

    Hello,
    I recently upgraded to 4.3.3 and since then I've had problems with "No Service" where my AT&T service indicator usually sits.
    Since I know that they're just going to restore my device when I take it to the apple store, I decied to start the process myself.
    I tried several times but got the "iphone could not be restored. This device isn't eligible for the requested build."
    Checked around and found that my /etc/hosts file on my mbp had been altered and now included the following:
    # Below is to bypass Apple iPhone software
    # signature server. For unlocking iPhone
    74.208.105.171  gs.apple.com
    I have no idea how this got there!  And I am concerned.  Anyone have any ideas?  Perhaps from some Mac app I downloaded?
    Thanks.

    1. Click your Finder icon from your dock.
    2. Choose "Go" from your top menu and choose "Go To Folder"
    3. Type "/etc/" and then click "go"
    4. Delete the "hosts" file and reboot the system.
    The hosts file will repopulate from system defaults during the reboot process.
    EE

  • /etc/hosts file

    I was in sudo mode and wiped out my /etc/hosts file. anyone have any idea what i did, or better how to rewrite the proper text there?

    edge.it wrote:
    I was in sudo mode and wiped out my /etc/hosts file. anyone have any idea what i did, or better how to rewrite the proper text there?
    Here's what mine has in it:
    # 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
    (Remove the space at the beginning of each line. I had to add those to keep the board software from scrambling the content.)
    Here are it's permissions settings:
    -rw-r--r-- 1 root wheel 236 Jun 23 2009 /etc/hosts
    I wasn't watching you type, so I don't have any idea what you did to delete that. In Terminal the history command will show you a large number of the last commands you typed. Perhaps that will give you a clue.

  • Do I need to provide the physcial hostname to iAS during installation or can I just that installed name into the /etc/hosts file?

     

    Hi,
    Pls confirm if you are using Windows 2000 Pro, in this O/S the
    hostname is the name of the computer itself. Check the
    MyComputer->Properties->Network Identification->Properties, the name you
    find under the computer name will be automatically taken while
    installation, if it doesn't then there is some error. However the
    C:\Winnt\System32\Drivers\Etc\hosts doesn't matter much while installing
    iAS 6.0 SP1 or above. Hope this helps
    Regards
    Raj
    Hazel Seow wrote:
    Do I need to provide the physcial hostname to iAS during installation
    or can I just that installed name into the /etc/hosts file?
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • How could a java process bypass etc\hosts file while doing dns lookup ?

    Hi,
    I am developing a java web proxy and developer tool [http://www.tcpcatcher.org|http://www.tcpcatcher.org] .
    Right now it is working as a none transparent web proxy.
    In some situation and for some hosts, I would like to turn it into a transparent web proxy.
    Suppose, user's browser and java proxy are running on same host (typically on localhost). An entry is added in etc\hosts file, for example:
    127.0.0.1 google.com
    So without any change in browser config , if user visits google.com with its browser , http request is received at proxy level.
    Now my proxy has to get the actual ip address of google.com bypassing the etc\hosts file (right now the proxy is doing a loop on itself).
    Any idea how this could be achieved ?
    Am I searching in wrong direction ?
    thanks !

    This is a shot in the dark, but I'll try anyway.
    Take a look at dnsjava (open source, I never played with it).
    My understanding is that using this to resolve names instead of normal Java API's would allow you to bypass etc/hosts in the java code
    (see [http://old.nabble.com/DNS-Resolve-from-hosts-file-first-then-DNS-Server-td15431381.html]).

Maybe you are looking for

  • Can i hook up ethernet and use airplay on Apple tv 3rd gen?

    I would like to connect to my apple tv with an ethernet connection for fast networking from my iMac, but would still like to use airplay with iphone and ipad. Is it possible to have both ethernet connected and wifi on at the same time?

  • Sound stays on laptop

    When I plug in my Macbook Pro, with Lion (And when SL) my external mac monitor is active. My laptop is on its stand, closed. The sound stays with the laptop.  I can go into the system prefs and change it to the monitor, but shouldn't it happen automa

  • Can I just issue sqlplus command like a Korn shell does in python?

    Hi I have a question on python as an Oracle DBA. Do I have to have cx_oracle or another similar compenent in order to access Orade database? Can I just do sqlplus like a Korn shell does? I am an Oracle DBA. Daily job requires shell scripting. I am sk

  • Query with trim function running more than 15 hours..

    Hi, I have one select query which is running more than 15 hours.I have many trim() functions in that.and i have index for some columns for the tables that i used in that query.but it is not considering those indexes.. select DISTINCT trim(A.x) x, tri

  • Field change in billing

    Hi ALL, I would like to change the weight and volume fields in billing document while creating in VF01.Please advise me any user exist or any Badi in ECC 6.0. Thanxs.