Skip to content

Instantly share code, notes, and snippets.

@nathaniel-security
Created April 28, 2025 19:04
Show Gist options
  • Select an option

  • Save nathaniel-security/dc6165ae26b301f858a749e6a5db8df7 to your computer and use it in GitHub Desktop.

Select an option

Save nathaniel-security/dc6165ae26b301f858a749e6a5db8df7 to your computer and use it in GitHub Desktop.
# Flush old NAT rules if needed
sudo iptables -t nat -F
# Forward all TCP traffic hitting port 2000 on the LAN-facing interface to Cowrie
sudo iptables -t nat -A PREROUTING -i ens33 -p tcp --dport 2000 -j DNAT --to-destination 192.168.237.128:2222
# Allow forwarding
sudo iptables -A FORWARD -p tcp -d 192.168.237.128 --dport 2222 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# Masquerade the packets so they appear to come from the proxy
sudo iptables -t nat -A POSTROUTING -o ens37 -p tcp -d 192.168.237.128 --dport 2222 -j MASQUERADE
sudo iptables -A INPUT -m state --state INVALID -j DROP
sudo iptables -A FORWARD -m state --state INVALID -j DROP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment