0

I have media box in my network that hard coded to use specific DNS servers like Google DNS. But I want force this device to use my own DNS servers instead of hard coded DNS. Only way I think this is possible to mangle the DNS request coming from that media box IP to DNAT to my DNS server IP. but I'm not quite sure how do I put rule with mentioning source port and source ip at the same time

I use openwrt router with openwrt 15.0 chaos calmer on it.

iptables -t nat -A PREROUTING -p tcp --sport 53 -j DNAT --to-destination 192.168.1.153

Above query will do the job but it will mangle all the port 53 request. how can I specify this rule with IP address. or is there any other way to do it ?

0

Just add -d a.b.c.d immediately after tcp, to restrict the rule to packets with destination address a.b.c.d.

And add -s e.f.g.h to also restrict by source address.

| improve this answer | |
  • Thanks for the answer.. But it will mangle all the packet go to that 8.8.8.8 I only need to mangle packet from certain device – gripen fighter Apr 16 '18 at 7:35
2

I use

iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT
iptables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT

The redirect just redirects the requests to the router.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.