#!/bin/bash # git clone https://github.com/mt08xx/vgc.git # http://qiita.com/mt08/private/01f57f8a6658922755b3 IF_to=$1 IF_from=wlan0 if [ -z $IF_to ];then if ! pidof openvpn; then IF_to=eth0 else IF_to=tun0 fi fi echo $IF_from to $IF_to sudo iptables -F sudo iptables -t nat -F sudo iptables -t nat -A POSTROUTING -o $IF_to -j MASQUERADE sudo iptables -A FORWARD -i $IF_to -o $IF_from -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i $IF_from -o $IF_to -j ACCEPT