Skip to content

Instantly share code, notes, and snippets.

@protectroot-com
Last active March 6, 2021 19:08
Show Gist options
  • Save protectroot-com/22e1ae7f31b5c7a77e8c77c0efd2708f to your computer and use it in GitHub Desktop.
Save protectroot-com/22e1ae7f31b5c7a77e8c77c0efd2708f to your computer and use it in GitHub Desktop.
C# .net core 5.0 DOH query
using System;
using Makaretu.Dns;
// add the Makaretu.Dns.Unicast Nuget package.
namespace testing123
{
class Program
{
static void Main(string[] args)
{
//add the Makaretu.Dns.Unicast Nuget package.
Console.WriteLine("starting..");
var result = yeet();
//it works!
}
public static async System.Threading.Tasks.Task yeet ()
{
var dns = new Makaretu.Dns.DohClient();
//pick your doh url ---> github.com/curl/curl/wiki/DNS-over-HTTPS
//using xfinity as dns over https server.
dns.ServerUrl = "https://doh.xfinity.com/dns-query";
//query for twitter IP
var response = dns.QueryAsync("twitter.com", DnsType.A);
Console.WriteLine(response.Result.Answers.Count);
foreach (var item in response.Result.Answers)
{
Console.WriteLine(item.ToString());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment