I have my OpenWRT router which also works as wireguard server for my devices. My router was connected to the bridged port of the router provided my ISP (OpenWRT router obtained public ipv4 address, public ipv6 address and ipv6 prefix) and my clients could connect to wireguard server (in both ipv4 and ipv6 modes). My ISP decided not to allow bridged ports anymore, so my OpenWRT router WAN address became 192.168.64.100 (while my ISP router has 192.168.64.1 ipv4 address). My OpenWRT device is still in the router mode (all local connected devices are on 192.168.1.x subnet and receive ipv6 addresses by wan/lan dhcpv6 relay mode). However, there is a problem now with wireguard. While my devices can still connect to wireguard server, there is no (or very little data exchange going on between server and clients and the internet does not work). I can see clients connected to wireguard server (in Luci wireguard overview tab), but no handshake happens between clients and server. My ISP router has very limited settings, but I managed to forward UDP 51820 (wireguard port) to 192.168.64.100 (OpenWRT router "WAN" address). If needed, I can share my wireguard setup information later (however, it is a fairly standard one). Do you have any ideas what to do to convince wireguard to work in such a stupid network?
Does your ISP router have a proper public IPv4 address on its wan? That will be required.
Let's see your current config:
Please connect to your OpenWrt device using ssh and copy the output of the following commands and post it here using the "Preformatted text </> " button:
Remember to redact passwords, MAC addresses and any public IP addresses you may have:
ubus call system board
cat /etc/config/network
cat /etc/config/firewall
wg show
I already forwarded the required port from my ISP router. But it does not solve the problem. One additional (obvious) observation. If I connect to wireguard from my lan network, the connection works as expected.
Remove list dns '192.168.1.1' you cannot point DNSMasq to itself
Remove option masq '1'
For your client configs for the time being do not use 192.168.1.1 as DNS server it is possible the DNSMasq is not listening on the WG interface or only services local subnets, so for now use e.g. 9.9.9.9
wg show shows last handshake 16 hours ago so reboot the router and check again with wg show after trying to connect form outside
You can see if there is traffic coming from the ISP router (after you tried to connect from outside) with: nft list chain inet fw4 input_wan
No, WireGuard does not use these protocols to open/forward ports.
The ports must be opened and/or forwarded manually. The OP's config shows that they do have the port open on the wan, and they said that they had done the port forward from the upstream router to OpenWrt.
Yes, wireguard does not do it, but you can open public UDP listener manually and acquire hostname via some ddns and get incoming connections via double- or cg- nats
Generally speaking, no, this isn't going to work for WG. There may be tricks that could make this plausible, but it would be quite fragile and may also be a bad idea for security. For users who have CG-NAT or double-NAT for which they cannot setup port forwards, the recommended path is to use something like zerotier or Tailscale. But this doesn't currently seem to be relevant to the OP's situation based on the previous parts of the discussion (unless we learn otherwise as we move forward).
I changed configuration as suggested by egc, but wireguard still does not work. The handshake was successful when I connected to wireguard from my lan. I think this is the part related to wireguard if I run: nft list chain inet fw4 input_wan
I deleted 51820 port forward on my ISP router and created the same rule once again. Now it works Something must have gone wrong when I created the rule for the first time (I need to log in to my ISP website and remotely change router settings, it is not done locally...).
I have another challenge for you. How to enable ipv6 on such configuration? I remember I once used NATv6 to do this, before I managed to properly setup wireguard (but that was when I had 64-bit prefix delegated by the ISP).
I have it running with IPv6, I use ULA addresses with NAT66, I know there are other ways using GUA addresses with a PD of the router, but I have dynamic prefixes so I did not venture into that direction.
The error repeated today. So, again there is no handshake between client and server. I tried adding/removing ISP router port forward rule multiple times, but to no avail. I guess there is nothing I can do (all wireguard/OpenWRT configs seem to be fine) to make it work reliably. So I either not use wireguard anymore (frankly, I have no urgent need to use it anymore) or pay my ISP additional fee to allow me to use public IP on my OpenWRT router.