Networking Forums  

Go Back   Networking Forums > Networking Newsgroups > Linux Networking

Port Translation via iptables?

Reply
 
Thread Tools Display Modes
  #1  
Old 04-19-2007, 07:40 PM
Default Port Translation via iptables?



Hi, is there a way using iptables to perform port translation, i.e.

Have a service listening on port 343 on the server box, but have
public users reach the server via port 8080 using iptables to route
traffic to port 343 on the server box.

Do I need to create a rule for incoming traffic, as well as outgoing
traffic? Or is this even possible?


Thanks for any help.


-iptables newb



d a v i d
Reply With Quote
  #2  
Old 04-19-2007, 09:17 PM
Pascal Hambourg
Guest
 
Posts: n/a
Default Re: Port Translation via iptables?

Hello,

d a v i d a écrit :
> Hi, is there a way using iptables to perform port translation, i.e.
>
> Have a service listening on port 343 on the server box, but have
> public users reach the server via port 8080 using iptables to route
> traffic to port 343 on the server box.


Of course. Have a look at the DNAT and REDIRECT targets.

> Do I need to create a rule for incoming traffic,


Yes. For example :

iptables -t nat -A PREROUTING -d <box_ip_address> -p tcp --dport 8080 \
-j REDIRECT --to-ports 343

or :

iptables -t nat -A PREROUTING -d <box_ip_address> -p tcp --dport 8080 \
-j DNAT --to :343

Actually "-d <box_ip_address>" is not needed if the box does not act as
a router.

> as well as outgoing traffic?


No. Netfilter will automatically translate the return traffic as needed.
Reply With Quote
Reply

Tags
iptables, port, translation

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 08:21 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.