Skip to content

Commit

Permalink
openvpn.sh actually fix dperson#284
Browse files Browse the repository at this point in the history
  • Loading branch information
David Personette committed May 2, 2020
1 parent 3f25a7f commit aee6c4b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions openvpn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,20 @@ vpn() { local server="$1" user="$2" pass="$3" port="${4:-1194}" proto=${5:-udp}\
# protocol) optional protocol (defaults to TCP)
# Return: configured NAT rule
vpnportforward() { local port="$1" protocol="${2:-tcp}"
ip6tables -t nat -A OUTPUT -i tap+ -p $protocol --dport $port -j DNAT \
--to-destination ::11:$port 2>/dev/null &&
ip6tables -t nat -A OUTPUT -i tun+ -p $protocol --dport $port -j DNAT \
--to-destination ::11:$port 2>/dev/null ||
ip6tables -t nat -A OUTPUT -p $protocol --dport $port -j DNAT \
--to-destination ::11:$port 2>/dev/null
ip6tables -A INPUT -p $protocol -m $protocol --dport $port -j ACCEPT \
2>/dev/null
ip6tables -A FORWARD -i tun0 -p $protocol -m $protocol --dport $port -j \
ACCEPT 2>/dev/null
iptables -t nat -A OUTPUT -i tap+ -p $protocol --dport $port -j DNAT \
--to-destination 127.0.0.11:$port 2>/dev/null &&
iptables -t nat -A OUTPUT -i tun+ -p $protocol --dport $port -j DNAT \
--to-destination 127.0.0.11:$port 2>/dev/null ||
iptables -t nat -A OUTPUT -p $protocol --dport $port -j DNAT \
--to-destination 127.0.0.11:$port
iptables -A INPUT -p $protocol -m $protocol --dport $port -j ACCEPT
Expand Down

0 comments on commit aee6c4b

Please sign in to comment.