Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

A machine (M) is behind a NAT.

Port X is forwarded through, and available to the internet.

My application wants to connect to port Y.

How to I configure M to forward incoming data on port X to port Y?

share|improve this question
    
That's unclear to me. Are you talking about TCP ports? If your application (is that application on another machine across the internet?) wants to connect to port Y, how is forwarding incoming data on port X to port Y on M going to help? Do you mean to say that your application on M can only listen on port Y instead? What do you mean by Port X is forwarded through, and available to the internet? –  Stéphane Chazelas Dec 12 '13 at 21:02

1 Answer 1

I think that you are talking about redirecting from the same machine, if so, you could try with iptables,

# iptables -t nat -A OUTPUT -p tcp --dport X -j REDIRECT --to-ports Y
share|improve this answer
    
That sounds right. If my question is unclear on that point, please suggest an improvement. :) I'll give this a try and report back. –  user50849 Dec 12 '13 at 22:12

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.