DNS
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationDNS

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old November 25th, 2003, 10:50 AM
Tynianx Tynianx is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 4 Tynianx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
DNS Bind 9 and Iptables

Ok I have my name server working perfectly. Internally I can access any domain that I have authority (and a zone file). Externally I can do the same.

However the problem comes when internally I want to get the address of a non-authortive domain such as yahoo.com. It WILL work if I kill iptables, but soon as I bring up IP tables it won't work. Obviously there is an IP table output and input that needs to be set correctly for the named to talk with the other dns servers such as the root servers in the db.rootcache file.

Currently my iptables file looks like so (using lokkit to create the file then I manualy edit it since the last time I used a linux firewall was with ipchains).


# Firewall configuration written by lokkit
# Manual customization of this file is not recommended.
# Note: ifup-post will punch the current nameservers through the
# firewall; such entries will *not* be listed here.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Lokkit-0-50-INPUT - [0:0]
-A INPUT -j RH-Lokkit-0-50-INPUT
-A FORWARD -j RH-Lokkit-0-50-INPUT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 53 --syn -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p udp -m udp --dport 53 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 22 --syn -j ACCEPT
-A RH-Lokkit-0-50-INPUT -i lo -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p udp -m udp -s 10.0.0.220 --sport 53 -d 0/0 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --syn -j REJECT
-A RH-Lokkit-0-50-INPUT -p udp -m udp -j REJECT
COMMIT


So how do I open (and restrict) this server to allow recursive lookups ( I know the named.conf is correct because it works fine without iptables running). The only thing this computer does is authoritive DNS for 5 domains (no recursion externally) and will do authoritive and recursion for internal clients. And will accept SSH from an internal IP address (10.0.0.x). But that should be it.

Thanks for your help in advanced.

Reply With Quote
  #2  
Old November 25th, 2003, 11:47 AM
SilentRage's Avatar
SilentRage SilentRage is offline
DNS/BIND Guru
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jun 2003
Location: OH, USA
Posts: 4,193 SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 14 h 27 m 56 sec
Reputation Power: 77
oh spiffy, I've never researched how to allow restricted recursion.

*researches for 5 min*

darn, it turned out to be really simple.

****************************************************
allow-recursion

Specifies which hosts are allowed to make recursive queries through this server. If not specified, the default is to allow recursive queries from all hosts. Note that disallowing recursive queries for a host does not prevent the host from retrieving data that is already in the server's cache.
****************************************************

Here's an example I made for ya:

options {
&nbsp;&nbsp;&nbsp;&nbsp;# allow loopback and all private networks
&nbsp;&nbsp;&nbsp;&nbsp;allow-recursion { 127/8; 192.168/16; 10/8; 172.16/12; };
};

--
As for iptables, I can't help ya since I'm no linux guru. But an overkill measure is allowing all UDP traffic incoming and outgoing. Not much harm in that.
__________________
Send me a private message if you would like me to setup your DNS for you for a price of your choosing. This is the preferred method if your DNS needs to be fixed/setup fast and you don't have the time to bounce messages back and forth on a forum. Also, check out these links:

Whois Direct | DNS Crawler | NS Trace | Compare Free DNS Hosts

Last edited by SilentRage : November 25th, 2003 at 11:52 AM.

Reply With Quote
  #3  
Old November 25th, 2003, 12:31 PM
Tynianx Tynianx is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 4 Tynianx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes I have the recursion enabled. The named is actually working perfect. It's the dang IPTABLES that is restricting it down. Because when it has to serve an internal host on a non-authoritive lookup it has to ask a root server for help, and those will dish it off and etc. But that reply has to come back to the named through the firewall. And that is where it is dying. I'm guessing it's coming back on a non 53 tcp/udp port.

Reply With Quote
  #4  
Old November 25th, 2003, 03:21 PM
SilentRage's Avatar
SilentRage SilentRage is offline
DNS/BIND Guru
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jun 2003
Location: OH, USA
Posts: 4,193 SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 14 h 27 m 56 sec
Reputation Power: 77
I did some packet sniffing while my BIND server resolved lookups. Try opening incoming port 1025 UDP.

You also should try sniffing or look at iptable logs to determine what ports you need to open. You should also look for an option where iptables will be more intelligent about this. My router blocks port 1025 UDP, but I still get my responses. This is cause the router detects the outgoing UDP packet and expects a response to the original source port.

Last edited by SilentRage : November 25th, 2003 at 03:24 PM.

Reply With Quote
  #5  
Old November 26th, 2003, 08:16 AM
Tynianx Tynianx is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 4 Tynianx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Here is the fix for Bind9.

Since I allow port 53 to come in and I know that works, I just make all other things coming into and out of the DNS server also on port 53.

To do this you need to put this in your options section

query-source address * port 53;
notify-source * port 53;
transfer-source * port 53;


Hope this helps anyone that may come across the same problem.

Reply With Quote
  #6  
Old November 26th, 2003, 09:29 AM
SilentRage's Avatar
SilentRage SilentRage is offline
DNS/BIND Guru
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jun 2003
Location: OH, USA
Posts: 4,193 SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 14 h 27 m 56 sec
Reputation Power: 77
oh duh, why didn't I think of that. :-(

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationDNS > DNS Bind 9 and Iptables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway