Gentoo Archives: gentoo-user

From: Mick <michaelkintzios@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Blocking a domain instead of an IP with ufw
Date: Sat, 01 Aug 2015 10:17:26
Message-Id: 201508011117.05396.michaelkintzios@gmail.com
In Reply to: Re: [gentoo-user] Blocking a domain instead of an IP with ufw by Alan McKinnon
1 On Saturday 01 Aug 2015 10:48:15 Alan McKinnon wrote:
2 > On 01/08/2015 11:21, Meino.Cramer@×××.de wrote:
3 > > Hi,
4 > >
5 > > With ufw I want temporary block any access from my Gentoo PC to certain
6 > > domains. Since domain names change IP addresses I dont want to block
7 > > on base of the IP only.
8 > >
9 > > Is this possible with ufw?
10 >
11 > That is really not a good idea, which is why packet filtering firewalls
12 > seldom attempt it.
13 >
14 > It means that *every*single*packet* involves a reverse DNS lookup to get
15 > the (unreliable) DNS name (which might not even be listed at all), do a
16 > string comparison and make a block decision based on that. All of which
17 > is probably an order of magnitude more resource use that simply sending
18 > the packet out. There are optimizations of course, such as caching the
19 > results of previous lookups, but there's still a considerable overhead.
20 >
21 > There's a few ways around it:
22 >
23 > 1. Rethink your firewalling policy. Maybe you really don't need to block
24 > stuff and just think you do.
25 >
26 > 2. Do a DNS lookup and check the TTL. If it's high, say 86400 then it
27 > cannot change more than once a day. So you only need to do a lookup once
28 > a day. Write or get a script that looks up your banned domains every so
29 > often, gets the new IP if it changed and reload a new netfilter rule set.
30 >
31 > #2 is the correct approach for large firewalls with many users but does
32 > involves a quite sophisticated codebase, probably way more than you need
33 > for your 1 pc. Which brings us back to #1
34
35 There's also the option to set in /etc/hosts:
36
37 127.0.0.1 safebrowsing.clients.google.com
38
39 (Replace the google domain above with whatever you want to stop access to).
40
41 --
42 Regards,
43 Mick

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies