Hello everyone,
I am hoping someone already ran into inter vlan routing issues and resolved it and I can get to know the fix or missing configuration.
\
-
RPI 4B running latest dietPi version. Have wireless disabled, so only eth0 is working. Usual stuff like Pi-hole and PiVPN works as well. DHCP scope thru the Pi-Hole works as well.
-
Added a subinterface (VLAN) eth.120 and corresponding dhcp scope via dnsmasq to listen to this tagged dhcp request on vlan 120. This works as well. Client connected to this vlan ( via a wireless AP with SSID mapped to this vlan 120) obtains the IP address from this vlan 120 dhcp scope set up on the RPi.
-
default route is thru the eth0 to get to internet. VLAN interface has only IP and subnet mask.
Here are the steps that I followed for this vlan part:
apt install vlan
echo 8021q >> /etc/modules
lsmod | grep 8021q (checks out good)
nano /etc/sysctl.conf
remove comment from (this is already done on my box as I am using IP forwarding for VPN client to be able to traverse the RPi and get to inside network, but listing here for completeness of vlan setup)
#net.ipv4.ip_forward=1
save
nano /etc/network/interfaces.d/vlans
add below
auto eth0.120
iface eth0.120 inet static
address 10.10.120.1
netmask 255.255.254.0
vlan-raw-device eth0
Save
service networking restart
verify presence of new interface and IP via following:
Hostname -I
ifconfig
route -n (shows default route thru eth0 and two connected routes for eth0 and eth0.120 subnet as should be the case).
Add dhcp scope via dnsmasq
nano /etc/dnsmasq.d/120-vlan-dhcp.conf
dhcp-range=set:120,10.10.120.2,10.10.121.254,255.255.254.0,20m
dhcp-option=tag:120,option:router,10.10.120.1
dhcp-option=tag:120,6,192.168.2.34
save
At this time, I attach RPi to a managed VLAN switch with switch port set to tag vlan 120 and untag on default vlan 1 (default vlan 1 is where the main eth0 IP of RPi is). I then create another similar port on switch and connect the Wireless AP. Wireless AP obtains dhcp IP address from the vlan 1 and comes online. I then create a SSID on the AP with the egress traffic mapped to vlan 120. The client connects to this SSID and is successful in getting IP address in vlan 120 from dhcp scope for this vlan set up on the RPi. So we know VLANs are working.
Then I try to do some pings:
ping 192.168.2.34 (works and this is the RPI eth0 / vlan 1 untagged Ip address).
ping 10.10.120.1 (works and this is the RPI eth0.120 / vlan ip address)
ping -I eth0 192.168.2.34 ( works of course)
ping -I eth0.120 10.10.120.1 (does not work).
The client gets ip address in 10.10.120.0/23 subnet but also cannot ping its gateway 10.10.120.1.
So something is broken that client on the same subnet / vlan cannot ping the gateway and the router (RPi) itself cannot ping its own vlan interface.
I have ufw firewall installed but is disabled for now.
My next step after making this local (inter vlan) routing / forwarding work is to then approach the NAT side via ufw / iptables masquerading. eth0.120 will be the LAN side and eth0 will be acting as WAN / Internet side to which 10.10.120.x traffic will be natted.
MichaIng and Joulinar , your expertise is needed here please.
Thanks and very best