p; 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.客户机(windows / linux)
==============================================================
# 客户端每次启动时加入到开机启动(或进程中): SockTest.java
import java.io.*;
import java.net.*;
public class SocketTest
{ public static void main(String args)
{ try
{ Socket s=new Socket("A.A.A.A",8189);
BufferedReader in=new BufferedReader(new InputStreamReader(s.getInputStream()));
PrintWriter out=new PrintWriter(s.getOutputStream(),true);
InetAddress localHostAddress =InetAddress.getLocalHost() ; //get LocalHost Ip
out.println("LAguest");
out.println("LByourdomain.com");
out.println("LC" + localHostAddress.getHostAddress() );
out.close();
s.close();
}
catch (IOException e)
{ System.out.println(e);
}
}
}
=========================================================
dns 样本文件: ( yourdomain.com.static)
@ ns.dnsserver.com xxxxx
&nb