Esempio n. 1
0
        // https://arsofttoolsnet.codeplex.com/discussions/654851
        static void TestUpdateAdd(System.Net.IPAddress dnsServerIP,
                                  ARSoft.Tools.Net.DomainName updateZoneName,
                                  ARSoft.Tools.Net.DomainName newRecordName,
                                  System.Net.IPAddress newRecordIPAddress,
                                  ARSoft.Tools.Net.DomainName tsigName,
                                  byte[] tsigKey)
        {
            var client = new DnsClient(dnsServerIP, 150000);

            client.IsUdpEnabled = false;

            var msg = new ARSoft.Tools.Net.Dns.DynamicUpdate.DnsUpdateMessage {
                ZoneName = updateZoneName
            };

            msg.Updates.Add(
                new ARSoft.Tools.Net.Dns.DynamicUpdate.AddRecordUpdate(
                    new ARecord(newRecordName, 86400, newRecordIPAddress)));

            msg.TSigOptions = new TSigRecord(tsigName, TSigAlgorithm.Md5, DateTime.Now, new TimeSpan(0, 0, 5),
                                             msg.TransactionID, ReturnCode.NoError, null, tsigKey);

            ARSoft.Tools.Net.Dns.DynamicUpdate.DnsUpdateMessage dnsResult = client.SendUpdate(msg);
            if (dnsResult == null)
            {
                Console.WriteLine("Failed sending message");
            }
            else
            {
                Console.WriteLine(dnsResult.ReturnCode); // FormatError
            }
        }
Esempio n. 2
0
        } // End Sub Test3 


        // Send dynamic update
        public static void Test4()
        {
            ARSoft.Tools.Net.Dns.DynamicUpdate.DnsUpdateMessage msg = new ARSoft.Tools.Net.Dns.DynamicUpdate.DnsUpdateMessage()
            {
                ZoneName = ARSoft.Tools.Net.DomainName.Parse("example.com")
            };

            msg.Updates.Add(new ARSoft.Tools.Net.Dns.DynamicUpdate.DeleteRecordUpdate(ARSoft.Tools.Net.DomainName.Parse("dyn.example.com"), RecordType.A));
            msg.Updates.Add(new ARSoft.Tools.Net.Dns.DynamicUpdate.AddRecordUpdate(
                new ARecord(ARSoft.Tools.Net.DomainName.Parse("dyn.example.com"), 300, System.Net.IPAddress.Parse("192.0.2.42"))));
            msg.TSigOptions = new TSigRecord(ARSoft.Tools.Net.DomainName.Parse("my-key"), TSigAlgorithm.Md5, System.DateTime.Now
                , new System.TimeSpan(0, 5, 0), msg.TransactionID
                , ReturnCode.NoError, null
                , System.Convert.FromBase64String("0jnu3SdsMvzzlmTDPYRceA==")
            );

            ARSoft.Tools.Net.Dns.DynamicUpdate.DnsUpdateMessage dnsResult = new DnsClient(System.Net.IPAddress.Parse("192.0.2.1"), 5000).SendUpdate(msg);
        } // End Sub Test4