damob-byun / WireGuardNTSharp

WireGuard Simple Windows Cli and WireGuard NT Wrapper for C#(Csharp) with P/Invoke
GNU General Public License v2.0
48 stars 6 forks source link

not workig #6

Open xkajxkajx opened 3 months ago

xkajxkajx commented 3 months ago

When running "WireGuard-Cli.exe -c client.conf", I got this error:

OpenAdapter Fail And Now Start Create... : 1168 Unhandled exception. System.Net.Sockets.SocketException (11001): No such host is known. at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, ValueStopwatch stopwatch) at System.Net.Dns.GetHostEntry(String hostNameOrAddress, AddressFamily family) at WireGuardNT_PInvoke.Adapter.ParseConfFile(String[] lines, WgConfig& wgConfig) in C:\Users\ablestor-bjs\Documents\GitHub\WireGuardNTSharp\WireGuardNT-PInvoke\Adapter.cs:line 92 at WireGuardCli.Program.Main(String[] args) in C:\Users\ablestor-bjs\Documents\GitHub\WireGuardNTSharp\WireGuard-Cli\Program.cs:line 118

damob-byun commented 3 months ago

It looks like you didn't write the host address correctly or it's a DNS issue. Try writing the IP address in the address line of your config file

xkajxkajx commented 2 months ago

OK, could you please check my config file and see what's wrong with it:


[Interface] PrivateKey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx= Address = 172.16.0.2/32 Address = 2606:4700:110:8bc1:cd08:82cc:d807:6ef9/128 DNS = 1.1.1.1, 1.0.0.1, 2606:4700:4700::1111, 2606:4700:4700::1001 MTU = 1280 [Peer] PublicKey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx= AllowedIPs = 0.0.0.0/0 AllowedIPs = ::/0 Endpoint = engage.cloudflareclient.com:2408

voidZiAD commented 1 month ago

Did you find a solution @xkajxkajx or not?

alphons commented 5 days ago

I looks like this project is sort of abandoned... For one of the errors mentioned (host), it can be solved by changing lines 180 - 190 of Adapter.cs Parsing of interface address is not valid, only the network is set. And dont forget, it is IPv4 only, so skipp the IPv6 addressing.

case "address":
   string address = value.Split(',').First().Trim();
   if (ValidateIPv4(address))
   {
        wgConfig.InterfaceNetwork = IPNetwork.Parse(value.Split(',').First());
    }
    else
    {
       var ipEntry = Dns.GetHostEntry(address);
       wgConfig.InterfaceNetwork = IPNetwork.Parse(ipEntry.AddressList[0].ToString());
     }

We can do better when the interface is specified using cidr for example: 10.0.0.1/24 And specifying a DNS name for a local interface address is a bit of so we dont need the Dns.GetHostEntry.

case "address":
   wgConfig.InterfaceNetwork = IPNetwork.Parse(value);
   wgConfig.InterfaceAddress = IPAddress.Parse(value.Split('/')[0]);
   continue;