Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@icarrr
Created March 26, 2021 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icarrr/065ef744e972b8b2a2c4a7c922f9485a to your computer and use it in GitHub Desktop.
Save icarrr/065ef744e972b8b2a2c4a7c922f9485a to your computer and use it in GitHub Desktop.
Forward port from private network to public port
#!/bin/bash
# sudo iptables -t nat -I POSTROUTING -m comment --comment "NAT the src ip" -d 192.168.42.12 -o ppp0 -j MASQUERADE
sudo iptables -t nat -I POSTROUTING -m comment --comment "NAT the src ip" -d 192.168.42.12 -j MASQUERADE
sudo iptables -I FORWARD -d 192.168.42.12 -m comment --comment "Accept to forward winbox mikrotik traffic" -m tcp -p tcp --dport 800 -j ACCEPT
sudo iptables -I FORWARD -m comment --comment "Accept to forward winbox mikrotik return traffic" -s 192.168.42.12 -m tcp -p tcp --sport 800 -j ACCEPT
sudo iptables -t nat -I PREROUTING -m tcp -p tcp --dport 1001 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 192.168.42.12:800
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment