Skip to content

Instantly share code, notes, and snippets.

@oakaigh
Last active October 3, 2018 06:31
Show Gist options
  • Save oakaigh/ba42daee59bcb9331f24a8963a6cc395 to your computer and use it in GitHub Desktop.
Save oakaigh/ba42daee59bcb9331f24a8963a6cc395 to your computer and use it in GitHub Desktop.
#!/bin/bash
ELTXTOK="http://elitex.w3.ext.caraconnects.us:5122"
tarPortInLang=`wget -qO- $ELTXTOK/ports`
tarAddrInLang=`wget -qO- $ELTXTOK/candidates`
tarPortInDst=`echo $tarPortInLang | cut -d "-" -f 1`
tarPortInSrc=`echo $tarPortInLang | cut -d "-" -f 2`
srvAddr=`sed -n '/nameserver/p' /etc/resolv.conf | head -1`
echo
echo " __ _ __ __ Servicing";
echo " ___ / / (_) /____ / /_ $srvAddr";
echo "/ -_) /__/ / __/ -_) __/ eLitet Inc.";
echo "\__/____/_/\__/\__/\__/ Internet For All.";
echo " ";
echo "eLitex HTTP Extension: Settings Updated..."
echo "Extensión HTTP de eLitex: configuración actualizada..."
echo "Port redirection from $tarPortInDst to $tarPortInSrc that applies to the following:"
echo "Redirección de puerto desde $tarPortInDst a $tarPortInSrc que se aplica a lo siguiente:"
echo
sysctl -w net.ipv4.ip_forward=1
for tarAddr in $tarAddrInLang
do
printf "$tarAddr "
iptables -t nat -A OUTPUT -d $tarAddr -p tcp --dport $tarPortInDst -j DNAT --to-destination $tarAddr:$tarPortInSrc
iptables -t nat -A PREROUTING -d $tarAddr -p tcp --dport $tarPortInDst -j DNAT --to-destination $tarAddr:$tarPortInSrc
done
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment