Pergunta

I want redirect all outgoing traffic with port 8080 to local port 8080

for example i create server with this command nc -l -p 8080 and i want when use this command nc 1.2.3.4 8080 , nc redirect and connect to 127.0.0.1:8080

i try with this command:

iptables -t nat -A POSTROUTING -p tcp --dport 80 -o eth0 -j SNAT --to-source IP

but not worked!

how to do it?

Foi útil?

Solução

Local originated traffic isn't passing through nat/POSTROUTING chain. You should add rule like this:

iptables -t nat -A OUTPUT -p tcp --dport 8080 -j DNAT --to-destination 127.0.0.1:8080

Additional info:

  1. http://upload.wikimedia.org/wikipedia/commons/3/37/Netfilter-packet-flow.svg
  2. http://www.linuxtopia.org/Linux_Firewall_iptables/index.html Chapter 4.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top