编辑这个文件 WINNT\system32\drivers\etc\hosts
添加你解析的域名
例如
127.0.0.1 csdn.net #csdn
之后csdn.net域名ip地址就被解析成你本机了

解决方案 »

  1.   

    /**
     * 本文件归属SynchroFLOW3.0 ,未经许可,不得擅自使用、拷贝和修改。
     * 开发公司:SYNCHROBIT
     * 项目组:SynchroFLOW HACluster项目组
     * 开发日期:2003-8-16
     * @author 郭胜旺
     * @version 3.0
     */package com.synchrobit.synchroflow.hacluster;import java.io.*;
    import java.net.*;
    import java.util.*;
    import org.xbill.DNS.*;
    import org.xbill.DNS.utils.*;import org.apache.log4j.Logger;/**
     * 此程序用于动态更改HACluster的IP地址
     * 调用时:
     * 1.通过构造函数创建一实例化对象(同时传递了区域名,集群服务器名,集群服务器新的IP地址,DNS服务器的IP地址{事务签名码}等的形参值)
     * 2.调用boolean型update()方法,若正确更改IP则返回true,否则返回false
     */public class UpdateDNS
    {
      private static String zoneStr;
      private static String hostStr;
      private static String DNSServerIP;
      private static String haClusterIP;
      private static byte[] TSIGKey = base64.fromString("1324") ;
      private static Logger log = Logger.getRootLogger();
      private static StringManager strm=null;  /**
       * 构造函数
       * @param zoneStr:区域名
       * @param hostStr:集群服务器名
       * @param haClusterIP:集群服务器IP
       * @param DNSServerIP:需制定的DNS服务器IP
       * @param TSIGKey:事务验证码
       */
      public UpdateDNS(String zoneStr,String hostStr,String haClusterIP,String DNSServerIP,byte[] TSIGKey)
      {
        if (zoneStr.substring(zoneStr.length()-1).equals("."))
          this.zoneStr = zoneStr.toString().trim();
        else
          this.zoneStr = zoneStr.toString().trim()+".";
          this.hostStr = hostStr;
          this.DNSServerIP = DNSServerIP.trim();
          this.haClusterIP = haClusterIP.trim();
          this.TSIGKey = TSIGKey;
        }    /**
         * 构造函数
         * @param zoneStr:区域名
         * @param hostStr:集群服务器名
         * @param haClusterIP:集群服务器IP
         * @param DNSServerIP:需制定的DNS服务器IP
         */
        public UpdateDNS(String zoneStr,String hostStr,String haClusterIP,String DNSServerIP)
      {
        if (zoneStr.substring(zoneStr.length()-1).equals("."))
        {
          this.zoneStr = zoneStr.toString().trim();
        }
        else this.zoneStr = zoneStr.toString().trim()+".";
        this.hostStr = hostStr;
        this.DNSServerIP = DNSServerIP.trim();
        this.haClusterIP = haClusterIP.trim();
      }  /**
       * 当集群某个节点失败时,更改集群的IP地址
       * @return:返回更改成功与否
       */
      public boolean update()
      {
        Locale locale=Locale.getDefault();
        strm=StringManager.getManager("com.synchrobit.synchroflow.hacluster",locale);
        try
        {
          Name zone = Name.fromString(this.zoneStr);
          Name host = Name.fromString(this.hostStr,zone);
          Update update = new Update(zone);
          update.replace(host,Type.A,3600,this.haClusterIP);
          Resolver res  = new SimpleResolver(this.DNSServerIP);
          if (this.TSIGKey.toString().equals("[B@7d13b5"))
            res.setTSIGKey(host,base64.fromString("1324"));
          else
            res.setTSIGKey(host,TSIGKey);
          res.setTCP(true);
          Message response = res.send(update);
          return true;
        }
        catch (TextParseException et)
        {
          log.warn(strm.getString("HACluster.usage.options.ZoneOrHostInputError")
                 + Tool.getExceptionInfo(et));
          return false;
        }
        catch (UnknownHostException eu)
        {
          log.warn(strm.getString("HACluster.usage.options.DNSServerIPError")
                 + Tool.getExceptionInfo(eu));
          return false;
        }
        catch (IOException ei)
        {
          log.warn(strm.getString("HACluster.usage.options.HAClusterIPChageError")
                 + Tool.getExceptionInfo(ei));
          return false;
        }
      }
    /** test
      public static void main(String args[]) throws IOException
      {
        UpdateDNS upDate = new UpdataDNS("workflow.com","gsw","168.160.12.122","168.160.12.14");
        upDate.update();
      }
     */
    }
      

  2.   

    上面是我在一个公司时的编码,你到网上把jar包下下来