Wireguard connects but webserver and camera doesn't work

Hi There,

I followed this guide and have a working wireguard configuration on a 19.07 rc2 on a Dir-860 b1.
They seem to work over wifi and 4G .

I use this to access 3 camera's a doorbird, Grandstream and a Hikvision.
I have moving video from one and 2 but not from 3.

I also have a server(Qapache) running on a QNAP listing to port 88.
None of the experimental pages are served when wireguard is running not even over wifi.But when I turn of wireguard on the phone I get my webpages.

Can anybody help me with this?

How are you able to access the encrypted network if you turn OFF the Wireguard?

If you are testing from the same network, that may not work, depending on your config.

Can you show us the config (removing keys)?

This is the firewall

config redirect
option dest_port '1194'
option src 'wan'
option name 'WireguardForward'
option src_dport '1194'
option target 'DNAT'
option dest 'lan'
option proto 'udp'
option dest_ip '192.168.1.1'

This is the network

config interface 'wg0'
option proto 'wireguard'
option private_key 'Redacted'
option listen_port '1194'
list addresses '192.168.46.0/16'

config wireguard_wg0
option route_allowed_ips '1'
option persistent_keepalive '25'
option description 'nokiaeveline'
option public_key 'Redacted'
list allowed_ips '192.168.46.199/32'

config wireguard_wg0
option route_allowed_ips '1'
option persistent_keepalive '25'
option description 'Nokia8Guy'
option public_key 'Redacted'
list allowed_ips '192.168.46.210/32'

How are you able to access the encrypted network if you turn OFF the Wireguard?

At home I can test via wifi or 4G indeed it seems to work better via 4G than via home-wifi.

On my Android phone I get an error if I try to connect with total comander to my NAS I get the following after some time.
SMB2 CONNECT failed to connect to QNAP TS869L.lan 192.168.1.5(port445) from 192.168.46.210 (port 38945 after 5000ms

Create a static route between the wireguard network and your local one.

Is there a reason you’re defining a /16? Unless you are servicing 65k hosts, this is only going to mess things up. And it is likely part of the problem since this collides with your LAN (192.168.1.0/24, I’m guessing)

Change this to a /24 and you also need to make the address an actual host address, not a network address:

list addresses '192.168.46.1/24'

Also, your firewall rule should not be a redirect, but rather a traffic rule (accept udp 1194)


config rule
        option target 'ACCEPT'
        option src 'wan'
        option proto 'udp'
        option dest_port '1194'
        option name 'Allow-WireGuard-Inbound'

Then create a Wireguard zone and allow forwarding to the lan zone:


config zone
        option name 'wg'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option network 'wg0'
        option forward 'REJECT'

config forwarding
        option dest 'lan'
        option src 'wg'

You should not need to add any static routes.

Also, if these don’t fix your problems, please post the complete firewall and network files (ok to redact the keys and such, but the other config items are critical)

1 Like

Hi,

First of all warm greetings in these special holidays.
Thanks for the tips and I experimented with them.
What I learned was that:
/etc/init.d/ firewall restart wasn't enough to have the changed settings working
/etc/init.d/network restart wasn't enough to have the changed settings working
A REBOOT was necessary.

I had and have a working Wireguard for my camera's but not for reaching my NAS.

When I change 192.168.46.0/24 to 192.168.46.1/24 Wireguard doesn't work.
When I change from PortForward to traffic rule Wireguard doesn't work.

Changing from /16 to /24 gave me a signifact speeds boost in framerate on the camera's.

Stil I would like to reach my NAS network on 192.168.1.5

My Network Config is

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 'fdb7:6ef3:dd69::/48'

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

config device 'lan_eth0_1_dev'
	option name 'eth0.1'
	option macaddr 'Redacted'

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

config device 'wan_eth0_2_dev'
	option name 'eth0.2'
	option macaddr 'Redacted'

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 ports '1 2 3 4 6t'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option ports '0 6t'

config interface 'wg0'
	option proto 'wireguard'
	option private_key 'Redacted'
	option listen_port '1194'
	list addresses '192.168.46.0/24'

config wireguard_wg0
	option route_allowed_ips '1'
	option persistent_keepalive '25'
	option description 'nokiaeveline'
	option public_key 'Redacted'
	list allowed_ips '192.168.46.199/32'

config wireguard_wg0
	option route_allowed_ips '1'
	option persistent_keepalive '25'
	option description 'Nokia8Guy'
	option public_key 'Redacted'
	list allowed_ips '192.168.46.210/32'

config wireguard_wg0
	option persistent_keepalive '25'
	option route_allowed_ips '1'
	option public_key 'Redacted'
	option description 'Nexus5'
	list allowed_ips '192.168.46.211/32'

My Firewall is:

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

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

config zone 'wan'
	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 'lan_wan'
	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 rule 'wg'
	option name 'Allow-WireGuard-Inbound'
	option src 'wan'
	option dest_port '1194'
	option proto 'udp'
	option target 'ACCEPT'
	option src_port '1194'
	option enabled '0'

config zone
	option name 'wg'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option network 'wg0'
	option forward 'REJECT'

config forwarding
	option dest 'lan'
	option src 'wg'

config redirect
	option dest_port '1194'
	option src 'wan'
	option name 'WireguardForward'
	option src_dport '1194'
	option target 'DNAT'
	option dest 'lan'
	option proto 'udp'

config redirect
	option src 'wan'
	option src_dport '88'
	option target 'DNAT'
	option dest_ip '192.168.1.5'
	option dest 'lan'
	option proto 'tcp udp'
	option name 'Website'
	option dest_port '88'
	option enabled '0'

config rule
	option src_port '88'
	option src 'wan'
	option name 'websites'
	option target 'ACCEPT'
	option dest 'lan'
	option dest_ip '192.168.1.5'
	option dest_port '88'
	option proto 'tcp udp'

When you tried the traffic rule, did you delete the redirect?

And when you set the wg interface address as .1/24, how did you test to determine that it wasn’t working? Had you restarted after the change?

Also, it looks like you have the wg interface attached to both the lan and wg zones. Remove it from the lan zone.

Please post your remote peer config and describe how you are testing (same network, different WiFi/wired network, cellular) and what diagnostics you are using to determine the status.

At the very least I did a /etc/init.d/firewall restart and a /etc/init.d/network restart. Now I just reboot

I have the 192.168.46.1/24 working .
I removed wg0 from the lan zone.

Yesterday I changed he allowed IPs on the Android phone from 0.0.0.0/0, ::0 to 0.0.0.0/0,::/0 from that moment I can't connect over wireguard from that phone.
When I reentered 0.0.0.0/0, ::0 and saved I notice that the wireguardapp on Android changed it to 0.0.0.0/0, ::/128

My other phones are still able to connect. I even removed the app and rebooted before I did a new installation.
Then I changed the Peer IP adres from 192.168.46.210/24 to 192.168.46.10/24 on the phone and the router and NOW it works

I test via wifi at home so same network and I enable 4G so that's the real test.

Camera's are working connection to NAS not.
Furthermore it's only working over wifi now....

[Interface]                                    changed to 
Address = 192.168.46.210/24    ========>     192.168.46.10/24
DNS = 192.168.1.1
ListenPort = 1194
PrivateKey = REDACTED

[Peer]
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = 82.84.154.176:1194
PersistentKeepalive = 25
PublicKey = Redacted

This is the Nexus5 conf

[Interface]
Address = 192.168.46.211/24
DNS = 192.168.1.1
ListenPort = 1194
PrivateKey = REDACTED

[Peer]
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = 82.84.154.176:1194
PublicKey = REDACTED

Change the peer (phones) addresses to /32.

Also remove the ipv6 addressing from the allowed ips (make it simply 0.0.0.0/0). This is because you don’t have ipv6 defined on the router peer side.

Restart the router and try again. If there are still problems, post the latest config files and peer configs

I only want to connect to my home network and acces my Camera's, my NAS and later on I will configure stubby.

I have following setting.

ISP --------OpenWRT19.07rc2------TL-SG2424P------All PC's1.PC

For now the configuration beneath this line gives high framerate, but no Internet and no NAS. It's also only working over 4G

The 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'
	list 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 zone
        option name 'wg'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option network 'wg0'
        option forward 'REJECT'

config forwarding 
	option dest 'lan'
	option src 'wg'

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 rule
        option target 'ACCEPT'
        option src 'wan'
        option proto 'udp'
        option dest_port '2110'
        option name 'Allow-WireGuard-Inbound'

config redirect
	option src 'wan'
	option src_dport '88'
	option target 'DNAT'
	option dest_ip '192.168.1.5'
	option dest 'lan'
	option proto 'tcp udp'
	option name 'Website'
	option dest_port '88'
	option enabled '0'

config rule
	option src_port '88'
	option src 'wan'
	option name 'websites'
	option target 'ACCEPT'
	option dest 'lan'
	option dest_ip '192.168.1.5'
	option dest_port '88'
	option proto 'tcp udp'



The 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 'fdb7:6ef3:dd69::/48'

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

config device 'lan_eth0_1_dev'
	option name 'eth0.1'
	option macaddr '90:8d:78:23:9f:94'

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

config device 'wan_eth0_2_dev'
	option name 'eth0.2'
	option macaddr '90:8d:78:23:9f:97'

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 ports '1 2 3 4 6t'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option ports '0 6t'

config interface 'wg0'
	option proto 'wireguard'
	option private_key 'sGF-REDACTED-Q='
	option listen_port '2110'
	list addresses '192.168.9.1/24'

config wireguard_wg0
	option route_allowed_ips '1'
	option persistent_keepalive '25'
	option public_key 'g2-REDACTEDG-U='
	list allowed_ips '192.168.9.2/32'
	option description 'Nokia8Eveline'

config wireguard_wg0
	option route_allowed_ips '1'
	option persistent_keepalive '25'
	option description 'Nokia8Guy'
	option public_key 'ay-REDACTED-Uc='
	list allowed_ips '192.168.9.7/32'

config wireguard_wg0
	option persistent_keepalive '25'
	option route_allowed_ips '1'
	option public_key 'EA-REDACTEDT-c='
	option description 'Nexus5'
	list allowed_ips '192.168.9.9/32'


The Peers on the phone:
Nokia8Guy

[Interface]
Address = 192.168.9.7/32
DNS = 192.168.1.1
ListenPort = 2110
PrivateKey = YO-REDACTED-mE=

[Peer]
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = 81.82.154.176:2110
PersistentKeepalive = 25
PublicKey = Du-REDACTED-kU=

Nexus5

[Interface]
Address = 192.168.46.211/24
DNS = 192.168.1.1
ListenPort = 2110
PrivateKey = QD-REDACTED-8=

[Peer]
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = 81.82.154.176:2110
PublicKey = Du-REDACTED-kU=

Remove the ipv6 allowed ips from the phone peers.

Add forwarding from wg to wan If you want internet access.

Not surprising that it only works when on cellular - while you are connected to your WiFi I would expect that there would be ambiguity regarding the routing because your phone(s) have local op addresses in the 192.168.1.0/24 network but then have wg overriding and routing back to that same network may not work as expected. But there is no point to worrying about it when you are on WiFi on your local network since that is not a use case that matters.

What is the operating system of the bad? Does it have a firewall or any other rules that might restrict access from other rfc1918 address ranges to the device itself?

Indeed though it would be easy, if you don't have to think about it when arriving at home.

What is the operating system of the bad? Does it have a firewall or any other rules that might restrict access from other rfc1918 address ranges to the device itself?

I don't understand what you mean with what is the operating system of the bad?
My nokia8 is running android 9, OpenWRT is 19.07rc2.

As openwrt is handing out the IP adresses, my Nokia8 always gets the same IP adres that isn't conflicting with the ones from Wireguard.

The NAS itself can be accessed with wifi...

Can you elaborate a bit about the difference in firewall approach of the portforward approach and the rule configuration.

Sorry, autocorrect. NAS operating system.

My NAS is a QNAP and thus running a linux ...I look into it if allowed it only to have connections from 192.168.1.x range.

So this could explain why you cannot access your NAS. Not sure if the device would block other subjects, but if so, you’ll need to modify the firewall on that device to allow connections from your wg subnet.

Indeed I had placed a rule that only 192.168.1.x range was allowed...Access to Nas is there.

Thanks...
Guy

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