Unix/Linux Go Back    


IP Networking Learn TCP/IP, Internet Protocol, Routing, Routers, Network protocols in this UNIX and Linux forum.

How to block domains that match a keyword?

IP Networking


Tags
blocking, domain filtering

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 4 Weeks Ago   -   Original Discussion by milhan
milhan's Unix or Linux Image
milhan milhan is offline
Registered User
 
Join Date: Oct 2002
Last Activity: 23 January 2018, 4:22 PM EST
Location: New England, USA
Posts: 166
Thanks: 6
Thanked 2 Times in 2 Posts
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.
Sponsored Links
    #2  
Old Unix and Linux 4 Weeks Ago   -   Original Discussion by milhan
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 23 January 2018, 12:16 PM EST
Location: Amsterdam
Posts: 11,713
Thanks: 532
Thanked 3,402 Times in 2,997 Posts
Have you tried TCP wrappers?
See https://www.unix.com/man-page/centos/5/hosts_access/

Last edited by Scrutinizer; 4 Weeks Ago at 02:09 AM..
Sponsored Links
    #3  
Old Unix and Linux 3 Weeks Ago   -   Original Discussion by milhan
bakunin's Unix or Linux Image
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 22 January 2018, 12:33 PM EST
Location: In the leftmost byte of /dev/kmem
Posts: 5,678
Thanks: 112
Thanked 1,633 Times in 1,198 Posts
Quote:
Originally Posted by milhan View Post
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
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk to match keyword and return matches and unique fields cmccabe Shell Programming and Scripting 6 12-31-2015 05:31 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
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
Match keyword on string and substitute under vi lycaon Shell Programming and Scripting 2 04-25-2008 01:36 PM



All times are GMT -4. The time now is 05:55 PM.