csf (ConfigServer Security & Firewall) offers the possibility to redirect/forward traffic from one IP/port to another IP/port.
The requirements, as stated in the
/etc/csf/csf.redirect file, are:
ipt_DNAT iptables module
ipt_SNAT iptables module
ipt_REDIRECT iptables module
The lines listed below need to be added to the file
/etc/csf/csf.redirect. You can edit the line from the command-line or from your control panel -> csf plugin.
To redirect an IP to another IP (same port or a different port):
# DNAT (redirect from one IP address to a different one): # IPx|*|IPy|*|tcp/udp - To IPx redirects to IPy # IPx|portA|IPy|portB|tcp/udp - To IPx to portA redirects to IPy portB
Example 1 – redirect 220.127.116.11 to 18.104.22.168, all TCP ports
Example 2 – redirect 22.214.171.124 port 25 to 126.96.36.199 port 25, TCP protocol
To redirect from one port to another:
# REDIRECT (redirect from port to a different one): # IPx|portA|*|portB|tcp/udp - To IPx to portA redirects to portB # *|portA|*|portB|tcp/udp - To portA redirects to portB
Example 3 – redirect port 8080 to port 443, all IPs, TCP protocol
Example 4 – redirect 188.8.131.52:8080 to 184.108.40.206:443, TCP protocol