Implement domain name analysis with dynamic host IP

zhaozj2021-02-11  215

Implement domain name analysis with dynamic host IP

Wenhuah (2001-03-20 11:26) 〖Back〗 〖Forward〗

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 possibility of resolving the domain name to a personal machine. As long as it is very simple Settings can be done. For example, you have a domain called YourDomain.com, you can parse this domain name. 1. Server (IP: AAAA) Start a small process of DNS dynamic resolution. YourDomain.com's domain name file for / VAR / Named / YourDomain.com built again /var/named/yourdomain.com.Static (Template file can be used to generate youdomain.com) (JDK1.3, Linux, find a network management to help:) ==== ==================================================== # The original code is 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 INPUTSTREAMREAD Er (incoming.getinputstream ()); string user = "unkown"; string dnsfilepath = "/ var / named /"; string dnsfile = "YourDomain.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 (); // joins user authentication. // Put the youdomain.com.cn.static file in the server yourdomain.com.cn written in 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.pri NTLN ("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-3506.html

New Post(0)