markus0815
New Member
Hi,
ich habe mir einen kleinen Raspberry Pi 3 genommen und habe aus dem einen VPN-Router gebaut.
Eth0 steckt an meiner Fritzbox.
Eth1 steckt ein anderer PC dran, der über VPN ins Internet gehen soll.
Ich hab mich mal mit dem Thema IPTABLES beschäftigt aber irgendwie komme ich hier nicht so ganz weiter.
Habe diesen Code hier verwendet und alles ist gut.
Nun habe ich hier im Forum was über Ports gelesen, die man freischalten muss wenn man nicht alles Durchlassen will.
Mein Code dazu:
Achtung viel viel und mehr...
ich habe mir einen kleinen Raspberry Pi 3 genommen und habe aus dem einen VPN-Router gebaut.
Eth0 steckt an meiner Fritzbox.
Eth1 steckt ein anderer PC dran, der über VPN ins Internet gehen soll.
Ich hab mich mal mit dem Thema IPTABLES beschäftigt aber irgendwie komme ich hier nicht so ganz weiter.
Habe diesen Code hier verwendet und alles ist gut.
Code:
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
iptables -A FORWARD -i tun0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth1 -o tun0 -j ACCEPT
Nun habe ich hier im Forum was über Ports gelesen, die man freischalten muss wenn man nicht alles Durchlassen will.
Mein Code dazu:
Achtung viel viel und mehr...
Code:
#!/bin/bash
#--Internet--Fritzbox ---192.168.10.0/24--- eth0-VPN-Router-eth1 ----192.168.200.0/24--- PC
# |
# |
# |--- 192.168.10.116--- NAS
#
#
#
# 192.168.10.0/24 Lan hinter Fritzbox
# 192.168.200.0/24 Lan hinter VPN-Router
iptables="/sbin/iptables"
ip6tables="/sbin/ip6tables"
echo "Regeln löschen"
$iptables -X
$iptables -F
$iptables -t nat -X
$iptables -t nat -F
echo "Default Drop"
$iptables -P INPUT -j DROP
$iptables -P OUTPUT -j DROP
$iptables -P FORWARD -j DROP
$ip6tables -P INPUT -j DROP
$ip6tables -P OUTPUT -j DROP
$ip6tables -P FORWARD -j DROP
echo "Connection Tracking"
$iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
$iptables -A FORWARD -m conntrack --ctstate=INVALID -j DROP
$iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -m conntrack --ctstate=INVALID -j DROP
$iptables -A OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -m conntrack --ctstate=INVALID -j DROP
echo "Output"
$iptables -A OUTPUT -o eth0 -p tcp --dport=53 -j ACCEPT
$iptables -A OUTPUT -o eth0 -p tcp --dport=80 -j ACCEPT
$iptables -A OUTPUT -o eth0 -p tcp --dport=21 -j ACCEPT
$iptables -A OUTPUT -o eth0 -p tcp --dport=443 -j ACCEPT
echo "Output VPN - Ports"
$iptables -A OUTPUT -p UDP -o tun0 --dport=148 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p UDP -o tun0 --dport=149 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p UDP -o tun0 --dport=150 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p UDP -o tun0 --dport=151 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p UDP -o tun0 --dport=1148 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p UDP -o tun0 --dport=1149 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p UDP -o tun0 --dport=1150 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p UDP -o tun0 --dport=1151 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p UDP -o tun0 --dport=1194 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p TCP -o tun0 --dport=1194 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p TCP -o tun0 --dport=300 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p TCP -o tun0 --dport=301 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p TCP -o tun0 --dport=142 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p TCP -o tun0 --dport=152 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p TCP -o tun0 --dport=1142 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p TCP -o tun0 --dport=1152 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p TCP -o tun0 --dport=53 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p TCP -o tun0 --dport=80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p TCP -o tun0 --dport=443 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A OUTPUT -p TCP -o tun0 --dport=21 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
echo "Input VPN - Ports"
$iptables -A INPUT -p UDP -i tun0 --sport=148 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p UDP -i tun0 --sport=149 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p UDP -i tun0 --sport=150 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p UDP -i tun0 --sport=151 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p UDP -i tun0 --sport=1148 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p UDP -i tun0 --sport=1149 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p UDP -i tun0 --sport=1150 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p UDP -i tun0 --sport=1151 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p UDP -i tun0 --dport=1194 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p TCP -i tun0 --dport=1194 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p TCP -i tun0 --sport=300 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p TCP -i tun0 --sport=301 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p TCP -i tun0 --sport=142 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p TCP -i tun0 --sport=152 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p TCP -i tun0 --sport=1142 -m state --state ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -p TCP -i tun0 --sport=1152 -m state --state ESTABLISHED,RELATED -j ACCEPT