I am configuring a Raspberry Pi to route traffic from a specific VLAN through a VPN, but I am encountering routing issues. Here’s an overview of my setup and the problems I'm facing:
Setup:
- Raspberry Pi
- Managed Switch
- PC connected to the switch.
PC, RPI are intended to be in one VLAN 10. The traffic from PC should be routed via RPI
RPI setup
Network Interfaces:
- eth0: Connected to a local network, IP 192.168.100.27/24
- tun0: VPN interface, which is set as the default route for all outbound traffic, gateway 10.0.0.1
- eth0.10: VLAN 10 interface with IP 192.168.10.1/24
Goal: Route all traffic from the VLAN 10 (192.168.10.0/24 network) exclusively through the VPN on the tun0 interface.
Current Configuration & Issue:
I have configured split tunneling for the VPN with routes 0.0.0.0/1 and 128.0.0.0/1 via 10.0.0.1 on tun0.
Attempts to configure routing to let traffic from eth0.10 use tun0 result in the error: "Nexthop has invalid gateway."
Direct pings from eth0.10 to 10.0.0.1 or to external IPs such as 8.8.8.8 fail, suggesting an issue with how the traffic is being routed from the VLAN through the VPN.
Specific Challenges:
Unable to route traffic from 192.168.10.0/24 through tun0 effectively. Errors when setting 10.0.0.1 as a gateway for eth0.10, despite tun0 being configured with this gateway for VPN traffic.
Questions:
- How can I ensure that all traffic from VLAN 10 (eth0.10) is correctly routed through the VPN on tun0?
- Are there specific configurations or adjustments needed in iptables or routing tables to facilitate this setup?
Any insights or guidance on how to correctly configure this network setup would be greatly appreciated, particularly any configuration snippets or diagnostic commands that could help resolve these routing issues.