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 ?

2 Answers 2

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.

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.

1
  • 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
    – sameera
    Apr 16, 2018 at 7:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .