LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   IP/port forwarding (https://www.linuxquestions.org/questions/linux-networking-3/ip-port-forwarding-812313/)

mmichele 06-05-2010 09:49 AM

IP/port forwarding
 
Hi,
I have to forward all of packet destinate to 127.0.1.1:3820 to 192.168.1.3:3820.

I tried follow iptables command:
Code:

iptables -t nat -A PREROUTING  -p tcp -d 127.0.1.1 --destination-port 3820 -j DNAT --to-destination 192.168.1.3:3820
but the result of "tracepath 127.0.1.1/3820" is the follow:
1: name (127.0.1.1) 0.229ms pmtu 16436
1: name (127.0.1.1) 0.078ms reached
1: name (127.0.1.1) 0.063ms reached
Resume: pmtu 16436 hops 1 back 64

What's I wrong?

Thanks in advice.
Michele

SuperJediWombat! 06-05-2010 10:12 AM

The PREROUTING chain is only for traffic coming into the netfilter system.
Localy generated traffic goes to OUTPUT rather than PREROUTING.

However, loopback traffic (127.0.0.0/8) skips both chains...

In short, you can not DNAT loopback traffic.

mmichele 06-05-2010 10:15 AM

Quote:

Originally Posted by SuperJediWombat! (Post 3993370)
The PREROUTING chain is only for traffic coming into the netfilter system.
Localy generated traffic goes to OUTPUT rather than PREROUTING.

However, loopback traffic (127.0.0.0/8) skips both chains...

In short, you can not DNAT loopback traffic.

then, how can I resolve this problem? There are no solutions?

SuperJediWombat! 06-05-2010 11:29 AM

Well, if the traffic is coming from your system then why can't you just change the destination address? That would solve your problem.

nickname.random 07-11-2010 01:27 PM

Look at this:
http://www.linuxquestions.org/questi....php?p=4027927

For further details:
http://lists.debian.org/debian-user/.../msg00542.html
http://lists.debian.org/debian-itali.../msg00148.html


All times are GMT -5. The time now is 06:22 PM.