How to block a website with Linux

jfall

Diamond Member
Oct 31, 2000
5,975
2
0
I have Slackware 8.1 that is acting as a gateway via IPtables to two Win XP boxes. Is there any easy way that I can block a website with linux so that when one of my XP boxes try to access that particular site it just says page cannot be displayed or something similiar? I would like to do this without the use of a proxy server if possible
 

resedit

Junior Member
Dec 1, 2002
4
0
0
There's a caching proxy nameserver - I think it is called dproxy-nexgen.
You can run that on a box somewhere and have your other boxes use that for their nameserver.

In addition to requests for names, it also caches the contents of /etc/hosts - thus, in your /etc/hosts file you have

forbidden.domain 127.0.0.1

and when anyone request forbidden.domain the proxy nameserver will see it in its cache and serve 127.0.0.1 as the associated IP address.

That doesn't stop people from going to the IP address who KNOW the IP address though.
It does work as an effective add blocker though :)

You also can run an http proxy and set your firewall to only allow access through the proxy.
Then you can define forbidden sites through the proxy (and log where the wayward employees do their worktime surfing).
 

PowerMacG5

Diamond Member
Apr 14, 2002
7,701
0
0
Why not use iptables to block the URL? If you are using iptables, use this command (to block, say www.tomshardware.com):

iptables -A PREROUTING -t nat -d www.tomshardware.com -j DROP

This will not let anything from www.tomshardware.com come through the gateway, thus blocking the url completely. You can replace the URL with an IP address also. This script can be implemented from the bash prompt, or you can add it to your config file. I personally created a file, named rc.firewall, and added that line to the end of the script. Then when I update the line I just run rc.firewall as a shell script. One thing to note is that since you are using slackware 8.1, as do I, you can add this file to /etc/rc.d/, and it will be implemented automatically at boot time from rc.inet2. If you want it to run at boot time, make sure that it is executable.