Last active
November 7, 2024 09:40
-
-
Save drmalex07/1b8160f6c1761028dfff6c68d1d38156 to your computer and use it in GitHub Desktop.
Revisions
-
drmalex07 revised this gist
Feb 20, 2020 . 2 changed files with 28 additions and 40 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,30 +1,23 @@ #!/bin/bash set -e listen_iface=${1} listen_port=${2} target_host=${3} target_port=${4} # Check non-empty [[ -n "${listen_iface}" ]] [[ -n "${listen_port}" ]] [[ -n "${target_host}" ]] [[ -n "${target_port}" ]] # Check that ports is actually numbers [[ ${listen_port} -eq ${listen_port} ]] [[ ${target_port} -eq ${target_port} ]] listen_address=$(ip -f inet addr show dev ${listen_iface} | grep -Po 'inet \K[\d.]+') [[ -n "${listen_address}" ]] echo " == Forwarding ${listen_address}:${listen_port} -> ${target_host}:${target_port} == " # Socat 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,28 +1,23 @@ #!/bin/bash set -e listen_iface=${1} listen_port=${2} target_host=${3} target_port=${4} # Check non-empty [[ -n "${listen_iface}" ]] [[ -n "${listen_port}" ]] [[ -n "${target_host}" ]] [[ -n "${target_port}" ]] # Check that ports is actually numbers [[ ${listen_port} -eq ${listen_port} ]] [[ ${target_port} -eq ${target_port} ]] listen_address=$(ip -f inet addr show dev ${listen_iface} | grep -Po 'inet \K[\d.]+') [[ -n "${listen_address}" ]] echo " == Forwarding ${listen_address}:${listen_port} -> ${target_host}:${target_port} == " # Socat -
drmalex07 revised this gist
Feb 20, 2020 . 2 changed files with 2 additions and 0 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 @@ -2,6 +2,7 @@ # Forward to an IPv6 address # Change me! PUBLIC_IP4_IFACE=eth2 LISTEN_IFACE=${PUBLIC_IP4_IFACE} 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,5 +1,6 @@ #!/bin/bash # Change me! PUBLIC_IP4_IFACE=eth2 LISTEN_IFACE=${PUBLIC_IP4_IFACE} -
drmalex07 revised this gist
Feb 20, 2020 . 2 changed files with 30 additions and 0 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,30 @@ #!/bin/bash # Forward to an IPv6 address 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 TCP6:[${target_host}]:${target_port} File renamed without changes. -
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}