4

On a Debian based system; as the superuser, I need to restrict access to some websites but specific to user. For instance, abc.com for user1, xyz.com for user2...

I tried /etc/hosts file. Adding a line like

127.0.0.1 abc.com

does what I want. But it applies to all users as there are only one hosts file. As far as I learn so far, it is not possible to configure hosts file for different users. Are there any other ways of doing this?

2

2 Answers 2

1

If users are locally logged in, you can use iptables:

iptables -A OUTPUT -o EXTERNAL_IF -m owner --uid-owner USERNAME -d DESTINATION_WEB -j REJECT

where:

  • EXTERNAL_IF is the name of the Internet-bound interface (e.g. eth0)
  • USERNAME is the login id of the restricted user
  • DESTINATION_WEB is the DNS name or IP address of the destination website. Beware of sites that host many websites (such as blogger) or those that have multiple public IPs (such as Google)
2
  • Do you know how can I get the EXTERNAL_IF info through terminal with a script? Aug 25, 2014 at 12:24
  • Try this:ip r | grep ^default | sed 's/.* dev \([a-z0-9]*\).*/\1/'
    – Gheesh
    Aug 28, 2014 at 21:04
-2

You can try also starting such tiny script for different users that restarts browser and gives notification to users. It restricts to some websites based on their web-browser title.

1
  • Welcome to superuser - we expect answers to be self contained rather than simply be a link - considering its your own blog, could you edit your answer to include the essential parts of your answer?
    – Journeyman Geek
    Aug 4, 2014 at 1:57

You must log in to answer this question.

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