Port Forward :80 and :8080 to Two Different Servers
6,695
It depends.
If you are talking about http traffic (I'm assuming that from the ports given), proxying might be preferable to using (D)NAT.
IPTables wise this should do it:
iptables -t nat -A PREROUTING -p tcp -d 172.16.1.10 --dport 80 -j DNAT --to 192.168.1.10:80
iptables -t nat -A PREROUTING -p tcp -d 172.16.1.10 --dport 8080 -j DNAT --to 192.168.1.10:8080
possibly related: https://serverfault.com/questions/179200/difference-beetween-dnat-and-redirect-in-iptables
Related videos on Youtube
Author by
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
On a CentOS 6 server with an IP address of 172.16.1.10, how can I configure iptables to route traffic destined for 172.16.1.10:80 to 192.168.1.10:80, and traffic destined for 172.16.1.10:8080 to 192.168.1.11:8080? Traffic comes in on eth0 and must leave on eth1. Thanks!
-
yoonix about 9 yearsYou find documentation that explains how to do it for one port, then you repeat that for another port. What have you tried and how did it fail?
-
-
ILMostro_7 about 8 yearsWhat about Server-side configuration? e.g.
VirtualHost
directive withapache
.