Browse Source

Add files via upload

MoeClub 5 years ago
parent
commit
8fb1b8236d
1 changed files with 17 additions and 0 deletions
  1. 17 0
      AnyConnect/redirect.sh

+ 17 - 0
AnyConnect/redirect.sh

@@ -0,0 +1,17 @@
+#!/bin/bash
+
+HostName="server.host"
+HostPort="443"
+LocalPort="443"
+LocalIf="eth0"
+
+RemoteHost=`curl -o /dev/null -sSL --connect-timeout 5 --retry-delay 3 --retry 5 -w %{remote_ip} "https://${HostName}:${HostPort}"`
+[ -n "$RemoteHost" ] || exit 1
+
+Forward=`cat /proc/sys/net/ipv4/ip_forward`
+[ "$Forward" != "1" ] && echo "1" >/proc/sys/net/ipv4/ip_forward
+
+iptables -I INPUT -p tcp --dport ${LocalPort} -j ACCEPT
+iptables -t nat -A PREROUTING -p tcp -i ${LocalIf} --dport ${LocalPort} -j DNAT --to-destination ${RemoteHost}:${HostPort}
+iptables -t nat -I POSTROUTING -d ${RemoteHost} -p tcp --dport ${HostPort} -j MASQUERADE
+