iptables and DNS
Quoted 16 lines · Brian Ugie
Actually iptables-save will resolve to ip when it saves regardless of weather you created the chain with IPs or hostnames. I guess you would never know which way I did it but I assure you that I am entering the IPs when I create the chains.
I feel that you are all missing what the problem is. Let me see if I
can explain it better.The example server is NS2.pzs.com and has an ip address of 10.1.1.13
The DNS record for NS2.pzs.com is 66.126.189.37
A firewall appliance sits in front of the server and mapps the public address to the private address. The firewall will only allow port 53 /udp/tcp traffic in.
Quoted 5 lines
Now, this works fine with no iptable rules but once I add, say
iptables -A INPUT -d 10.1.1.13 -p tcp --dport 53 -j ACCEPT iptables -A INPUT -d 10.1.1.13 -p udp --dport 53 -j ACCEPT iptables -P INPUT DROP
Is NS2 the same as the firewall? In other words, the rule above
says: dns packets destined for 10.1.1.13 are allowed to enter the firewall host. Is this what you want?
Quoted 1 line
DNS will nolonger respond on NS2. But if I go into NS1 and change the
What is NS1? What is your network topology?
Quoted 1 line
NS2 record so that is resolves to 10.1.1.13, the above rules will work.
I believe that you need to revisit your rule set. But a general "iptables" rule is that when you're writing rules, do not use dns/host names for the "-d" and "-s" switches.
Ramin
Quoted 1 line
--Brian
Hi.
I'm not sure if I've got the gist of this thread correctly, but I thought it might be useful to point out the following, which may not be obvious:
If you create netfilter rules using hostnames, they get resolved once and once only at the time the rule is entered (ie when you type it in, or when it gets executed in a startup script), and from that point onwards, netfilter internally uses the numeric value in the ruleset.
If you create netfilter rules using IP addresses, then of course it's clear that these are the addresses being used in the rules, but internally everything is just the same.
Do not think that netfilter is going to do a series of DNS lookups every time a packet comes through and gets matched against a ruleset which you specified using hostnames !
Hope that helps ?
Antony.