V
V
Volodymyr Palamar2020-03-24 19:25:33
linux
Volodymyr Palamar, 2020-03-24 19:25:33

How to redirect all incoming traffic to a proxy using iptables?

How to redirect all tcp and udp traffic (from all ports) to port 8890

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitriy Loginov, 2020-03-25
@caramingo

In the rules below there is no division into tcp or udp, they need to be finalized :)
I did something like this
Forwarding traffic to another server from 192.168.1.15 to 192.168.1.61
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.15 -j DNAT - -to-destination 192.168.1.61
iptables -t nat -A POSTROUTING -p tcp --dst 192.168.1.61 -j SNAT --to-source 192.168.1.15
With ports from 192.168.1.15:80 to 192.168.1.61:8080
iptables - t nat -A PREROUTING -p tcp -d 192.168.1.15 --dport 80 -j DNAT --to-destination 192.168.1.61:8080
iptables -t nat -A POSTROUTING -p tcp --dst 192.168.1.61 --dport 8080 -j SNAT --to-source 192.168.1.15

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question