Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

For this command lines:

sysctl net.ipv4.ip_forward=1

iptables -t nat -A PREROUTING -p tcp --dport port -j DNAT --to-destination ip:port

iptables -t nat -A POSTROUTING -j MASQUERADE

I can reroute to ip:port

But how do I use a DNS instead? For example:

--to-destination mynetwork.dyndns.com:80

share|improve this question
add comment

1 Answer 1

If you want to redirect DNS quries you can try this.

iptables -t nat -A PREROUTING -i ethX -p udp --dport 53 -j DNAT --to $(get lan_ipaddr)
iptables -t nat -A PREROUTING -i ethX -p tcp --dport 53 -j DNAT --to $(get lan_ipaddr)
iptables -t nat -L -v -n # shows nat table

and if you try to forward port 80 to another ip. Here is the rule and a example of it.

iptables -t nat -A PREROUTING -p ${PROTOCOL} -i ${INTERFACE} -d ${LOCAL_IP_ADDR} --dport ${LOCAL_PORT} -j DNAT --to ${DESTINATION_IP_ADDR}:{DESTINATION_PORT}
iptables -t nat -A PREROUTING -p tcp -i eth0 -d 192.168.1.10 --dport 80 -j DNAT --to 192.168.2.2:80

Please let me know in case of queries or if it was the answer of your question.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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