Implement domain name analysis with dynamic host IP

zhaozj2021-02-11  159

[Author: wenhuah Add Time: 2001-5-2 12:24:33]

Source: www.chinaid.com.cn Objective To use an Internet DNS Host to direct domain names to the host (personal) host. CABLEMODEM is already very fast, and there is dynamic IP, so there is a domain name to Personal Machine Possible. Just get a very simple setting. For example, you have a domain called YourDomain.com, you can resolve this domain name. 1. Server (IP: AAAA) A small process of DNS dynamic resolution . YouDomain.com's domain name file for /var/named/yourdomain.com.Static (Template file can be used to generate YourDomain.com) (JDK1.3, Linux, find a network management Help it:) ================================================ ==== # original code as follows: ThreadDNSReloadServer.javaimport java.io *; import java.net *; public class ThreadDNSReloadServer {public static void main (String [] args) {int i = 1; try {ServerSocket s =.. New Serversocket (8189); for (;;) {socket incoming = S.Accept (); System.out.Println ("Accept New Client: i); New ThreadDnsReloadhandle (Incoming, i) .start (); i ;}} catch (Exception e) {System.out.println (e);}}} class ThreadDNSReloadHandle extends Thread {public ThreadDNSReloadHandle (Socket i, int c) {incoming = i; counter = c;} public void run () {Try {BufferedReader in = New BufferedReader (New InputStreamRea) DER (incoming.getinputStream ()); string user = "unkown"; string dnsfilepath = "/ var / named /"; string dnsfile = "youdomain.com"; string hostip = "127.0.0.1"; boolean user_validated = True Boolean Done = false; while (! Done) {string str = in.readline (); // validate user; if (str == null) DONE = true; else {str = str.trim (); if (STR) . Substring (0, 2). Equals ("la"

)) {IF (Str.Length ()> 2) user = str.substring (2);} if (str.substring (0, 2) .Equals ("lb")) {if (str.length ()> 2) DNSFILE = Str.Substring (2);} IF (Str.Substring (0, 2) .Equals ("lc")) {if (str.Length ()> 2) Hostip = Str.Substring (2); } IF (str.trim (). Equals ("BYE")) DONE = true;}}} incoming.close (); // Add user authentication. // Write the youdomain.com.cn.static file in the server yourdomain.com.cn the String DNSTMP = DNSFILEPATH DNSFILE ". static"; BufferedReader sin = new BufferedReader (new FileReader (DNSTMP)); PrintWriter sout = new PrintWriter (new FileWriter (DNSFILEPATH DNSFILE), true); String s WHILE ((s = sin.readline ())! = Null) {if (s.startswith ("Host")) {s = "host in a" hostip; sout.println (s); s = "@ IN a " hostip;} Sout.println (s);} //system.out.println ("user:" user); //system.out.println ("dnsfile: " DNSFILE); // system .out.println ("Hostip:" Hostip); // ndc reload string command = "ndc reload" DNSFILE; java.lang.Runtime.Getruntime (). EXEC (Command);} catch (exception e) {system.out.println (e);}} private socket incoming Private int counter;} 2. Client (Windows / Linux) =================================== ===========================

转载请注明原文地址:https://www.9cbs.com/read-5668.html

New Post(0)