Answer the question
In order to leave comments, you need to log in
How to route traffic to VPS depending on the port?
There is a VPS that, depending on the port, traffic is redirected to other VPS.
For example, there is a vps with ip 1.1.1.1, game clients connect to it, let's say on port 7777 and 8888.
The task is to redirect traffic from port 7777 to one vps, and from port 8888 to another.
Answer the question
In order to leave comments, you need to log in
iptables gallery?
ipables -A PREROUTING -d VPS_IP/32 -i eth0 -p tcp -m tcp --dport 7777 -j DNAT --to-destination FIRST_IP:DST_PORT
ipables -A PREROUTING -d VPS_IP/32 -i eth0 -p tcp -m tcp --dport 8888 -j DNAT --to-destination SECOND_IP_IP:DST_PORT
ipables -A PREROUTING -d 1.1.1.1/32 -i eth0 -p tcp -m tcp --dport 7777 -j DNAT --to-destination 2.2.2.2:9999
ipables -A PREROUTING -d 1.1.1.1/32 -i eth0 -p tcp -m tcp --dport 8888 -j DNAT --to-destination 3.3.3.3:9999
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question