Skip to content

Instantly share code, notes, and snippets.

@toriaezunama
Created April 5, 2018 17:49
Show Gist options
  • Save toriaezunama/5eeb598ddd6c0ca6ee31e6765084ac14 to your computer and use it in GitHub Desktop.
Save toriaezunama/5eeb598ddd6c0ca6ee31e6765084ac14 to your computer and use it in GitHub Desktop.
Use netcat to proxy requests
#!/bin/bash
# From: https://notes.tweakblogs.net/blog/7955/using-netcat-to-build-a-simple-tcp-proxy-in-linux.html
LOCAL_PORT=$1
REMOTE_HOST=$2
REMOTE_PORT=$3
mkfifo fifo
nc -k -l -p $LOCAL_PORT <fifo | nc $REMOTE_HOST $REMOTE_PORT >fifo
rm fifo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment