IP_REMOTO="192.168.0.250" IP_VPN_REMOTO="10.0.0.1" IP_VPN_LOCAL="10.0.0.2" IP_REDE_REMOTA="192.168.0.0" MASQ_REDE_REMOTA="255.255.255.0" IP_REDE_LOCAL="192.168.1.0" MASQ_REDE_LOCAL="255.255.255.0" if [ $1 = "stop" ] then iptables -D INPUT -j ACCEPT -p udp -s $IP_REMOTO --dport 5000 >/dev/null 2>/dev/null iptables -D FORWARD -j ACCEPT -i tun0 >/dev/null 2>/dev/null iptables -D FORWARD -j ACCEPT -o tun0 >/dev/null 2>/dev/null killall openvpn fi # Gerar chave secreta (deve ser igual nas duas pontas) # openvpn --genkey --secret /etc/openvpn/secret # Permitir estabelecimento do tunel VPN iptables -I INPUT -j ACCEPT -p udp -s $IP_REMOTO --dport 5000 # Estabelecer o tunel VPN (na outra ponta modifica apenas as variaveis) #openvpn --remote $IP_REMOTO --dev tun1 --ifconfig $IP_VPN_LOCAL $IP_VPN_REMOTO --verb 5 --secret /etc/openvpn/secret & openvpn --config /etc/openvpn/filial.conf --daemon # Permitir trafego pela VPN iptables -I FORWARD -j ACCEPT -i tun0 iptables -I FORWARD -j ACCEPT -o tun0 # Adicionando as rotas da VPN route add -net $IP_REDE_REMOTA netmask $MASQ_REDE_REMOTA gw $IP_VPN_REMOTO