This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| docu:csheet:net:iptables:port_redirection [2020/02/06 23:27] – external edit 127.0.0.1 | docu:csheet:net:iptables:port_redirection [2020/07/19 22:32] (current) – admin | ||
|---|---|---|---|
| Line 12: | Line 12: | ||
| <code bash> | <code bash> | ||
| # syntax | # syntax | ||
| + | iptables -t nat -A PREROUTING -d [IN_IP] -p tcp --dport 3456 -j DNAT --to-destination 2.2.2.2: | ||
| iptables -t nat -A OUTPUT -d [IN_IP] -p tcp --dport [PORT] -j DNAT --to-destination [TO_IP]: | iptables -t nat -A OUTPUT -d [IN_IP] -p tcp --dport [PORT] -j DNAT --to-destination [TO_IP]: | ||
| # example: | # example: | ||
| iptables -t nat -A OUTPUT -d 127.0.0.1 -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1: | iptables -t nat -A OUTPUT -d 127.0.0.1 -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1: | ||
| + | |||
| + | # nat 1:1 port from public to private IP space | ||
| + | iptables -t nat -A POSTROUTING -j MASQUERADE | ||
| + | iptables -t nat -A PREROUTING -d [A_PUBLIC_IP] -p tcp --dport 222 -j DNAT --to-destination [LAN_IP]:22 | ||
| </ | </ | ||