Cannot ssh to clients on lan when accessing router via wireguard client

I have configured a wireguard server on my openwrt router using "/root/auto_wg_username-id.sh", from this page. The ip address of my openwrt router when accessed from the lan and not the vpn client, is 192.168.1.1. The vpn client dns address is 10.0.5.1. The Wireguard vpn client connects successfully, and when I type in 192.168.1.1 to access luci interface, it works, and I can access luci just fine. However, I also have an ssh server running on my lan located at 192.168.1.2. I can ssh into this server when connected directly to my lan, however, I cannot ssh to this server when connected via the Wireguard VPN as a client. I suspect this has something to do with the vpn client not sharing the same dns as the LAN. But I am not for certain. What I want to do, is (securely) force my wireguard vpn client to use the same dns as my lan, or at least be able to access other systems on my lan via ssh, when connecting as a wireguard client. I cannot seem to figure out how to do this and could use some help and advice.

Thank you so much!

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/firewall

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'

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'lan1'
	list ports 'lan2'
	list ports 'lan3'
	list ports 'lan4'

config interface 'lan'
	option device 'br-lan'
	option proto 'static'
	option netmask '255.255.255.0'
	option ip6assign '60'
	list dns '1.1.1.1'
	list dns '1.0.0.1'
	list dns '8.8.8.8'
	option ipv6 '0'
	option delegate '0'
	option ipaddr '192.168.1.1'

config device
	option name 'wan'
	option macaddr '************'

config interface 'wan'
	option device 'wan'
	option proto 'dhcp'
	option ipv6 '0'

config interface 'wan6'
	option device 'wan'
	option proto 'dhcpv6'

config interface 'wg_lan'
	option proto 'wireguard'
	option private_key '*************************************='
	option listen_port '51820'
	list addresses '10.0.5.1/24'
	option mtu '1420'

config wireguard_wg_lan
	option public_key '*************************************='
	option preshared_key '*************************************='
	option description '1_lan_MBPClient'
	list allowed_ips '10.0.5.2/32'
	option route_allowed_ips '1'
	option persistent_keepalive '25'

config wireguard_wg_lan
	option public_key '*************************************='
	option preshared_key '*************************************='
	option description '2_lan_iPhoneClient'
	list allowed_ips '10.0.5.3/32'
	option route_allowed_ips '1'
	option persistent_keepalive '25'

cat /etc/config/firewall

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

config zone 'lan'
	option name 'lan'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'
	list device 'tun+'
	option network 'lan wg_lan'

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

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'
	option enabled '0'

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'
	option enabled '0'

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'
	option enabled '0'

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'
	option enabled '0'

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'
	option enabled '0'

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'
	option enabled '0'

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

config rule 'ovpn'
	option name 'Allow-OpenVPN'
	option src 'wan'
	option dest_port '1194'
	option proto 'udp'
	option target 'ACCEPT'

config rule 'wg'
	option name 'Allow-WireGuard-lan'
	option src 'wan'
	option dest_port '51820'
	option proto 'udp'
	option target 'ACCEPT'

nothing jumps out as problematic.

What OS(s) do the host(s) use on your 192.168.1.0/24 network (that you are having trouble reaching)? If they are Windows based systems, you probably need to adjust the firewall on those hosts -- by default, Windows will block any connection attempts initiated from a different subnet.

My host os's on the Lan (192.168.1.0/24) are ubuntu server 20.04. I can ssh into it easily if I connect directly to my router, of which the ubuntu server is also connected to. I'm ssh'ing from Mac OS.
Also, on a side note (which I didn't document in my ORIGINAL POST), I DID change my routers LAN address from 192.168.1.1 to a different address and subnet like 192.168.2.1. I'm not sure if I have to change something in the firewall as well after changing the router's LAN ip address. Could that be an issue?

do you have any host-level firewall rules that could restrict inter-VLAN connections?

You could try the following options (either/or, not both)

Option 1: Change the networks in your lan zone to be defined as "list network" lines.

config zone 'lan'
    option name 'lan'
    option input 'ACCEPT'
    option output 'ACCEPT'
    option forward 'ACCEPT'
    list device 'tun+'
    list network 'lan'
    list network 'wg_lan'

-- or --
Option 2:

remove wg_lan from the lan zone and then create a new zone for it and allow forwarding

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

config zone 'wg'
    option name 'wg'
    option input 'ACCEPT'
    option output 'ACCEPT'
    option forward 'ACCEPT'
    list network 'wg_lan'

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

Oh… and another thought - let’s see the wg config on your peer (Mac) that is trying to connect back to your Ubuntu servers

I have a stupid question:
Does it matter that the list network are ordered ahead of the

  • option input
  • option output
  • option forward
    entries?

No. Within a stanza, order doesn’t matter.

2 Likes

I don't have any host level firewall rules that could restrict interVLAN connections. At least I don't think I do. All of my firewall rules are untouched from defaults aside from anything the wireguard auto-installation script installed. On my lan network all peers are open as well.

I tried both of the above listed options to no avail.
Here is my wg config for my mac peer:

[Interface]
Address = 192.168.9.3/24, fdf1:e8a1:8d3f:9::3/64
PrivateKey = =
DNS = 192.168.9.1, fdf1:e8a1:8d3f:9::1
[Peer]
PublicKey = =
PresharedKey = =
PersistentKeepalive = 25
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = MYPUBLICIP:51820

I also tried changing the DNS to 192.168.2.1 on this configuration. 192.168.2.1 is the dns and ip address of my router. I successfully connected, but did not see other local hosts on the lan.

By host level firewall rules, I mean the windows firewall (or whatever os you are running). Windows will block connections from a different subnet unless you change the firewall settings on the pc itself.

Gotcha. I am using a mac, and no, I don't have any host level firewall restrictions on.

What is the output of wg show

interface: vpn
  public key: ****=
  private key: (hidden)
  listening port: 51820

peer: *****=
  preshared key: (hidden)
  allowed ips: 192.168.9.2/32

peer: *****=
  preshared key: (hidden)
  allowed ips: 192.168.9.3/32

peer: *****=
  preshared key: (hidden)
  allowed ips: 192.168.9.4/32

It looks like you're not actually getting a handshake.

EDIT: to elaborate.. if you're getting a valid handshake, you will see something like this:

interface: wireguard
  public key: <REDACTED>
  private key: (hidden)
  listening port: 8444

peer: <REDACTED>
  preshared key: (hidden)
  endpoint: <REDACTED>
  allowed ips: 10.0.21.2/32
  latest handshake: 12 seconds ago
  transfer: 10.88 KiB received, 34.80 MiB sent
  persistent keepalive: every 25 seconds

Wireguard can appear to be connected even if there is no handshake. But if there is no handshake, it isn't actually able to transfer any data. And that would account for the fact that you cannot reach your devices on the LAN from the remote WG peer.

Some things to check:

  1. Do you have a public IPv4 address (if in doubt, post the first two octets, in bold, of your WAN IP as seen on your OpenWrt device: aaa.bbb.ccc.ddd)
  2. Does the address from above match what you see when you google "what's my IP"
  3. Are your keys exchanged properly.
    3a) Try removing the preshared key to reduce the number of variables (you can add it in later).
    3b) The interfaces each need their own private key (not to be exchanged).
    3c) The public keys must be exchanged between the to peers that will directly connect to each other.

If your keys might be messed up, you can try to fix them, but sometimes it's easier to simply generate new keys.

Oh wow. Sorry. I didn't realize you wanted me to post this while connected via wiregard. Please not that I just also learned, I am able to ssh into my openwrt router when using wireguard, but not my other lan devices (my ubuntu server). I am still able to ssh into my ubuntu server when connected directly to my router. Pinging my local ubuntu server fails when connected to wireguard as well, but not when directly plugged into my local openwrt router.

Here is the command output when I am connected via wireguard.

wg show
interface: vpn
  public key: ****=
  private key: (hidden)
  listening port: 51820

peer: *****=
  preshared key: (hidden)
  endpoint: ***.***.***.***:64423
  allowed ips: 192.168.9.3/32
  latest handshake: 1 minute, 16 seconds ago
  transfer: 272.60 KiB received, 1.00 MiB sent

peer: *****=
  preshared key: (hidden)
  allowed ips: 192.168.9.2/32

peer: *****=
  preshared key: (hidden)
  allowed ips: 192.168.9.4/32

EDIT:
It just occured to me that I probably should have mentioned this in my initial post.
I am running my router behind a router. The first router is my ISP's router. The second router is my openwrt router. The first router is using port forwarding to forward it's wireguard port to the openwrt router. I didn't think this was relevant since I am successfully connecting to openwrt with wireguard. Just to check things, when I go to https://www.dnsleaktest.com/ and do a dnsleaktest, it shows dns addresses from my ISP router, and correctly shows that my dns is not leaking. I just figured this is extra information that might somehow be relevant beyond my knowledge.

Lastly, the only thing I can think of is that somehow my vpn dns requests are not querying or properly being forwarded to the local openwrt dns. Somehow, I can't get it out of my head that this is a local dns issue. I figured the wireguard script would have this working right out of the box, but I guess my local server is not seeing my vpn client on the same network as my local connection to the router. If this is true, then the solution would have to somehow be a way to get my vpn client to link itself to the local routers lan, not 192.168.9.1.

I'm at a loss, so just shooting out ideas. Your help is much appreciated!

This could be very relevant. Is anything else connected to your isp router? Or is everything behind the openwrt router? What is the subnet of your isp router? How is the OpenVPN router connected to the isp router (isp router lan > openwrt wan or lan > lan)?

So the isp router is actually on 192.168.1.1, not the openwrt router. The openwrt router is on 192.168.2.1. I obfuscated the original addresses because I didn't think it mattered. Nothing else is connected to my ISP router. Everything is behind the wrt router. The openvpn router is connected to the isp router like so... WAN>ISP ROUTER> ISP LAN> Openwrt LAN> Lan Devices. However, I still don't think having a dual router setup is relavent if port forwarding is working. I tested this theory by pluggging in a pepwave surf soho router, and turning on its OpenVPN server. When testing, I made sure the soho device was in the exact same setup as the wrt router, in other words, it was connected from the ISP routers LAN to its wan, and then all local devices connected to the soho lan. After testing this, openvpn works perfectly on the soho with access to all of my lan devices. To double check things, I flashed another wrt router with openwrt and installed openvpn with the setup script listed in the openwrt openvpn setup section. Once again, I cannot access my local devices on the openvpn openwrt router using openvpn, even though it is usinig the same IP as my soho was. So essentially, I am having the same issue on both my wrt routers using wireguard, and the other using openvpn. Neither seem to be able to connect to the local devices when being tunneled. However, my soho can under the same configuration.

Ok,,, so let’s see the latest configuration. Don’t obfuscate the internal addresses (it’s not necessary). Redact keys, public ips, and passwords, etc.

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

The following was taken while connected to wireguard vpn to my openwrt router.

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'

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'lan1'
	list ports 'lan2'
	list ports 'lan3'
	list ports 'lan4'

config interface 'lan'
	option device 'br-lan'
	option proto 'static'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option ipaddr '192.168.2.1'
	option ipv6 '0'
	option delegate '0'

config device
	option name 'wan'
	option macaddr '****'

config interface 'wan'
	option device 'wan'
	option proto 'dhcp'
	option ipv6 '0'

config interface 'wan6'
	option device 'wan'
	option proto 'dhcpv6'

config interface 'vpn'
	option proto 'wireguard'
	option private_key '****='
	option listen_port '51820'
	list addresses '192.168.9.1/24'
	list addresses 'fdf1:e8a1:8d3f:9::1/64'

config wireguard_vpn 'wgclient'
	option public_key '*****='
	option preshared_key '*******='
	list allowed_ips '192.168.9.2/32'
	list allowed_ips 'fdf1:e8a1:8d3f:9::2/128'

config wireguard_vpn 'wglaptop'
	option public_key '*******='
	option preshared_key '********='
	list allowed_ips '192.168.9.3/32'
	list allowed_ips 'fdf1:e8a1:8d3f:9::3/128'

config wireguard_vpn 'wgmobile'
	option public_key '******='
	option preshared_key '*******='
	list allowed_ips '192.168.9.4/32'
	list allowed_ips 'fdf1:e8a1:8d3f:9::4/128'

cat /etc/config/wireless
config wifi-device 'radio0'
	option type 'mac80211'
	option path 'soc/soc:pcie/pci0000:00/0000:00:01.0/0000:01:00.0'
	option channel '36'
	option band '5g'
	option htmode 'VHT80'
	option country 'US'
	option cell_density '0'

config wifi-iface 'default_radio0'
	option device 'radio0'
	option network 'lan'
	option mode 'ap'
	option macaddr '*****'
	option ssid '******'
	option encryption 'psk2'
	option key '******'
	option wpa_disable_eapol_key_retries '1'

config wifi-device 'radio1'
	option type 'mac80211'
	option path 'soc/soc:pcie/pci0000:00/0000:00:02.0/0000:02:00.0'
	option channel '1'
	option band '2g'
	option htmode 'HT20'
	option country 'US'
	option cell_density '0'

config wifi-iface 'default_radio1'
	option device 'radio1'
	option network 'lan'
	option mode 'ap'
	option macaddr '******'
	option ssid '*****'
	option encryption 'psk2'
	option key '********'
	option wpa_disable_eapol_key_retries '1'

config wifi-device 'radio2'
	option type 'mac80211'
	option path 'platform/soc/soc:internal-regs/f10d8000.sdhci/mmc_host/mmc0/mmc0:0001/mmc0:0001:1'
	option channel '34'
	option band '5g'
	option htmode 'VHT80'
	option cell_density '0'

config wifi-iface 'default_radio2'
	option device 'radio2'
	option network 'lan'
	option mode 'ap'
	option ssid '*******'
	option encryption 'psk2'
	option key '*********'
	option wpa_disable_eapol_key_retries '1'


cat /etc/config/dhcp

config dnsmasq
	option domainneeded '1'
	option boguspriv '1'
	option filterwin2k '0'
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/lan/'
	option domain 'lan'
	option expandhosts '1'
	option nonegcache '0'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
	option nonwildcard '1'
	option localservice '1'
	option ednspacket_max '1232'

config dhcp 'lan'
	option interface 'lan'
	option start '100'
	option limit '150'
	option leasetime '12h'
	option dhcpv4 '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'

cat /etc/config/firewall
config defaults
	option syn_flood '1'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'REJECT'

config zone 'lan'
	option name 'lan'
	list network 'lan'
	list network 'vpn'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'
	list device 'tun+'

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

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 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 rule
	option name 'Support-UDP-Traceroute'
	option src 'wan'
	option dest_port '33434:33689'
	option proto 'udp'
	option family 'ipv4'
	option target 'REJECT'
	option enabled 'false'

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

config rule 'ovpn'
	option name 'Allow-OpenVPN'
	option src 'wan'
	option dest_port '1194'
	option proto 'udp'
	option target 'ACCEPT'

config rule 'wg'
	option name 'Allow-WireGuard'
	option src 'wan'
	option dest_port '51820'
	option proto 'udp'
	option target 'ACCEPT'