-
-
Save tuxfight3r/99cb1a82449847cd5dd37d031fb48f95 to your computer and use it in GitHub Desktop.
Revisions
-
drmalex07 revised this gist
Jun 26, 2018 . 2 changed files with 28 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ #!/bin/bash PUBLIC_IP4_IFACE=eth2 LISTEN_IFACE=${PUBLIC_IP4_IFACE} listen_address=$(ip -f inet addr show dev ${LISTEN_IFACE} | grep -Po 'inet \K[\d.]+') listen_port=${1} target_host=${2} target_port=${3} if [ -z "${listen_port}" ]; then echo "${0} <listen-port> <target-host> <target-port>" && exit 1; fi if [ -z "${target_host}" ]; then echo "${0} <listen-port> <target-host> <target-port>" && exit 1; fi if [ -z "${target_port}" ]; then echo "${0} <listen-port> <target-host> <target-port>" && exit 1; fi # Test that ports is actually numbers [[ ${listen_port} -eq ${listen_port} ]] [[ ${target_port} -eq ${target_port} ]] echo " == Forwarding ${listen_address}:${listen_port} -> ${target_host}:${target_port} == " # Socat socat -d -d TCP4-LISTEN:${listen_port},bind=${listen_address},su=nobody,fork,reuseaddr TCP4:${target_host}:${target_port} This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +0,0 @@ -
drmalex07 revised this gist
May 24, 2018 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,6 @@ #!/bin/bash LISTEN_ADDRESS=1.2.3.4 LISTEN_PORT=10022 TARGET_HOST=app.localdomain -
drmalex07 revised this gist
May 24, 2018 . No changes.There are no files selected for viewing
-
drmalex07 created this gist
May 24, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ #!/bin/bash PUBLIC_IP4_ADDRESS=1.2.3.4 LISTEN_ADDRESS=${PUBLIC_IP4_ADDRESS} LISTEN_PORT=10022 TARGET_HOST=app.localdomain TARGET_PORT=22 socat -d -d TCP4-LISTEN:${LISTEN_PORT},bind=${LISTEN_ADDRESS},su=nobody,fork,reuseaddr TCP4:${TARGET_HOST}:${TARGET_PORT}