An easy method to do port forwarding on CentOS is to use xinetd. This service is usually installed on CentOS by default.
In order to port forward with xinetd, you will need to create a configuration file:
vim /etc/xinetd.d/smtp_forward
Some xinetd port forwarding examples:
1. Forward port 2000 on localhost to remote server on port 25:
service smtp_forward { disable = no type = UNLISTED socket_type = stream protocol = tcp user = nobody wait = no redirect = remote_server 25 bind = 127.0.0.1 port = 2000 }
2. Forward port 2000 on all IPs to remote server on port 25:
service smtp_forward { disable = no type = UNLISTED socket_type = stream protocol = tcp user = nobody wait = no redirect = remote_server 25 port = 2000 }
Once you have created your xinetd configuration file, you must reload xinetd for the changes to take effect:
/etc/init.d/xinetd reload