When you have two routers on different subnets (192.168.0.0/24 and 192.168.2.0/24) each with their own WAN connection, devices can't naturally communicate across subnets. Your unexpected discovery about the printer suddenly working indicates some auto-discovery protocol (likely mDNS/Bonjour) temporarily bridged the gap, but this isn't reliable for all services.
Option 1: Static Routes (Recommended)
On your Vilfo router running LEDE:
# SSH into the router
ssh root@192.168.0.1
# Add static route to 192.168.2.0/24
uci add network route
uci set network.@route[-1].interface='lan'
uci set network.@route[-1].target='192.168.2.0'
uci set network.@route[-1].netmask='255.255.255.0'
uci set network.@route[-1].gateway='192.168.2.1'
uci commit
/etc/init.d/network restart
On the D-Link router:
# Web interface path:
Advanced > Routing > Add New
Destination: 192.168.0.0
Netmask: 255.255.255.0
Gateway: 192.168.0.1
Interface: LAN
Option 2: VLAN Bridging (Advanced)
For your Vilfo router's /etc/config/network:
config device
option name 'eth0.2'
option type '8021q'
option ifname 'eth0'
option vid '2'
config interface 'vlan2'
option ifname 'eth0.2'
option proto 'static'
option ipaddr '192.168.2.254'
option netmask '255.255.255.0'
Option 3: Dedicated Routing Device
Using your spare router as a dedicated router between subnets:
# Example OpenWRT configuration
config interface 'lan1'
option ifname 'eth0'
option proto 'static'
option ipaddr '192.168.0.254'
option netmask '255.255.255.0'
config interface 'lan2'
option ifname 'eth1'
option proto 'static'
option ipaddr '192.168.2.253'
option netmask '255.255.255.0'
config route
option interface 'lan1'
option target '192.168.2.0'
option netmask '255.255.255.0'
option gateway '192.168.2.1'
Verify routes after configuration:
ip route show
traceroute 192.168.2.100
arp -an
Test connectivity:
ping -c 4 192.168.2.100
nc -zv 192.168.2.100 9100 # Test printer port
Add firewall rules to control cross-subnet traffic:
# Vilfo firewall example
uci add firewall rule
uci set firewall.@rule[-1].name='Allow-Printer'
uci set firewall.@rule[-1].src='lan'
uci set firewall.@rule[-1].dest='lan'
uci set firewall.@rule[-1].dest_ip='192.168.2.100'
uci set firewall.@rule[-1].target='ACCEPT'
uci commit
/etc/init.d/firewall restart
Interestingly, simply connecting LAN ports between routers with different subnets (192.168.0.1 and 192.168.2.1) eventually established communication after 30 minutes - evidenced by the Vilfo router detecting the printer on the D-Link subnet. This suggests some automatic route propagation occurred, but let's examine proper configuration methods.
When dealing with multiple routers on different subnets, these key elements must be addressed:
- Static route configuration
- Proper gateway assignments
- Firewall rules permitting inter-subnet traffic
- Potential NAT considerations
For consistent connectivity, manually configure routes on both routers. On the Vilfo (OpenWRT/LEDE):
uci add network route
uci set network.@route[-1].interface='lan'
uci set network.@route[-1].target='192.168.2.0'
uci set network.@route[-1].netmask='255.255.255.0'
uci set network.@route[-1].gateway='192.168.0.2' # Assuming D-Link LAN IP is .0.2
uci commit
/etc/init.d/network restart
On the D-Link router web interface:
- Navigate to Advanced > Routing
- Add static route for 192.168.0.0/255.255.255.0 via 192.168.2.2 (Vilfo LAN IP)
On OpenWRT/Vilfo, edit /etc/config/firewall:
config zone
option name 'lan_interconnect'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
option network 'lan wan' # Include both interfaces
For simpler setups, configure the D-Link as an access point:
# On D-Link:
1. Disable DHCP server
2. Set LAN IP to 192.168.0.2
3. Connect LAN port to Vilfo LAN port
4. Configure wireless settings as needed
Essential diagnostic tools:
# Check routing tables
ip route show
# Test connectivity
traceroute 192.168.2.100
# Check ARP resolution
arp -an
The initial success suggests these factors may have enabled automatic routing:
- UPnP enabling temporary routes
- IGMP multicast propagation
- Router firmware-specific features