M
M
Michael2021-07-22 17:12:06
iptables
Michael, 2021-07-22 17:12:06

How to redirect traffic using iptables?

Hello dear experts. There are 5 proxies with authorization ( http , socks ) servers
scattered geographically around the planet (all data for example) : 6 server in order to have one incoming ip address and redirect to these 5 servers by ports. Suppose server 6 (main): 6.6.6.6 And so 6.6.6.6:1000 - redirects everything to the proxy 1.1.1.1:9999 6.6.6.6:1001 - redirects everything to the proxy 2.2.2.2:8888 6.6.6.6:1002 - redirects everything to proxy 3.3.3.3:7777 6.6.6.6:1003 - redirects everything to proxy 4.4.4.4:6666 6.6.6.6:1004 - redirects everything to proxy 5.5.5.5:5555

How to organize this using iptables?
I found out that this is iptables PREROUTING POSTROUTING FORWARD
But how to correctly compose the rules themselves, the brute force did not work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
galaxy, 2021-07-22
@galaxy

iptables -t nat -A PREROUTING -p tcp --dport 1000 -j DNAT --to-destination 1.1.1.1:9999

H
hint000, 2021-07-23
@hint000

POSTROUTING not required?
Required if 6.6.6.6:1000 is not a gateway for 1.1.1.1:9999 (which is not according to the task description).
iptables -t nat -A POSTROUTING -p tcp --dport 1000 -j SNAT --to-
source this answer is trash).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question