From: Rafael D. <raf...@ki...> - 2010-11-03 21:17:24
|
As i have read, problems due to the code must be sent through this list, so, here we go! :) Well, using the Eclipse Galileo for windows over here. I´m coding a small void main trying to test the DNS Dynamic update example from the oficial website. My idea is that when my DNS fails this small code could use another DNS so that my application keep working properly. Resume: If the default DNS fails, the dynamic update could bring me, in some sort of a real time, another DNS that works (8.8.8.8. google dns maybe). this is the code: public static void DNSDynamicUpdate() throws Exception { System.out.println("\n" + "DNSDynamicUpdate" + "\n"); String selfHost = "192.168.0.156"; String hostIP = "128.63.2.53";//one of the root dns //google dns 8.8.8.8 String gateway = "192.168.0.254";//my wireless gateway if(QueryRemoteserver(hostIP)) { Name zone = Name.fromString(" root-servers.net."); Name host = Name.fromString("h", zone); Update update = new Update(zone); update.replace(host, Type.A, 3600, gateway); Resolver res = new SimpleResolver(hostIP); //com md5 res.setTSIGKey(new TSIG(host, base64.fromString("1234"))); //res.setPort(53); res.setTCP(true); Message response = res.send(update); System.out.println("\n" + response + "\n"); } } public static boolean QueryRemoteserver(String hostIP) throws Exception { if(hostIP == null) hostIP = "128.63.2.53"; System.out.println("\n" + "QueryRemoteserver" + "\n"); Lookup l = new Lookup("version.bind.", Type.TXT, DClass.CH); l.setResolver(new SimpleResolver()); l.run(); if (l.getResult() == Lookup.SUCCESSFUL) { System.out.println(l.getAnswers()[0].rdataToString()); return true; } else { System.out.println(l.getAnswers()[0].rdataToString()); return false; } } response: ;; ->>HEADER<<- opcode: UPDATE, status: NOTIMP, id: 48592 ;; flags: qr ; qd: 0 an: 0 au: 0 ad: 0 ;; TSIG invalid ;; ZONE: ;; PREREQUISITES: ;; UPDATE RECORDS: ;; ADDITIONAL RECORDS: ;; Message size: 12 bytes Thanks in advance... PS: NOTAUTH was the most received message in my "testes" |