How to block domains that match a keyword?

Tags
blocking, domain filtering, ip networking

 
Thread Tools Search this Thread
# 1  
Old 12-23-2017
How to block domains that match a keyword?

I want to know, for internet access, if there is an easy way to filter domain names, on your Linux box, that match certain key(s) without using squid. For example, if you want to block example.com you add the following lines in your /etc/hosts file:
Code:
0.0.0.0  www.example.com
0.0.0.0  example.com
::0      www.example.com
::0      example.com

this will only block the domain example.com. However,
Code:
0.0.0.0  *ample*
0.0.0.0  *ample*
::0      *ample*
::0      *ample*

won't work. I am basically trying to block all domains which contain specific keywords which I provide. Is there a way to get this keyword-match domain filtering work without using squid? Thanks.
# 2  
Old 12-24-2017
Have you tried TCP wrappers?
See https://www.unix.com/man-page/centos/5/hosts_access/

Last edited by Scrutinizer; 12-24-2017 at 02:09 AM..
# 3  
Old 12-26-2017
Quote:
Originally Posted by milhan
For example, if you want to block example.com you add the following lines in your /etc/hosts file:
What you need is a firewall, like the one Scrutinizer has suggested.

Notice that the way you describe you do NOT "block" any domain, you just make sure that the name associated with the domain cannot be reliably translated into an IP-address any more. This is more like painting over a certain name in the telephone book with a black marker: you cannot look up the name and its associated number any more, but everybody who knows the telephone number (or has other means to find it out) could still call it.

I hope this helps.

bakunin

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
awk to match keyword and return matches and unique fields cmccabe Shell Programming and Scripting 6 12-31-2015 05:31 PM
VLANs and their domains Lost in Cyberia IP Networking 2 07-22-2014 09:10 PM
Search for a Keyword in file and replace another keyword or add at the end of line dashing201 Shell Programming and Scripting 7 05-05-2014 05:04 PM
Two separate domains - and files davidm123SED Web Programming 1 02-26-2013 05:17 PM
Using sed to pattern match within a particular multiline block and take action tirodad Shell Programming and Scripting 5 10-04-2012 04:31 AM
Sub domains from report john_prince UNIX for Dummies Questions & Answers 2 02-04-2011 11:54 PM
SED, match a line block RobertFord Shell Programming and Scripting 5 05-17-2010 10:50 AM
delete block of lines when pattern does not match udelalv Shell Programming and Scripting 1 05-06-2010 05:08 PM
Different Nameservers for Different Domains? vertigo23 UNIX for Advanced & Expert Users 2 10-17-2008 04:23 PM
Automating creation of sub-domains??? elduderino UNIX for Dummies Questions & Answers 0 07-11-2008 07:02 PM
Match keyword on string and substitute under vi lycaon Shell Programming and Scripting 2 04-25-2008 01:36 PM
creating domains rmuhammad UNIX for Dummies Questions & Answers 4 11-03-2003 05:47 PM
blocking domains tamemi UNIX for Dummies Questions & Answers 1 04-16-2003 08:13 AM
multiple domains ericg UNIX for Dummies Questions & Answers 2 06-04-2002 07:55 PM