Advertisement
genBTC

iptables = route forwarded ports, DNAT + MASQUERADE

Apr 5th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #(anything arriving into the box on dport #x, gets NAT'ed over to the local lan IP, same port. then masquerade needed.)
  2.  
  3. #example one.
  4. sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 32401 -j DNAT --to-destination 192.168.0.200:32401
  5. sudo iptables -t nat -A POSTROUTING -p tcp -m tcp -d 192.168.0.200 --dport 32401 -j MASQUERADE
  6. #example two.
  7. sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 1025 -j DNAT --to-destination 10.0.8.1:1025
  8. sudo iptables -t nat -A POSTROUTING -p tcp -m tcp -d 10.0.8.1 --dport 1025 -j MASQUERADE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement