Alright, my situation is basically this... I have a box that's acting as a router, with 2 interfaces, eth0
and eth1
. eth1
is my uplink, that is it is the interface through which the box is obtaining an Internet connection. eth0
is the downlink, that is the interface through which another device / a switch / a wireless AP / what have you would be connected.
I want to somehow, with iptables, make it so that all requests to port 53 any address that are originating at eth0
should instead be sent to the DNS server running at 127.0.0.1
, and when that DNS server sends a reply, the machine that sent the request should have it seem like the reply came from the address they actually sent the packet to.
Example, say there is a machine connected to eth0
configured to use 8.8.8.8
as the DNS server. The routing machine's DNS server has a record for example.com
pointing at 192.0.2.1
. Someone on the machine connected to eth0
runs dig example.com @8.8.8.8
. They get a reply that APPEARS to come from 8.8.8.8
, but ACTUALLY came from the routing box, and this reply says that the A record for example.com is 192.0.2.1
.
How can I do this?
Note that this needs to work for ANY DNS server address, not just 8.8.8.8
.