Struggling with Wireguard connecting to the local network

Hi,
I can get my phone to connect to the router using Wireguard, but can't reach anything now, doesn't seem to be a DNS problem, as 192.168.1.1 doesn't seem to connect either.

I'm trying to get my phone to connect as 192.168.4.241 with wg0 on a 192.168.4.0/255 subnet. The Lan is on 192.168.1.0 with 192.168.1.1 as the gateway. DMZ and Virtual Machines are two other subnets on 192.168.{2,3}.0/24 respectively.

I'm running out of ideas, I had it working to the outside world when I set wireguard up to use the 192.168.1.0 network, but changed it after reading on the forum that it's better to have a separate subnet. I'd ideally like to be able to reach the VirtualMachine and DMZ networks too. If anyone has any ideas?

Here's my /etc/config/network;

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

config globals 'globals'
        option ula_prefix 'fde6:4511:0f54::/48'

config interface 'lan'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option ifname 'eth1.1'

config interface 'wan'
        option ifname 'eth0.2'
        option proto 'dhcp'

config interface 'wan6'
        option ifname 'eth0.2'
        option proto 'dhcpv6'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option vid '1'
        option ports '6t 4 3 2'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '5 0t'
        option vid '2'

config interface 'dmz'
        option _orig_bridge 'false'
        option proto 'static'
        option ipaddr '192.168.2.1'
        option netmask '255.255.255.0'
        option broadcast '192.168.2.255'

config interface 'wg0'
        option proto 'wireguard'
        option private_key '<redacted>'
        option listen_port '51820'
        list addresses '192.168.4.1/24'

config wireguard_wg0
        option description 'JimPhone'
        list allowed_ips '192.168.1.241/32'
        option route_allowed_ips '1'
        option persistent_keepalive '25'
        option public_key '<redacted>'

config switch_vlan
        option device 'switch0'
        option vlan '3'
        option vid '3'
        option ports '6t 1'

config interface 'VirtualMachine'
        option proto 'static'
        option netmask '255.255.255.0'
        option ipaddr '192.168.3.1'
        option broadcast '192.168.3.255'
        option ifname 'eth1.3'

Here's my /etc/config/firewall

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

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

config zone
        option name 'wan'
        option input 'REJECT'
        option output 'ACCEPT'
        option forward 'REJECT'
        option masq '1'
        option mtu_fix '1'
        option network 'wan 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'

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

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

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

config forwarding
        option src 'dmz'
        option dest 'wan'

config zone
        option forward 'REJECT'
        option output 'ACCEPT'
        option name 'dmz'
        option input 'REJECT'
        option network 'dmz'
        option family 'ipv4'
        option log '1'

config forwarding
        option dest 'dmz'
        option src 'lan'

config redirect
        option target 'DNAT'
        option src 'wan'
        option dest 'dmz'
        option proto 'tcp'
        option src_dport '80'
        option dest_ip '192.168.2.241'
        option dest_port '80'
        option name 'www-http'

config rule
        option target 'ACCEPT'
        option dest_port '53'
        option name 'dhcp-dns'
        option family 'ipv4'
        option proto 'udp'
        option src 'dmz'
        option dest_ip '192.168.2.1'

config rule
        option enabled '1'
        option target 'ACCEPT'
        option proto 'udp'
        option dest_port '67'
        option name 'dhcp-dmz'
        option family 'ipv4'
        option src 'dmz'

config redirect
        option target 'DNAT'
        option src 'wan'
        option dest 'dmz'
        option proto 'tcp'
        option src_dport '443'
        option dest_ip '192.168.2.241'
        option dest_port '443'
        option name 'https'

config rule
        option src '*'
        option target 'ACCEPT'
        option proto 'udp'
        option dest_port '51820'
        option name 'Allow-Wireguard-Inbound'

config zone
        option input 'ACCEPT'
        option output 'ACCEPT'
        option name 'VMBridge'
        option forward 'ACCEPT'
        option network 'VirtualMachine lan wan'

config forwarding
        option dest 'dmz'
        option src 'VMBridge'

config forwarding
        option dest 'lan'
        option src 'VMBridge'

config forwarding
        option dest 'wan'
        option src 'VMBridge'

config forwarding
        option dest 'VMBridge'
        option src 'lan'

config zone 'wireguard'
        option name 'wireguard'
        option input 'ACCEPT'
        option forward 'ACCEPT'
        option output 'ACCEPT'
        option masq '1'
        option mtu_fix '1'
        option network 'wireguard wg0'
        list device 'wg0'

config forwarding
        option dest 'VMBridge'
        option src 'wireguard'

config forwarding
        option dest 'dmz'
        option src 'wireguard'

config forwarding
        option dest 'wan'
        option src 'wireguard'

config forwarding
        option dest 'wireguard'
        option src 'VMBridge'

config forwarding
        option dest 'wireguard'
        option src 'dmz'

config forwarding                               
        option dest 'lan'                 
        option src 'wireguard' 

config forwarding                               
        option dest 'wireguard'                 
        option src 'lan'
1 Like

It should be the peer's IP address matching the subnet of the respective WG interface:

1 Like

Thanks for that, missed that change!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.