but over the wire, IP addresses are encoded in big-endian format.
here is the code that works with DNS A-Record lookup for Ipv4
private static byte[] DnsBytesReverseLookup(string IP)
{//Builds up a request for a Reverse DNS-Lookup
byte[] Head = SeedTheHead(DateTime.Now.Minute);
byte[] Footer = new byte[18] { 7, 105, 110, 45, 97, 100, 100, 114, 4, 97, 114, 112, 97, 0, 0, 12, 0, 1 };//in-addr.arpa
string[] IPDigits = IP.Split('.');
MemoryStream MS = new MemoryStream();
MS.Write(Head, 0, Head.Length);
byte[] IP0 = ByteString(IPDigits[0]); byte[] IP1 = ByteString(IPDigits[1]); byte[] IP2 = ByteString(IPDigits[2]); byte[] IP3 = ByteString(IPDigits[3]);
MS.Write(IP3, 0, IP3.Length); MS.Write(IP2, 0, IP2.Length); MS.Write(IP1, 0, IP1.Length); MS.Write(IP0, 0, IP0.Length);
MS.Write(Footer, 0, Footer.Length);
return MS.ToArray();
}
private static byte[] ByteString(string Value)
{//Used to build up a DNS request
byte[] B = new byte[Value.Length + 1];
B[0] = (byte)Value.Length;
B[1] = (byte)Value[0];
if (Value.Length > 1)
B[2] = (byte)Value[1];
if (Value.Length > 2)
B[3] = (byte)Value[2];
return B;
}
The order is backwards but it's not hex