bind 9 and iptables
Hi All
I have a dns with a forwarder to my isp on the iptables box. I am having trouble on getting dns to work properly.
When i comment:
iptables -P INPUT DROP
iptables -p OUTPUT DROP
DNS will work fine and all the pc's can browse the net.
I have tried the following with out any luck:
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT iptables -A OUTPUT -p udp --dport 53 -j ACCEPT iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
what rule do i need to add to make things more secure to get my dns working properly, thanks?
Regards
_____________________________________________________________________
For super low premiums ,click here http://www.dialdirect.co.za/quote
Your question isn't really specific enough to be sure what's going on, but I'm assuming that on your firewall box, the rules you present allow DNS queries to work, but that on clients behind the firewall, DNS still fails, and furthermore that you have the clients set up to use a DNS server on the outside of your firewall. If this is the case, try:
iptables -A FORWARD ...
Remember, the input and output chains are only for traffic with a LOCAL source or destination (same computer as firewall), whereas forward is for traffic that goes through the firewall computer.
Quoted 33 lines · it clown
Date: Fri, 27 Aug 2004 22:06:00 +0200
From: it clown <[email protected]>
To: [email protected]
Subject: bind 9 and iptablesHi All
I have a dns with a forwarder to my isp on the iptables box. I am having trouble on getting dns to work properly.
When i comment:
iptables -P INPUT DROP
iptables -p OUTPUT DROPDNS will work fine and all the pc's can browse the net.
I have tried the following with out any luck:
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT iptables -A OUTPUT -p udp --dport 53 -j ACCEPT iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
what rule do i need to add to make things more secure to get my dns working properly, thanks?
Regards
_____________________________________________________________________
For super low premiums ,click here http://www.dialdirect.co.za/quote
OK i will try again.
I have a internal dns server with a forwarder to my isp.The internal dns server is on the iptables box.The clients use the internal dns server to resolve names on the local network.When the internal dns cannot resolve a name it forwards to my isp's dns.
So my problem is with the forwarding.To get that to work i have to uncomment:
iptables -P INPUT DROP and iptables -P OUTPUT DROP.
When i uncomment those two rules the clients can browse the internet.
what rules can i use instead of uncommenting those two rules because thats not secure?
I hope this makes more sense, thanks.
Regards
Quoted 41 lines · On Fri, 27 Aug 2004 16:19:59 -0400 (EDT) Nick Taylor <[email protected]>…
Your question isn't really specific enough to be sure what's going on, but
I'm assuming that on your firewall box, the rules you present allow DNS
queries to work, but that on clients behind the firewall, DNS still fails,
and furthermore that you have the clients set up to use a DNS server on
the outside of your firewall. If this is the case, try:iptables -A FORWARD ...
Remember, the input and output chains are only for traffic with a LOCAL
source or destination (same computer as firewall), whereas forward is for
traffic that goes through the firewall computer.Quoted 9 lines · it clown
Date: Fri, 27 Aug 2004 22:06:00 +0200
From: it clown <[email protected]>
To: [email protected]
Subject: bind 9 and iptablesHi All
I have a dns with a forwarder to my isp on the iptables box. I am having trouble on getting dns to work
properly.
Quoted 10 lines
When i comment:
iptables -P INPUT DROP
iptables -p OUTPUT DROPDNS will work fine and all the pc's can browse the net.
I have tried the following with out any luck:
Quoted 15 lines
Quoted 3 lines
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT iptables -A OUTPUT -p udp --dport 53 -j ACCEPT iptables -A INPUT -m state --state ESTABLISHED,RELATED
-j
Quoted 3 lines
ACCEPT
what rule do i need to add to make things more secure
to
Quoted 6 lines
get my dns working properly, thanks?
Regards
_____________________________________________________________________
Quoted 3 lines
Quoted 1 line
For super low premiums ,click here
http://www.dialdirect.co.za/quote
Quoted 1 line
_____________________________________________________________________
For super low premiums ,click here http://www.dialdirect.co.za/quote
Okay. Now I will assume that "forwarding" means satisfying a DNS query recursively, ie the firwall box will generate a NEW query (with the same request in it), and a conversation will start between the firewall and the DNS server at your ISP. When the answer comes back, it will be cached, and a reply will be formed to the client. In this case, the client talks directly to the firewall, NOT the ISP's DNS server...
So, you want:
iptables -A INPUT ...
in order to allow the clients to connect to your machine. A few other people have suggested specific rules to accomplish this, but in the simplest form,
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
is what you're missing.
Please note that this rule isn't specific enough, but there may be reasons why your site would chose to implement a more specific rule differently than I would. I would constrain the DNS service to packets entering the firewall on the "lan" side, and to source addresses within the network I was expecting them from, like this:
iptables -A INPUT -p tcp --dport 53 -i eth0 -s 192.168.1.0/24 -j ACCEPT iptables -A INPUT -p udp --dport 53 -i eth0 -s 192.168.1.0/24 -j ACCEPT
I didn't see any -A INPUT -j ACCEPT rules at all in your sample code. If there were some that don't seem to be matching, and they just didn't get forwarded to the list, please post these so we can figure out why they're not matching as intended.
Quoted 94 lines · it clown
Date: Fri, 27 Aug 2004 22:53:10 +0200
From: it clown <[email protected]>
To: [email protected]
Subject: Re: bind 9 and iptablesOK i will try again.
I have a internal dns server with a forwarder to my isp.The internal dns server is on the iptables box.The clients use the internal dns server to resolve names on the local network.When the internal dns cannot resolve a name it forwards to my isp's dns.
So my problem is with the forwarding.To get that to work i have to uncomment:
iptables -P INPUT DROP and iptables -P OUTPUT DROP.
When i uncomment those two rules the clients can browse the internet.
what rules can i use instead of uncommenting those two rules because thats not secure?
I hope this makes more sense, thanks.
Regards
Quoted 41 lines · On Fri, 27 Aug 2004 16:19:59 -0400 (EDT) Nick Taylor <[email protected]>…
Your question isn't really specific enough to be sure what's going on, but
I'm assuming that on your firewall box, the rules you present allow DNS
queries to work, but that on clients behind the firewall, DNS still fails,
and furthermore that you have the clients set up to use a DNS server on
the outside of your firewall. If this is the case, try:iptables -A FORWARD ...
Remember, the input and output chains are only for traffic with a LOCAL
source or destination (same computer as firewall), whereas forward is for
traffic that goes through the firewall computer.Quoted 9 lines · it clown
Date: Fri, 27 Aug 2004 22:06:00 +0200
From: it clown <[email protected]>
To: [email protected]
Subject: bind 9 and iptablesHi All
I have a dns with a forwarder to my isp on the iptables box. I am having trouble on getting dns to work
properly.
Quoted 10 lines
When i comment:
iptables -P INPUT DROP
iptables -p OUTPUT DROPDNS will work fine and all the pc's can browse the net.
I have tried the following with out any luck:
Quoted 15 lines
Quoted 3 lines
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT iptables -A OUTPUT -p udp --dport 53 -j ACCEPT iptables -A INPUT -m state --state ESTABLISHED,RELATED
-j
Quoted 3 lines
ACCEPT
what rule do i need to add to make things more secure
to
Quoted 6 lines
get my dns working properly, thanks?
Regards
_____________________________________________________________________
Quoted 3 lines
Quoted 1 line
For super low premiums ,click here
http://www.dialdirect.co.za/quote
Quoted 1 line
_____________________________________________________________________
For super low premiums ,click here http://www.dialdirect.co.za/quote
Quoted 4 lines · it clown
Hi All
I have a dns with a forwarder to my isp on the iptables box. I am having trouble on getting dns to work properly.
[snip]
Quoted 9 lines
I have tried the following with out any luck:
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT iptables -A OUTPUT -p udp --dport 53 -j ACCEPT iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
what rule do i need to add to make things more secure to get my dns working properly, thanks?
By the above rules, you are not allowing your clients to connect to your DNS server (you are only allowing DNS server to send queris outside). What you need is:
iptables -A INPUT -m state --state ESTABLISHED iptables -A INPUT -p icmp -m state --state RELATED
iptables -A INPUT -i int_if -p udp --sport 1024: --dport 53 \
-m state --state NEW -j ACCEPT
iptables -A INPUT -i int_if -p tcp --sport 1024: --dport 53 \
-m state --state NEW -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED iptables -A OUTPUT -p icmp --m state --state RELATED
iptables -A OUTPUT -o ext_if -p udp --sport 1024: --dport 53 \
-m state --state NEW -j ACCEPT
iptables -A OUTPUT -o ext_if -p tcp --sport 1024: --dport 53 \
-m state --state NEW -j ACCEPT
Replace int_if and ext_if with internal and external interface names (eth0, eth1, ppp0, or whatever else you have).
Signature · 3 lines
Aleksandar Milivojevic <[email protected]> Pollard Banknote Limited Systems Administrator 1499 Buffalo Place Tel: (204) 474-2323 ext 276 Winnipeg, MB R3T 1L7
On Fri, Aug 27, 2004 at 03:37:07PM -0500, Aleksandar Milivojevic wrote:
<snip>
Quoted 11 lines
By the above rules, you are not allowing your clients to connect to your DNS server (you are only allowing DNS server to send queris outside). What you need is:
iptables -A INPUT -m state --state ESTABLISHED iptables -A INPUT -p icmp -m state --state RELATED
iptables -A INPUT -i int_if -p udp --sport 1024: --dport 53 \ -m state --state NEW -j ACCEPT iptables -A INPUT -i int_if -p tcp --sport 1024: --dport 53 \ -m state --state NEW -j ACCEPT
Out of interest, why only permit packets with a source port of 1024 and above? This rule might not pass DNS requests if they come from a local DNS server being used internally, if it's set up with a "query-source" of port 53. Also the use of source ports is OS dependant, so if you're going to watch this why not pick the range the OS uses? The range of your Linux system can be found via
cat /proc/sys/net/ipv4/ip_local_port_range
or
sysctl net.ipv4.ip_local_port_range
Apologies if I'm being pedantic, just wondering if I've missed something...
Signature · 1 line
mors omnia vincit
Quoting Nick Drage <[email protected]>
Date: Sat, 28 Aug 2004 01:44:36
Quoted 6 lines
Out of interest, why only permit packets with a source port of 1024 and above? This rule might not pass DNS requests if they come from a local DNS server being used internally, if it's set up with a "query-source" of port 53. Also the use of source ports is OS dependant, so if you're going to watch this why not pick the range the OS uses? The range of your Linux system can be found via
Good question... Probably just a habit ;-) Safe to use restriction without having to worry about OS specifics. As for query-source, options in BIND 9 for forcing sport to 53 are there mainly as workarounds for people that have to live with old firewall configurations and old assumptions. Something that most new installations really don't need. I wouldn't be suprised at all to see those options go away one day in future.
Signature · 3 lines
Aleksandar Milivojevic <[email protected]> Pollard Banknote Limited Systems Administrator 1499 Buffalo Place Tel: (204) 474-2323 ext 276 Winnipeg, MB R3T 1L7