#!/bin/sh # -*- mode: sh; tab-width: 8; coding: utf-8-unix -*- # https://unix.stackexchange.com/questions/293304/using-netcat-for-port-forwarding . /usr/local/bin/usr_local_tput.bash || exit 2 prog=$( basename $0 .bash ) PREFIX=/usr/local ROLE=proxy netstat -nlpe4 | grep -q 127.0.0.1:53 && { ERROR 127.0.0.1:53 already bound exit 1 } MODE=$( /usr/local/bin/proxy_ping_lib.bash proxy_whonix_mode ) if [ "$MODE" = tor -o "$MODE" = tor -o "$MODE" = gateway -o "$MODE" = selektor ] ; then socat udp-l:53,bind=127.0.0.1,fork,reuseaddr udp:127.0.0.1:9053 elif [ "$MODE" = whonix -o "$MODE" = ws -o "$MODE" = tor -o "$MODE" = selektor ] ; then socat udp-l:53,bind=127.0.0.1,fork,reuseaddr udp:10.0.2.2:9053 fi