I was thinking about an ARM-SBC based setup for OpenWrt with a device with 2 ethernet ports like a NanoPi R3S. The ideia is to retain the ISP router and use it for Wifi / Lan ports and as gateway and use the SBC to manage DHCP, DNS and everything else.
Option A: Here's the configuration:
ISP Router: Disable DHCP + Set Static IP as 192.168.1.1
SBC: Connect LAN port to ISP router LAN 1
SBC: Connect WAN port to ISP router LAN 2
SBC: Set WAN IP as static 192.168.1.2, gateway 192.168.1.1
ISP Router: Set a few forwards from public WAN IP to 192.168.1.2 (this way the SBC will be the entry point for VPN etc).
SBC: enable DHCP on LAN port but restrict to range 192.168.10-192.168.254.
SBC: configure the DHCP to announce the ISP Router (192.168.1.1) as gateway - avoid looping the device traffic from ISP router > SBC > ISP router again.
Now the question is, will this work?
My concern is that both the Openwrt LAN and WAN are on 192.168.1.0/24 and the kernel might mix up packets from both interfaces.
Option B: If this is problematic, what about setting:
SBC: Add an additional route on DHCP so devices can access the ISP router 192.168.1.1 on 192.168.1.0/25.
I look to me that LAN devices will be able to send traffic to the gateway 192.168.1.1 (ISP Router) but the ISP router might get confused while returning a response because it won't have an internal route to 192.168.1.128/25. What if I set the ISP router static IP with the subnet 192.168.1.0/24?
I would like some advice here and what's best and what might or might not work alongside with potential issues.
Update:
I've done a similar setup with another SBC that only has one ethernet port, and it works fine. In that case everything is LAN.
However, I also want to have a group of devices with the SBC IP as gateway so I can filter out some outgoing traffic / apply extra rules. While this would still work on a single port that also means I would be slashing the bandwidth in half.
Final setup would look a bit more like:
PC1 --- switch -----> ISP Router
PC2 -----| | |
| |
SBC LAN ----- |
SBC WAN ------------------|
Eg.
PC1 internet traffic will go straight through the switch and be dispatched by the ISP router.
PC2 internet traffic would go through the switch into the SBC LAN > CPU applies rules > whatever is allowed exists through SBC WAN (potentially NAT from PC2 IP into SBC WAN IP) into ISP router LAN 2.
There's no need to use the WAN connection. Just add the openwrt device to the LAN. When setting DHCP up add the relevant options to pass gateway (192.168.1.1) and DNS (192.168.1.2) to client devices
Yes, I've done that setup with another SBC that only has one ethernet port, and it works fine.
However, I also want to have a group of devices with the SBC IP as gateway so I can filter out some outgoing traffic / apply extra rules. While this would still work on a single port that also means I would be slashing the bandwidth in half.
Final setup would look a bit more like:
PC1 --- switch -----> ISP Router
PC2 -----| | |
| |
SBC LAN ----- |
SBC WAN ------------------|
Eg.
PC1 internet traffic will go straight through the switch and be dispatched by the ISP router.
PC2 internet traffic would go through the switch into the SBC LAN > CPU applies rules > whatever is allowed exists through SBC WAN (potentially NAT from PC2 IP into SBC WAN IP) into ISP router LAN 2.
I can for sure isolate PC2 (and others that go through the SBC) on a VLAN but does that solve the potential issues with the subnet being the same? I still want those machines to be able to access all the other machines on the network.
To be fair I'm not even concerned that PC2 might set the ISP router as default gateway and bypass the outgoing rules, I just wanted it, by default, to work as described without a subnetting mess or network loops.
But it does seem to work on the single-port SBC. The thing only has a LAN software-wise and if I set some machine to use it as default gateway I can then add a bunch of traffic rules:
Here the network is 172.20.1.0/24, the ISP router sits at 172.20.1.254 as static, no DHCP:
config device
option name 'br-lan'
option type 'bridge'
list ports 'eth0'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '172.20.1.1'
option netmask '255.255.255.0'
option gateway '172.20.1.254'
option broadcast '172.20.1.255'
option ip6assign '64'
option delegate '0'
config device
option name 'eth0'
(... dhcp config...)
config dhcp 'lan'
option interface 'lan'
option leasetime '6h'
option dhcpv4 'server'
option start '10'
option limit '100'
list dhcp_option '3,172.20.1.254'
list dhcp_option '6,172.20.1.1'
I believe when a device wants to access the internet and has the SBC as default gateway then the SBC will NAT the traffic and it will appear on the ISP router with source IP 172.20.1.1.
I can live with that double NAT, but the ideia with an SBC with 2 ports + the switch was to avoid slashing the bandwidth in half for those more controlled wired devices.
To be fair, I don't really need WAN for what I want to do. Two ports set as LAN on the same bridge could work... assuming I would be able to set Openwrt to send all outgoing traffic with a destination different than the local subnet using the second LAN port... Not sure if this is possible.
Maybe something like:
Use PREROUTING to mark the traffic with destination IP outside the local subnet
Create a routing table for that mark
Add route that says that default of the routing table above should use the second port
Edit: found someone experimenting with something similar to what I described here.