LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 01-19-2005, 06:44 PM   #1
aqoliveira
Member
 
Registered: Dec 2001
Location: Portugal
Distribution: /Red Hat/Fedora/Solaris
Posts: 622

Rep: Reputation: 30
dns not working with iptables


Hi there

I have a Internal DNS server which is working fine can resolv all names for the internal network, forwarders is set to get DNS queries from my ISP which also works fine as I tried links as well as a dig to test this.

I then setup FORWARD filter for the rest of the network to access the internet which is also working fine. Able to resolv names and surf from all machines found my internal network.

Here is the problem I want to change my default Policy for the OUTPUT filter to a DROP and when i do this my DNS stops working which is what I want but when the rule is added to allow DNS queries is does not work.

Below u will find the iptables rule file:

# Generated by iptables-save v1.2.8 on Wed Jan 19 23:24:18 2005
*nat
:PREROUTING ACCEPT [209:35146]
:POSTROUTING ACCEPT [3:203]
:OUTPUT ACCEPT [6:684]
-A POSTROUTING -o eth1 -j MASQUERADE
COMMIT
# Completed on Wed Jan 19 23:24:18 2005
# Generated by iptables-save v1.2.8 on Wed Jan 19 23:24:18 2005
*filter
:INPUT DROP [206:35080]
:FORWARD ACCEPT [0:0]
:OUTPUT DROP [43:4643]
-A INPUT -i lo -j ACCEPT
-A INPUT -i eth0 -j ACCEPT
-A INPUT -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -i eth1 -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -i eth1 -p tcp -m tcp --dport 67 -j ACCEPT
-A INPUT -i eth1 -p tcp -m tcp --dport 67 -j ACCEPT
-A INPUT -i ! eth0 -p icmp -m icmp --icmp-type 255 -j DROP
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -d 192.168.0.0/255.255.0.0 -i eth0 -j DROP
-A FORWARD -s 192.168.0.0/255.255.0.0 -i eth0 -j ACCEPT
-A FORWARD -d 192.168.0.0/255.255.0.0 -i eth1 -j ACCEPT
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -p udp -m udp --sport 53 -j ACCEPT
COMMIT
# Completed on Wed Jan 19 23:24:18 2005



I have also tired to place the source/destination ip address with no luck what so ever.



Running the following command iptables -nL

Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
DROP icmp -- 0.0.0.0/0 0.0.0.0/0 icmp type 255
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

Chain FORWARD (policy ACCEPT)
target prot opt source destination
DROP all -- 0.0.0.0/0 192.168.0.0/16
ACCEPT all -- 192.168.0.0/16 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 192.168.0.0/16
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp spt:53


Thanking everyone in advance for your input
Antonio
 
Old 01-19-2005, 11:28 PM   #2
DaHammer
Member
 
Registered: Oct 2003
Location: Planet Earth
Distribution: Slackware, LFS
Posts: 561

Rep: Reputation: 30
Add a log rule to your chain, then tail the log file with a "tail -f /var/log/whatever" to see exactly what's being dropped.

Last edited by DaHammer; 01-19-2005 at 11:29 PM.
 
Old 01-20-2005, 12:56 AM   #3
DaHammer
Member
 
Registered: Oct 2003
Location: Planet Earth
Distribution: Slackware, LFS
Posts: 561

Rep: Reputation: 30
Just noticed something:
Code:
-A OUTPUT -p udp -m udp --sport 53 -j ACCEPT
That should be:
Code:
-A OUTPUT -p udp -m udp --dport 53 -j ACCEPT
 
Old 01-20-2005, 08:39 AM   #4
aqoliveira
Member
 
Registered: Dec 2001
Location: Portugal
Distribution: /Red Hat/Fedora/Solaris
Posts: 622

Original Poster
Rep: Reputation: 30
hi

I have tried the above with no success still have to try the logging to see what is happening

thanx
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables and DNS ujotne Linux - Security 8 09-12-2005 07:49 AM
iptables +DNS routing? rincewind Linux - Networking 2 03-17-2005 03:57 AM
DNS and IPTABLES cuco76 Linux - Networking 9 02-07-2004 09:12 PM
Dns Nslookup And Iptables s7gn4dd3 Linux - Networking 5 08-07-2003 01:53 AM
DNS Problems with iptables dubman Linux - Networking 1 08-01-2003 11:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 01:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration