Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to use bind9 on debian as a DNS server. It was working until I added iptables firewall. I have tried the following filter but it does not seem to work. Anyone can help?

# DNS
-A INPUT -p tcp -m tcp --dport 53 -j ACCEPT --syn
-A INPUT -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -p udp -m udp -s 0/0 -d 0/0 --sport 53 -j ACCEPT**

My complete filter is, the bold is actually a commented line using '#' which I could not find how to prevent:

*filter

# Samba
-A INPUT -p udp -m udp --dport 137 -j ACCEPT
-A INPUT -p udp -m udp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT

# SYN Flood Protection
-A INPUT -p tcp --syn -m limit --limit 5/second -j ACCEPT

# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT -i ! lo -d 127.0.0.0/8 -j REJECT

# Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allows SSH connections
# THE -dport NUMBER IS THE SAME ONE YOU SET UP IN THE SSHD_CONFIG FILE
-A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT

# My webmin custom port
-A INPUT -p tcp -m tcp --dport 10000 -j ACCEPT

#POP mail <br>
-A INPUT -p tcp -m tcp --dport 110 -j ACCEPT --syn

#SMTP Traffic <br>
-A INPUT -p tcp -m tcp --dport 25 -j ACCEPT --syn

#HTTP <br>
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT --syn

#HTTPS <br>
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT --syn

# IMAP mail services <br>
-A INPUT -p tcp -m tcp --dport 143 -j ACCEPT --syn

# Allow ping
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT

# DNS
-A INPUT -p tcp -m tcp --dport 53 -j ACCEPT --syn
-A INPUT -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -p udp -m udp -s 0/0 -d 0/0 --sport 53 -j ACCEPT

# Localhost traffic <br>
-A INPUT -i lo -j ACCEPT

# log iptables denied calls (access via 'dmesg' command)
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7

# Reject all other inbound - default deny unless explicitly allowed policy:
-A INPUT -j REJECT
-A FORWARD -j DROP

# The below commits the rules to production for iptables to execute <br>
COMMIT 
share|improve this question
    
No need for all the giant text! –  Don Roby Aug 13 '11 at 1:58
    
Could you please paste the contents of iptables-save (if it's very large, please use a pastebin) Also, is there any reason why you are poking at specific TCP flags rather than simply allowing conntrack to do what it does best? –  Olipro Aug 21 '11 at 5:25
    
Let me ask - are you testing DNS from within the server or outside the server? –  Rilindo Oct 28 '11 at 18:27
add comment

migrated from stackoverflow.com Aug 13 '11 at 12:52

This question came from our site for professional and enthusiast programmers.

1 Answer

The configuration you print is correct. Check that the actual iptables configured state matches that with the "iptables -L" command. You can make sure the actual configuration reflects your configuration file with "iptables -F" and "iptables-restore < conffile".

As a side note, you might want to break down your configuration in chains as simplification.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.