Skip to content

Instantly share code, notes, and snippets.

@pgiu
Created April 22, 2016 18:07
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 pgiu/4e9ca46deedf9481e52acad5a7e3e6a3 to your computer and use it in GitHub Desktop.
Save pgiu/4e9ca46deedf9481e52acad5a7e3e6a3 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Como hacer un proxy con netcat
# Correr esto en una maquina intermedia
#
# yo ---> maquina_intermedia ---> maquina_destino
# Desde mi maquina conecto al puerto $listening_port y el servicio que quiero de
# la maquina destino en $dest_host y puerto $dest_port
#
# correrlo así:
# proxy_kong.sh 151.168.0.9 20000
# donde 152.168.0.9 es la RTU real
# y 2000 es el puerto de la RTU
# El script se queda escuchando en $listening_port
#
dest_host=$1
dest_port=$2
listening_port=5000
mkfifo afifo
nc -l $listening_port 0<afifo | nc $dest_host $dest_port 1>afifo
@pgiu
Copy link
Author

pgiu commented Apr 22, 2016

tested on ubuntu 14.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment