Enviado em 13/05/2018 - 21:27h
Olá gurizada,#!/bin/bash
# Interface da Internet:
ifinternet="ens33"
iflocal="ens32"
iptables -F
iptables -F -t nat
#permite roteamento
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
#libera internet para as outras placas de rede
iptables -t nat -A POSTROUTING -o $ifinternet -j MASQUERADE
#bloqueia requisição da rede local para internet
iptables -A FORWARD -i $iflocal -o $ifinternet -j DROP
#libera acesso da vpn na rede local
iptables -t nat -A POSTROUTING -s 10.8.0.0/8 -o $ifinternet -j MASQUERADE
#libera porta vpn
#iptables -I INPUT -i $ifinternet -p udp --dport 1194 -j ACCEPT
#iptables -A FORWARD -p udp --dport 1194 -j ACCEPT
#iptables -t nat -I PREROUTING -p udp -i ens33 -m multiport --dport 1194 -j DNAT --to 192.168.0.109
#iptables -t nat -A PREROUTING -i $ifinternet -p udp -s 0.0.0.0/0 --dport 1194 -d 192.168.0.1 -j DNAT --to 192.168.0.109:1194
#iptables -t nat -A POSTROUTING -s 192.168.0.109 -o $iflocal -p udp --sport 1194 -j SNAT --to 192.168.0.1
#iptables -A OUTPUT -p udp -i ens33 --dport 1194 -s 192.168.0.109 -j ACCEPT
#iptables -A INPUT -p udp --dport 1194 -j ACCEPT
#iptables -A FORWARD -i tun0 -o $ifinternet -j ACCEPT
#iptables -A FORWARD -i tun0 -o $iflocal -j ACCEPT
#iptables -A INPUT -p udp -i $ifinternet --dport 1194 -j ACCEPT
#testes
#iptables -t filter -A INPUT -p udp --dport 1194 -j ACCEPT
#iptables -t filter -A FORWARD -p udp -s 192.168.2.0/24 --dport 1194 -j ACCEPT
#iptables -t filter -A FORWARD -p udp -d 192.168.2.0/24 --sport 1194 -j ACCEPT
#iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -d 10.8.0.0/8 -j ACCEPT
#iptables -t nat -A POSTROUTING -d 192.168.2.0/24 -s 10.8.0.0/8 -j ACCEPT
#iptables -t nat -I POSTROUTING -s 10.8.0.0/8 -o eth1 -j MASQUERADE
iptables -t nat -p udp -I PREROUTING -s 0/0 -d 192.168.0.109 --dport 1194 -j DNAT --to 192.168.2.1
iptables -I FORWARD -p udp --dport 1194 -j ACCEPT