How to add exception route to guest network setup?

I have successfully set up home network as follows:
OpenWRT router as a main router and DD-WRT router as an access point. Guest wifi is set up in DD-WRT and guests can't see main network devices nor eachother.

But how can I add an exception for guest network devices to allow them to acces raspberry pi (192.168.1.195) in main network?


             +-----------------------+                                
             | Openwrt (DHCP Server) |                                
             |      192.168.1.1      |                                
             +-----------------------+                                
                         |                                            
                         |                                            
                         |                                            
+----------------------------------------------------+                
|                       DD-WRT                       |                
|                     192.168.1.2                    |                
|                                                    |                
|                 WAN Disabled                       |                
|                 Gateway 192.168.1.1                |                
|                 Type DHCP Server                   |                
|                 DHCP Server Disabled               |                
|                                                    |                
|                                                    |                
| +-----------------+ +-----------------------------+|                
| | AP wl0          | | Guest VLAN wl0.1            ||                
| |                 | |                             ||                
| |                 | | Unbridged                   ||                
| |                 | | Net Isolation: Yes          ||                
| |                 | | Forced DNS Redirection: Yes ||                
| |                 | | Optional DNS Target 1.1.1.1 ||                
| |                 | | IP Address 192.168.2.1/24   ||                
| |                 | | AP Isolation: Yes           ||                
| +-----------------+ +-----------------------------+|                
+---------|--------------------------------|---------+                
          |                                |                          
          |                                |                          
  +---------------+                 +-------------+                  
  | ClientA       |                 |ClientB      |                  
  | 192.168.1.195 | <-------------- |192.168.2.30 |                  
  +---------------+  How to access  +-------------+                  
                     A from 192.168.2.X?                                        

To me it looks like the guest network is completely handled by DD-WRT, so this is a DD-WRT question, not an OpenWrt question. In OpenWrt, you would add a firewall rule to allow access.

2 Likes

Ok, looks like I have extra problems with DD-WRT managing the guest network as I want to control fw rules and routes on OpenWrt.

Any advice on setup how to utilize DD-WRT router only for wifi access point (main + guest wifi) and all other network management (DHCP, zones, routes, firewall) is done on OpenWrt?

This is a question for the DD-WRT forums.

If the guest network is handled by DD-WRT, you cannot make other rules to affect the guest network on another device.

The best topology for this is to have your main router handle all the networks (lan + guest + others) and run all other devices as dumb APs (ideally fully VLAN aware and capable of running multiple SSIDs). This way your main router's fireall handles all of the rules.

When using a dumb access point aka a Wireless Access Point you need to Masquerade over the LAN interface.
For DDWRT something like
iptables -t nat -I POSTROUTING -o br0 -j MASQUERADE

Test from command line

Yes. This is how I want to reconfigure my network.

My DD-WRT is already a dumb AP in terms of general settings so I..

  1. get rid of guest wifi setup with dnsmasq
  2. create VLANs for main, guest, iot, etc
  3. create virtual interfaces for wireless
  4. create bridges and assign VLANS and virutal wireless
  5. use masquerade commands described by egc above for each bridge

Is this correct?
If this is too DD-WRT sepcific I might ask it from DD_WRT forum.

But for the OpenWrt part - what would be the concept to start with?

All but number 5. Masquerading is only necessary in a dumb AP with guest wifi configuration (example of how to do it with OpenWrt) -- in other words, the guest wifi is created and routed on the dumb AP. If the main router handles the guest network, you'll be simply using a multi-SSID dumb AP (with VLANs)., no routing or firewall or anything else happens on the dumb AP.

Does this mean I should use another cable from DD-WRT eth port (assigned to vlan3) to OpenWrt and continue the remaining setup there or how other will different VLANs reach OpenWrt?

I've done the DD-WRT part, except number 5.
Created br1 and assigned vlan3 and wl0.2 to it.
br1 ip address is set to 172.16.0.1/24. Main network managed by OpenWrt is 192.168.1.0/24

I am not getting ip address on connecting to wl0.2. br1 is just sitting there separate.

No, just one cable between the two routers. This will be a 'trunk' cable -- i.e. carrying multiple networks on the same cable using VLANs (802.1q tagged).

the wireless hardware should not be spcified in the network config.

Let's see your config so far...

Please copy the output of the following commands and post it here using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have:

cat /etc/config/network
cat /etc/config/wireless
cat /etc/config/dhcp
cat /etc/config/firewall

On OpenWrt:

cat /etc/config/network

config interface 'loopback'
	option device 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'asdasd'

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'eth1'
	list ports 'eth2'
	option ipv6 '0'

config interface 'lan'
	option device 'br-lan'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option ipv6 'off'

config interface 'wan'
	option device 'eth0'
	option proto 'dhcp'
	option peerdns '0'
	option ipv6 'off'
	list dns '1.1.1.1'
	list dns '1.0.0.1'

config interface 'wan6'
	option device 'eth0'
	option proto 'dhcpv6'
	option auto '0'
	option reqaddress 'try'
	option reqprefix 'auto'

config route 'host_to_guest'
	option device 'br-lan'
	option target '192.168.2.0/24'
	option gateway '192.168.1.2'
	option interface 'lan'

host_to_guest route was for accessing smart devices in guest network managed by DD-WRT

cat /etc/config/wireless

config wifi-device 'radio0'
	option type 'mac80211'
	option path 'pci0000:00/0000:00:15.0/0000:05:00.0'
	option hwmode '11g'
	option channel '1'
	option cell_density '0'
	option country 'EE'

config wifi-iface 'default_radio0'
	option device 'radio0'
	option network 'lan'
	option mode 'ap'
	option ssid 'myssid'
	option encryption 'psk2'
	option key 'mypasswd'

cat /etc/config/dhcp

config dnsmasq
	option domainneeded '1'
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/lan/'
	option domain 'lan'
	option expandhosts '1'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option localservice '1'
	option ednspacket_max '1232'
	list server '/use-application-dns.net/'
	list server '127.0.0.1#5054'
	option doh_backup_noresolv '-1'
	list doh_backup_server '/use-application-dns.net/'
	option confdir '/tmp/dnsmasq.d'

config dhcp 'lan'
	option interface 'lan'
	option start '100'
	option limit '150'
	option leasetime '12h'
	option dhcpv4 'server'
	option ra 'server'
	list ra_flags 'managed-config'
	list ra_flags 'other-config'

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

config odhcpd 'odhcpd'
	option maindhcp '0'
	option leasefile '/tmp/hosts/odhcpd'
	option leasetrigger '/usr/sbin/odhcpd-update'
	option loglevel '4'

config host
	option name 'asd'
	option dns '1'
	option mac 'asd'
	option ip '192.168.1.28'

There are more similar hosts but I removed them.

cat /etc/config/firewall

config defaults
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'REJECT'
	option synflood_protect '1'

config zone
	option name 'lan'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'
	list network 'lan'

config zone
	option name 'wan'
	option input 'REJECT'
	option output 'ACCEPT'
	option forward 'REJECT'
	option masq '1'
	option mtu_fix '1'
	list network 'wan'
	list network 'wan6'

config forwarding
	option src 'lan'
	option dest 'wan'

config rule
	option name 'Allow-DHCP-Renew'
	option src 'wan'
	option proto 'udp'
	option dest_port '68'
	option target 'ACCEPT'
	option family 'ipv4'

config rule
	option name 'Allow-Ping'
	option src 'wan'
	option proto 'icmp'
	option icmp_type 'echo-request'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-IGMP'
	option src 'wan'
	option proto 'igmp'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-DHCPv6'
	option src 'wan'
	option proto 'udp'
	option src_ip 'fc00::/6'
	option dest_ip 'fc00::/6'
	option dest_port '546'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-MLD'
	option src 'wan'
	option proto 'icmp'
	option src_ip 'fe80::/10'
	list icmp_type '130/0'
	list icmp_type '131/0'
	list icmp_type '132/0'
	list icmp_type '143/0'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-ICMPv6-Input'
	option src 'wan'
	option proto 'icmp'
	list icmp_type 'echo-request'
	list icmp_type 'echo-reply'
	list icmp_type 'destination-unreachable'
	list icmp_type 'packet-too-big'
	list icmp_type 'time-exceeded'
	list icmp_type 'bad-header'
	list icmp_type 'unknown-header-type'
	list icmp_type 'router-solicitation'
	list icmp_type 'neighbour-solicitation'
	list icmp_type 'router-advertisement'
	list icmp_type 'neighbour-advertisement'
	option limit '1000/sec'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-ICMPv6-Forward'
	option src 'wan'
	option dest '*'
	option proto 'icmp'
	list icmp_type 'echo-request'
	list icmp_type 'echo-reply'
	list icmp_type 'destination-unreachable'
	list icmp_type 'packet-too-big'
	list icmp_type 'time-exceeded'
	list icmp_type 'bad-header'
	list icmp_type 'unknown-header-type'
	option limit '1000/sec'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-IPSec-ESP'
	option src 'wan'
	option dest 'lan'
	option proto 'esp'
	option target 'ACCEPT'
	option enabled '0'

config rule
	option name 'Allow-ISAKMP'
	option src 'wan'
	option dest 'lan'
	option dest_port '500'
	option proto 'udp'
	option target 'ACCEPT'
	option enabled '0'

config rule
	option name 'Support-UDP-Traceroute'
	option src 'wan'
	option dest_port '33434:33689'
	option proto 'udp'
	option family 'ipv4'
	option target 'REJECT'

config include
	option path '/etc/firewall.user'

config redirect
	option target 'DNAT'
	option name 'vaultp'
	option src 'wan'
	option src_dport 'port'
	option dest 'lan'
	option dest_ip '192.168.1.28'
	option dest_port 'port'
	list proto 'tcp'

config redirect
	option target 'DNAT'
	option name 'rpiSSH'
	list proto 'tcp'
	option src 'wan'
	option src_dport 'port'
	option dest 'lan'
	option dest_ip '192.168.1.111'
	option dest_port '22'

config redirect
	option target 'DNAT'
	option name 'vaultSSH'
	list proto 'tcp'
	option src 'wan'
	option src_dport 'port'
	option dest 'lan'
	option dest_ip '192.168.1.28'
	option dest_port '22'

Is OpenWrt the main router? If so, the guest netork should be defined here and not on the other device.

OpenWrt is the main router. I want to manage everything with OpenWrt and leave DD-WRT only for wireless because my OpenWrt is located in a garage rack but DD-WRT in livingroom.
host_to_guest route is there because of my previous setup, where guest network was managed by DD-WRT.
I have not yet made any configurations on OpenWrt.

What is the OpenWrt device?

ubus call system board
{
	"kernel": "5.10.138",
	"hostname": "OpenWrt",
	"system": "AMD G-T40E Processor",
	"model": "PC Engines apu1",
	"board_name": "pc-engines-apu1",
	"rootfs_type": "squashfs",
	"release": {
		"distribution": "OpenWrt",
		"version": "22.03.0",
		"revision": "r19685-512e76967f",
		"target": "x86/64",
		"description": "OpenWrt 22.03.0 r19685-512e76967f"
	}
}

ok... so, I'll assume for the moment that eth1 connects to the AP (correct me or adapt as necessary).

add this to your network config:

config interface 'guest'
	option device 'eth1.2'
	option proto 'static'
	option ipaddr '192.168.2.1'
	option netmask '255.255.255.0'

delete this from your network file:

add this to the DHCP file

config dhcp 'guest'
	option interface 'guest'
	option start '100'
	option limit '150'
	option leasetime '12h'
	option dhcpv4 'server'

and this to your firewall:

config zone
	option name 'guest'
	option input 'REJECT'
	option output 'ACCEPT'
	option forward 'REJECT'
	list network 'guest'

config rule
	option name 'Allow-guest-DHCP'
	option src 'guest'
	option proto 'udp'
	option dest_port '67-68'
	option target 'ACCEPT'
	option family 'ipv4'

config rule
	option name 'Allow-guest-DNS'
	option src 'guest'
	option dest_port '53'
	option target 'ACCEPT'

config forwarding
	option src 'guest'
	option dest 'wan'

This should get you a functional guest network on eth1 as a tagged network on VLAN2.

From there, you'll need to configure you DD-WRT device to setup a bridge with VLAN2 and a wifi SSID. In most cases, the AP should not have an address on this network.

I followed your instructions and looks like I've got guest network working. For detailed configutration of DD-WRT I got help from their community - thanks egc.

I assume, I should make a configuration for tagged vlan1 also?
At the moment main SSID (wl0 on DD-WRT) has no DHCP nor access anywhere. And ping on 192.168.1.2 (DD-WRT router) from OpenWrt wired network fails.

Looks like vlan1 from DD-WRT is also working now on the OpenWrt main network.
I had to create eth2.1 device (eth2 connects to AP) and add that device to the br-lan.

I don't know if this is the right way to do it but everything appears to be working as expected.

config device
	option type '8021q'
	option ifname 'eth2'
	option vid '1'
	option name 'eth2.1'

config device
	option name 'br-lan'
	option type 'bridge'
	option ipv6 '0'
	list ports 'eth1'
	list ports 'eth2'
	list ports 'eth2.1'

Thank you psherman, you're great! I got my problem solved and learned a lot.

How to enable client isolation on vlan3?

Client isolation is a wifi thing -- so you can enable it in the SSID settings. However, it only works within the same AP.

if you have multiple APs broadcasting the same SSID, the clients on any given AP will not be able to see each other, but the clients on one AP will be able to see the clients on the other AP and vise versa.

This is probably not correct, but Iā€™d need to see the latest complete network file to understand the context.