Auf einem Pi4 habe ich PiHole und OpenVPN (mit einem Account bei NordVPN) installiert. Beide Installationen funktionieren für sich einwandfrei (PiHole filtert, OpenVPN-Verbindung wird aufgebaut und steht; anhand der Prüfung mit "wget http://ipinfo.io/ip -qO -" sehe ich, dass dem VPN eine IP von NordVPN zugewiesen wurde). Der Internet-Verkehr aller Clients wird über PiHole gefiltert, ABER nicht über die VPN-Verbindung geroutet. Nachdem ich nun tagelang unendlich viele iptable-Einträge erfolglos ausprobiert habe, versuche ich hier eine Lösung zu finden.
Kann mir bitte jemand Vorschläge machen, welche das Routing zwischen eth0 und tun0 zum funktionieren bringen und der ganze Internet-Verkehr über die VPN-Verbindung geht UND mit PiHole gefiltert wird.
Herzlichen Dank im Voraus.
Hier meine iptable und die Routingeinträge:
Mein internes Netz 10.0.0.0/24
Mein Router 10.0.0.1 / 255.255.255.0
PiHole / OpenVPN: 10.0.0.82
sudo sysctl -p /etc/sysctl.conf
net.ipv4.ip_forward = 1
route
Kernel IP routing table PiHole
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.8.1.1 128.0.0.0 UG 0 0 0 tun0
default 10.0.0.1 0.0.0.0 UG 202 0 0 eth0
10.0.0.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0
10.8.1.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
37.120.213.107 10.0.0.1 255.255.255.255 UGH 0 0 0 eth0
128.0.0.0 10.8.1.1 128.0.0.0 UG 0 0 0 tun0
sudo iptables -L -v -n
Chain INPUT (policy ACCEPT 77632 packets, 7926K bytes)
pkts bytes target prot opt in out source destination
2392 126K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 ctstate NEW,ESTABLISHED
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- tun0 eth0 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 ACCEPT all -- eth0 tun0 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 60484 packets, 4325K bytes)
pkts bytes target prot opt in out source destination
1850 379K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp spt:22 ctstate ESTABLISHED
2327 931K ACCEPT all -- * tun0 0.0.0.0/0 0.0.0.0/0 /* vpn */
2 188 ACCEPT icmp -- * eth0 0.0.0.0/0 0.0.0.0/0 /* icmp */
7882 4633K ACCEPT all -- * eth0 0.0.0.0/0 10.0.0.0/24 /* lan */
2515 1072K ACCEPT udp -- * eth0 0.0.0.0/0 0.0.0.0/0 udp dpt:1194 /* allow vpn traffic */
0 0 ACCEPT udp -- * eth0 0.0.0.0/0 0.0.0.0/0 udp dpt:123 /* ntp */
sudo iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- anywhere anywhere
MASQUERADE all -- anywhere anywhere
MASQUERADE all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.82 netmask 255.255.255.0 broadcast 10.0.0.255
inet6 fe80::a977:2af1:5cfd:c6b4 prefixlen 64 scopeid 0x20<link>
ether dc:a6:32:47:b9:91 txqueuelen 1000 (Ethernet)
RX packets 20615 bytes 3748702 (3.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14880 bytes 6767313 (6.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 65245 bytes 4620454 (4.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 65245 bytes 4620454 (4.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 10.8.1.8 netmask 255.255.255.0 destination 10.8.1.8
inet6 fe80::a07b:8d06:c73a:ccff prefixlen 64 scopeid 0x20<link>
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 100 (UNSPEC)
RX packets 390 bytes 163098 (159.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 446 bytes 229680 (224.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0