iptables Einstellungen für Tunnel.

Post new topic   Reply to topic    DD-WRT Forum Index -> Allgemeine Fragen
Author Message
Hirnfraß
DD-WRT Novice


Joined: 07 Mar 2014
Posts: 10

PostPosted: Fri Mar 21, 2014 20:55    Post subject: iptables Einstellungen für Tunnel. Reply with quote
Hi.
Ich habe ein Neatgear WNDR3700v1 mit der DD-WRT built 21061. Diese ist über WAN mit dem LAN-Port meiner Fritzbox verbunden. Jetzt möchte ich, dass der ganze Datenverkehr des DD-WRT-Routers nur noch über den Tunnel online kommt, den ich über OpenVPN aufbaue. Wenn die Verbindung zum Tunnel abbricht, sollen also keine Daten mehr fließen, bis die Verbindung wieder steht.
Da ich mich mit iptables nicht auskenne, weiß ich auch nicht welche Einstellungen ich vornehmen muss.
WLAN+LAN bridge müsste br0 sein.

iptables -I FORWARD -i br0 -o tun0 -j ACCEPT
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE" > openvpn-up.sh


Das sind die bisherigen Einstellungen, die in dem Startup-Script meines VPN-Providers schon gesetzt wurden, diese dienen ja glaube ich auch nur dazu, dass der Tunnel aufgebaut wird. Ich war jetzt schon mehrmals mit der IP meines ISP und nicht die des Tunnels online. Immer nach 24h disconnect. Wie setze ich die Firewall Einstellung bei iptables, damit ich nur noch über den Tunnel surfe?
Wenn ihr mehr Daten aus dem OpenVPN Startup-Skript braucht, lasst es mich wissen.

Ich will das br0 nur online geht, wenn tun+ aktiv und will das br0 dann über schnittstelle tun+ online geht und nur wenn tun+ aktiv ist, Daten raus aus dem Netzwerk kommen. Connection zum Aufbau des Tunnels läuft über TCP 443.

Mfg Hirnfraß


Last edited by Hirnfraß on Sun Mar 23, 2014 21:16; edited 1 time in total
Sponsor
Hirnfraß
DD-WRT Novice


Joined: 07 Mar 2014
Posts: 10

PostPosted: Sun Mar 23, 2014 21:08    Post subject: Reply with quote
Code:
#Erlaubt Loopback-Schnittstelle (für eigene Anwendungen)
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

#Erlaubt Datenverkehr im eigenen Netzwerk
iptables -A INPUT -s 192.168.1.0/24 -j ACCEPT
iptables -A OUTPUT -d 192.168.1.0/24 -j ACCEPT

#Erlaubt die Verbindung zum VPN-Dienst
iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --sport 443 -j ACCEPT

#Akzeptiert Datenverkehr über VPN/tun-Schnittstellen.
iptables -A OUTPUT -o tun+ -j ACCEPT
iptables -A INPUT -i tun+ -j ACCEPT

#Routing von br0 ins Tunnelinterface
iptables -I FORWARD -i br0 -o tun0 -j ACCEPT

#NAT fürs Tunnelinterface einstellen
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE" > openvpn-up.sh

#Verwirft alle anderen Verbindungen bis auf die vorher geregelten.
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP


Ist das soweit richtig oder funktioniert das doch etwas anders? Ich bitte um Hilfe. Oder funktionieren die Regeln nicht, weil ja noch kein TUN existiert beim Abruf der Regeln?
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Allgemeine Fragen All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum