Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two questions.

Question 1: My debian machine has interface eth3 with ip If someone tries to connect to how do I redirect the request to another machine:

Question 2: If my debian machine has two interfaces: eth3 with and ppp0 with some dynamic IP and someone tries to connect via ppp0 on port 1234, how do I redirect the request to

I have tried this:

iptables -t nat -A PREROUTING -p tcp --dport 1234 -j DNAT --to-destination
echo 1 > /proc/sys/net/ipv4/ip_forward

but it does not work.

share|improve this question
I would highly recommend reading [this tutorial](frozentux .net/documents/iptables-tutorial/) on iptables but the site appears to be down at the moment. – kostix Aug 21 '13 at 11:11

Ok the rule looks fine, but you have to remember that packets generated in that machine do not go through PREROUTING. If said machine that holds the iptables in question needs to also redirect it's own traffic the same way, you need to put the same rule to OUTPUT. See iptables-extensions DNAT, it's valid both in OUTPUT and PREROUTING.

Another this that might come into question is filtering. Make sure you also allow said traffic to pass through the machine both ways.

Third thing is that you may also need to MASQUERADE the traffic to that destination in POSTROUTING for a route home.

I can't tell where the packets are lost based on information present. Use tcpdump to see where the packets fly.

share|improve this answer

You must log in to answer this question.

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