Ich weiß nicht wie du das meinst, aber ich will das der PI ganz normal zuhause im LAN-Netzwerk online ist. So ist es ja auch, der PI ist im LAN verbindet sich dann über das Internet mit dem OpenVPN-Server, dann bekommt er eine durch den Tunnel eine neue IP. Soweit habe ich auch alles, aber jetzt möchte ich, dass der PI auch versteht das er sich nur zum OpenVPN ohne Tunnelverbindung verinden darf und danach keine Internetverbindung mehr ohne Tunnel bzw. ohne die VPN-IP mehr aufnehmen darf.
Die IP vom VPN ist übrigens immer die selbe.
Also wäre es doch so
Code:
ROUTER <-> PI <-> VPN-SERVER <-> PI (tun0) <-> INTERNET
so ist es auch momentan.
Und das sollte überhaupt nicht mehr erlaubt sein
Code:
ROUTER <-> PI <-> INTERNET
Eigentlich scheinen diese Regeln doch nah dran zu sein oder?
Code:
#!/bin/bash
# Set your LAN subnet here
LANIP='192.168.1.0/24'
# Set the allowed destination IP (or IP range), port and protocol
DSTIP='8.8.8.8/32'
DSTPORT='1194'
DSTPROT='udp'
# flush all previous rules (reset iptables)
iptables -F
# drop INPUT and FORWARD if not matched (-P stands for policy, we're setting the default policy to DROP the packet if nothing below is matched)
iptables -P INPUT DROP
iptables -P FORWARD DROP
# allow established sessions and localhost traffic (many programs rely on localhost connections)
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -s 127.0.0.0/8 -d 127.0.0.0/8 -i lo -j ACCEPT
# allow LAN traffic and traffic going to the VPN
iptables -A OUTPUT -d $LANIP -j ACCEPT
iptables -A OUTPUT -d $DSTIP -p $DSTPROT -m $DSTPROT --dport $DSTPORT -j ACCEPT
# drop everything else (on the real devices)
iptables -A OUTPUT -o wlan0 -j DROP
iptables -A OUTPUT -o eth0 -j DROP
Lesezeichen