Selective DNS Caching/Forwarding
MaestroRC asks: "I've been looking around online, and I have found several people wanting to do the same thing, but no one seems to have figured it out yet. What I am wanting to do (and before you go further, understand this is for work, i.e.: no innocent people will be harmed in the implementation) is to set up a name server that selectively forwards queries. For example, I would like to create a list of acceptable domains (less than 20) using wildcards such as *.google.com, that the name server will forward a query on to and reply to normally. For anything not in the list, I want it to reply NXDOMAIN or some such.
I've looked at BIND, and there doesn't appear to be a way to do what I'm wanting; it can either have recursion on or off, and any specific zones of type forward still do not forward if it is off. The solution doesn't have to be pretty, and it can just be a simple DNS proxy, but I'm not adept at coding, so it needs to be installable by a regular sysadmin on Linux. Has anyone heard of something like this?"
It won't work for the simple reason that you need dns glue, and you can't control where the glue will come from.
I'm not a Linux person, but I know a way you could do this with Windows Server 2003 DNS Server...
It has an option called "conditional forwarding" where you can forward anything ending with "example.com" to the DNS server x.x.x.x - just set up the DNS server and then set conditional forwarding of the domains you want to allow to a real DNS server.
We use this for setting up trusts between separate Active Directories but it could conceivably be used for this purpose as well.
"I want to get more into theory, because everything works in theory." -John Cash
I tried to do something similar to this once. In BIND, you can define a zone called "." In there, add a record "* IN A 127.0.0.1" (this isn't really NXDOMAIN, but it does prevent people from getting places :)). Then create forward zones for each domain you want to resolve properly.
... then it'll probably suffice.
There are [at least] 2 problems with this. 1) You have to keep the forwarders up to date for the zones you list. 2) If google decides to make www.google.com a CNAME for www.google.akamai.net (OK, Google probably wouldn't do this, but Apple, Microsoft, etc do) and you don't have that other domain defined in a forward zone, it ain't gonna work.
I also wrote a perl script to do what you want. It's really quite simple with a couple modules from CPAN. But, it's not suitable for any sort of remotely demanding DNS environment. If it's just for your kid's computer
My solution is similar but with bind.
Edit the root.hints file and replace the root servers with 127.0.0.1. Then just list forwards for the domains you want to a nameserver that is capable of resolving them. Unfortunately with this method you will get a timeout on any domain that you don't have a forward for, not an NXDOMAIN.
-- http://anonet.org -- The internet the way it was meant to be. Check it out, you may be surprised.
If you check out NetReg, in the download and installation instructions they have steps on how to set up forwards like this. NetReg uses it to require people to register their MAC address. Anyone not registered is forwarded to the registration page, but it would be simply to modify it using their example. We use NetReg at our university, and I am working expanding some of its functionality for my senior project.
I'm not sure if Posadis will meet your requirements or not. See here: http://posadis.sourceforge.net/
.
Something else to look into is this code written in Visual Basic* - please don't laugh - I've been using a hacked version for some time now to cache results and to pass certain lookups through tor_resolve. Url: http://www.csh.rit.edu/~jon/projects/caching_dns/
(If the author is reading this I've been meaning to say "thanks"!)
This might not work as requested but it works for my home network and parenting needs.
pdnsd
__________________________________
Free your mind - Flush your toilet
No need to drop.
Selectively change the destination name server using DNAT and send it to a fake name server. I use a similar hack for other less nefarious purposes. It used to be (before wireless hotspot ops got inventive) a very good way of supplying roaming clients with a well behaved and working DNS. You set the nameservers in the client to two well known, well behaved nameservers so it works with the VPN down. You also set the firewall/VPN gw to hijack all traffic to these well known nameservers coming down the VPN and direct it to your nameservers. As a result the clients consistently get good DNS after the VPN gets brought up and you do not get any silly split DNS scenarios.
Alternatively, besides master and slave there are several less known zone types. You should be able to achieve results similar to what you are looking for by using forward or stub type zones. This will give you a "bind-only" solution without playing silly firewall games.
Baker's Law: Misery no longer loves company. Nowadays it insists on it
http://www.sigsegv.cx/
add a record "* IN A 127.0.0.1" (this isn't really NXDOMAIN, but it does prevent people from getting places :)).
It gets mighty confusing if you're running a web server locally. Like my Mac does. And I have taken it onto networks that like sending you to 127.0.0.1. And wondered why I was getting my own website.
Can use winroute (kerio package) to act as a DNS only, have it default deny, then make up the wildcards you want (yes, it supports standard * and ! wildcards).
eg
*.google.com
www!.yourworkdomain.com
*sourceforge.net
...
So set it to something other than 127.0.0.1 -- 127.0.0.2 for example :)
Even better set it to the IP of a webserver that throws up an information page explaining why you can't browse to the site you're trying to visit, and who to contact if you think it's a mistake/problem.
Of course that won't help anything other than web traffic, but I'm guessing that's the main point of this exercise.
"Don't break my arse, my bargey wargey arse, I don't think my pants would understand..."
Forget the whole 127.0.0.1 game playing, this is VERY simple with BIND
Simply create zones for the domains you want to forward on to be looked up as type forward and disable the "." zone
And since when did Ask Slashdot become an IT troubleshooting forum?
Slashdot has always been an IT troubleshooting forum. What else are you going to do with it? Drink beer? I admit, beer and tacos are a good mix.
Forwarding requires recursion turned on. However, you can set up internal root nameservers which have a trimmed-down version of the DNS namespace, and also slave the zones you're interested in. This can be done very well with BIND.
Hi Slashdot. A friend of mine has been hitting on me for a few weeks now. And while I like him, his advances makes me uncomfortable. How do I tell him that I don't want a relationship, without damaging the friendship that we share?
Yo Slashdot. I've got this yellowish reddish spot. It's about the size of a quarter, and it's getting bigger. And it's all puffy and stuff. It's right on the back of my knee, but it doesn't really hurt. Should I be worried?
Hello. I'm going to Bill's house for a party, so I thought I'd bring a bottle of Castello di Borghese 71. But dear Muffy says that Bill just returned form the Promise clinic, and has to stay clean. What else should I bring to a party instead of wine? A dog or something?
I have a 1989 chevy K2500 that has a vacuum problem. truck runs very rough at idle. has a new egr valve that is working properly, new egr solenoid, all vacuum lines are good, everything is working like it is supposed to except that i am getting almost twice the vacuum to the egr than it is supposed to get. has anyone seen this problem before or any tips? thanks alot!
The ______ Agenda
What's the use in alowing google and not alowing the sites it links to?
I assume you will try to block google cache somehow, otherwise the workaround is rather easy as well...
Sig (appended to the end of comments I post, 54 chars)
Since you're trying to filter people's web access, and block teh pr0n, I'd say you should look into decent web caching software. Something like Squid surely has a way to only allow certain URLs.
I want to delete my account but Slashdot doesn't allow it.
I haven't tried it, but you could probably set up a top level wild card domain, and force responses in it to be NXDOMAIN.
BIND v9 has a great Administrators Reference (bv9arm.pdf I think) that you should download and study if you want to do something like this. http://www.isc.org/sw/bind/arm93/Bv9ARM.pdf
Though you're probably better off looking into something like SQUID or some other internet proxy to do this internet access limitation... it will be more flexible.
Zapman
Actually, the reserved localhost network is a full class-A, 127.x.x.x, so sending to 127.0.0.2 will have the same result on most clients.
09
In our situation, DNS is the easiest way to limit it, because we have about 100 computers spread out among 100 locations, with no VPN or such things. Also, we don't want their actual traffic eating up our internet connection at the main office, since we only have a T1.
I hate sigs...
Wouldn't a proxy server be better suited to this?
You can control their DNS server, but not the other data/programs on the systems?
You might then be better off using a client side proxy, but I offer this piece of advice: If you can't trust your users to use their computers responsibly, why hire them?
(Unless you're in a kiosk situation, in which case this DNS based solution is nowhere near sufficient...)
Zapman
Twisted DNS should be pretty customizable, although your "I'm not adept at coding" will probably make it hard for you. Still, I throw it out there, in case someone else has an application that requires customized DNS. From a cleanliness and safety aspect, it's sure a better starting point than BIND.
As copyright owner of this comment, I authorize everyone to defeat any technological measure which limits access to it.
You're exactly right, I can control DNS server, but not what's on the machine (and the DNS is just a situation where the users aren't smart enough to know better, but even then only a manager would be able to change it). Where is this weird place, you might ask? It's a fast food restaurant. The reason we're doing this is mostly to prevent adware/spyware infections. Prior to doing our hosts file hack, we had 2-3 stores a week getting infected. Now, it's down to 1 every 2-3 months. There are 2 accounts on the machine, an admin account that is passworded, and a "store" account that is not, and is a limited user.
I hate sigs...
... that I'm glad this isn't (apparently) too easy to do? It should always be hard to break standards, especially on the Internet. Otherwise, the next thing you know, when powerful interest groups (think MPAA, RIAA, et al.) get large ISPs (think AOL, Comcast, et al.) in their back pockets... well, I think you can guess what happens next.
Break this! *obscene hand gesture*
Despite what EULAs say, most software is sold, not licensed.
If that's the case, you can up the security significantly by installing a nice, managed, client side firewall. I've only worked with Symantec for this service, but I'm sure there are others. Something that actually lets you limit the IP address ranges you can access, rather than 'this program can get to the internet, and this one can't'.
Zapman
I'll bet you are locked in to some specific Windows applications.
You really need to look into a proper solution, which would be migrating to a more secure OS like Linux.
You are being MICROattacked, from various angles, in a SOFT manner.
My daughter had an online class. The class required IE, Flash, JS, and other holes in security counter to my web browsing guidelines. To prevent it becoming a melted down bot, I pointed it's network setting for DNS to localhost instead my residential gateway. (I know, I just broke the web) I then manualy put just the 7 required sites in the hosts file with correct URL addresses. The end result was the school sites worked and nothing else did. The online course worked like a charm without getting owned. The cavot is the machine could not be used for both homework and web browsing.
The truth shall set you free!
127.0.0.2 is, in any decent stack, also localhost. Actually 127/8 should all point to localhost, and is explicitly reserved for this use.
The IP-of-a-webserver is a decent approach, though. So long as said server has the rest of its ports explicitly closed, not stealthed.
I imagine dnscache (djbdns recursive name server) could do this.
/var/services/dnscache/root/servers/@,
/dev/null > @ /var/services/dnscache
... etc.
I'd try deleting all the entries in
and adding files named as the domains you want to look up, containing only
the IP address(es) of the name servers you want to forward to.
Nuking that @ file appears to give you the NXDOMAIN error like you desire:
[root@blah servers]# cat
[root@blah servers]# svc -h
[root@blah servers]# host www.monster.com 192.168.1.1
Using domain server 192.168.1.1:
Host not found, try again.
If you have a name server to forward to, say at "192.168.1.2" you just need to do
the following:
echo 192.168.1.2 > monster.com
echo 192.168.1.2 > google.com
echo 192.168.1.2 > slashdot.org
I just thought of something... (Actually, I had to go to bed first...and THEN realize this) The IP addresses you put into the domain-named files have to be authoritative name servers. So, whatever you get from a 'host -t ns slashdot.org' has to be in the "slashdot.org" file, etc. Make sure you use IP addresses, and not the hostnames for obvious reasons. OK, back to bed...