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.

Is possible on Debian to change the port of packets that are going to a specific port, using iptables?

Example:

I want packets going in the outbound direction to a.b.c.d for port 1723 to be redirected to the address a.b.c.d on port 10000. Is this possible?

share|improve this question
    
Please use standard terminology like source and destination. Am I correct in assuming you want iptables to change the destination port on outbound packets to a specific host from 1723 to 10000 for both TCP and UDP? –  jw013 Oct 16 '12 at 21:07
    
@jw013 You're right –  Jhonathan Oct 16 '12 at 21:11
add comment

1 Answer

up vote 3 down vote accepted
for proto in tcp udp; do
  sudo iptables -t nat -A OUTPUT -d a.b.c.d -p "$proto" --dport 1723 -j DNAT --to-destination a.b.c.d:10000
done
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.