Hello and welcome to our community! Is this your first visit?
Register

Results 1 to 6 of 6

How to whitelist websites using hosts file?

This is a discussion on How to whitelist websites using hosts file? within the Alt OS Archives forums, part of the Alternative Operating Systems category; On OSX, I'd like to use the hosts file (/private/etc/hosts) to whitelist some websites (only specific sites should be accessible ...

  1. #1
    Newbie Backspace's Avatar
    Join Date
    Dec 2008
    Posts
    28

    Default How to whitelist websites using hosts file?

    On OSX, I'd like to use the hosts file (/private/etc/hosts) to whitelist some websites (only specific sites should be accessible on the computer). How can I do this?

    I thought this was possible, but I couldn't find instructions anywhere!

  2. #2
    Maestro LeoCastillo's Avatar
    Join Date
    Jun 2005
    Location
    Philippines
    Posts
    4,550
    Liked
    1079 times
    Real Name
    Leo Castillo

    Default Re: How to whitelist websites using hosts file?

    Instead of doing that, you can do it easier via System Preferences > Parental Controls.
    The ability to use a camera will make you a decent photographer. The ability to see and feel will make you a great one.
    Photoworks.
    Discover Photography as You've Never Known Before. http://www.photoworksacademy.com

  3. #3
    Newbie Backspace's Avatar
    Join Date
    Dec 2008
    Posts
    28

    Default Re: How to whitelist websites using hosts file?

    Ah, but I wanted it to affect even Administrator accounts.

  4. #4
    Shinrai's Avatar
    Join Date
    Feb 2008
    Location
    QC
    Posts
    2,192
    Liked
    1 times
    Real Name
    Glenn Santos

    Default Re: How to whitelist websites using hosts file?

    Hmm, I was going to suggest OpenDNS for your whitelist needs but it's a blanket solution which will affect all computers using that net connection.

    You can download the Secrets prefpane so that you can show hidden files and then edit the hosts file. But be sure you know what you're doing and make a backup of the file, we wouldn't want anything weird happening to your computer.

  5. #5
    Mac Lover aaron's Avatar
    Join Date
    Aug 2007
    Posts
    244
    Liked
    1 times

    Default Re: How to whitelist websites using hosts file?

    If you are familiar using Terminal and vi here's what you do:

    Backup first hosts file for safekeeping
    Code:
    sudo cp -p /etc/hosts /etc/hosts.backup
    (will ask for root password)
    Edit hosts file via vi (you should be familiar with using vi interface. google it. otherwise create hosts file from scratch via textedit app by copying first the original content and appending the whitelist IPs at the end)
    sudo vi /etc/hosts
    The hosts file will look like this:

    Code:
    ##
    # 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
    
    #############
    # Whitelist
    #############
    
    203.167.0.3	www.philmug.ph  
    174.133.252.146	www.pinoyphotography.org
    69.147.114.224	www.yahoo.com
    Add the Whitelist IPs at the end together with the website name

    press :wq! to exit and save vi


    You will have to remove the DNS entries in your internet connection in order for this to work. You can only do this by entering your IP address manually and NOT use DHCP. Otherwise, if DHCP is used, it will automatically assign a DNS server for you.

    Note: IMO, this is not an elegant solution since as you have said, you also want to restrict the ADMIN and any ADMIN with superuser privileges will be able to edit the /etc/hosts file

  6. #6
    Newbie Backspace's Avatar
    Join Date
    Dec 2008
    Posts
    28

    Default Re: How to whitelist websites using hosts file?

    Great! Thanks. Yeah, I came from linux and am quite comfortable with the command line (although I prefer just using nano for editing).

    Yeah, admin will be able to edit it but it's okay in my current situation. Thanks!





 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •