Wireguard Unable to use hostname as Endpoint

Started by crankshaft, May 12, 2023, 12:02:18 PM

Previous topic - Next topic
I need to use a hostname as the host is a dynamic IP.

wireguard supports Peer Endpoints as both IP addresses and hostnames, but if I set a hostname in the opnsense Endpoint, the settings get saved, but when applied, the wg handshake fails.

The hostname:port is saved correctly to the /usr/local/etc/wireguard/wgX.conf file.

I noticed that the pinger fails to start, and if I try and manually restart the wireguard service from the command line I get an error:

[#] ifconfig wg create name wg5
[#] wg setconf wg5 /dev/stdin
Name does not resolve: `somedomain.xxx.net:51820'
Configuration parsing error
[#] ifconfig wg5 destroy
ifconfig: interface wg5 does not exist


So my guess is that the script which attempts to resolve the endpoint, is probably configured to only regex filter an ip address and that is why the resolve is failing and the connection never succeeds.

The strange thing is that I have 2 wireguard configs that both use a hostname, one on wg2 and the other on wg5, the one on wg2 starts successfully but wg5 does not.

I have compared the configs between wg2 and wg5, as well as the interface and gateway settings for both and as far as I can tell they are both configured the same way, other than of course the hostname and ip settings.

Is anyone else successfully running multiple wg interfaces using hostnames as the Endpoints ? 

Is there a fix / workaround for this ?

works fine here. which versions are you on?
kind regards
chemlud
____
"The price of reliability is the pursuit of the utmost simplicity."
C.A.R. Hoare

felix eichhorns premium katzenfutter mit der extraportion energie

A router is not a switch - A router is not a switch - A router is not a switch - A rou....

Please double-check you didn't make a typo, try "host somedomain.xxx.net" in OPNsense and see if it really resolves.

Quote from: crankshaft on May 12, 2023, 12:02:18 PMIs anyone else successfully running multiple wg interfaces using hostnames as the Endpoints ? 
I only use hostnames, and it works except boot, where in the infamous race, WG starts before all DNS. So I have to restart WG every boot.