Redirect outbound traffic on port 53 to port 5300 with iptables

Posted by Zagorax on Server Fault See other posts from Server Fault or by Zagorax
Published on 2012-06-22T20:58:31Z Indexed on 2012/06/22 21:17 UTC
Read the original article Hit count: 118

Filed under:

I'm running a local dns server on port 5300 to develop a software. I need my machine to use that dns but I wasn't able to tell /etc/resolv.conf to check on a different port. I searched a bit on google and I didn't find a solution.

I set 127.0.0.1 as nameserver on /etc/resolv.conf. Could you please tell me how can I redirect outbound traffic on port 53 to another port?

I tried the following but it didn't work:

iptable -t nat -A PREROUTING -p tcp --dport 53 -j DNAT --to 127.0.0.1:5300 iptable -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to 127.0.0.1:5300

© Server Fault or respective owner

Related posts about iptables