歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> 關於Unix

一步步從Win2kDNS移植到Linux下

一、准備工作: 首先進入win2k, DNS 服務管理器,選 查看--列表; 然後導出列表到一個文件: mydomain.txt 進入 \winnt\system32\dns 將所有文件打包,和mydomain.txt 一起復制到linux下。 二、開始遷移: 1、生成配置文件: 主域配置文件: 執行如下腳本:
  一、准備工作:
  首先進入win2k, DNS 服務管理器,選 查看--列表;
  然後導出列表到一個文件: mydomain.txt
  
  進入 \winnt\system32\dns 將所有文件打包,和mydomain.txt 一起復制到linux下。
  
  二、開始遷移:
  1、生成配置文件:
  
  主域配置文件:
  執行如下腳本:
  
  #!/usr/bin/perl
  ##################################################################
  $configfile = "/etc/named.conf";
  $dnsfile = "/var/named";
  $importfile = "mydomain.txt";
  
  system("/bin/echo > $configfile");
  
  open(OUTFILE,">>$configfile");
  flock (OUTFILE,2);
  print OUTFILE "options {\n";
  print OUTFILE " directory \"$dnsfile\";\n";
  print OUTFILE " forwarders {\n";
  print OUTFILE " 202.96.199.133;\n";
  print OUTFILE " 202.96.209.5;\n";
  print OUTFILE " };\n";
  print OUTFILE "};\n";
  print OUTFILE "zone \".\" {\n";
  print OUTFILE " type hint;\n";
  print OUTFILE " file \"named.ca\";\n";
  print OUTFILE "};\n";
  
  open(INFILE,$importfile);
  @lines = <INFILE>;
  
  $num=0;
  foreach $line (@lines) {
  
  chop ($line);
  print OUTFILE "zone \"$line\" {\n";
  print OUTFILE " type master;\n";
  print OUTFILE " file \"$line.dns\";\n";
  print OUTFILE "};\n";
  
  $num ++;
  }
  close(INFILE);
  close (OUTILE);
  print "$num Record convert!!\n";
  
  exit;
  
  生成備份域配置文件: 執行這個腳本:
  
  #!/usr/bin/perl
  ##################################################################
  $configfile = "/etc/named.conf";
  $dnsfile = "/var/named";
  $importfile = "mydomain.txt";
  $masterns = "1.1.1.";
  
  system("/bin/echo > $configfile");
  
  open(OUTFILE,">>$configfile");
  flock (OUTFILE,2);
  print OUTFILE "options {\n";
  print OUTFILE " directory \"$dnsfile\";\n";
  print OUTFILE " forwarders {\n";
  print OUTFILE " 202.96.199.133;\n";
  print OUTFILE " 202.96.209.5;\n";
  print OUTFILE " };\n";
  print OUTFILE "};\n";
  print OUTFILE "zone \".\" {\n";
  print OUTFILE " type hint;\n";
  print OUTFILE " file \"named.ca\";\n";
  print OUTFILE "};\n";
  
  open(INFILE,$importfile);
  @lines = <INFILE>;
  
  $num=0;
  foreach $line (@lines) {
  
  chop ($line);
  print OUTFILE "zone \"$line\" {\n";
  print OUTFILE " type slave;\n";
  print OUTFILE " file \"$line.dns\";\n";
  print OUTFILE " masters { $masterns; };\n";
  print OUTFILE "};\n";
  
  $num ++;
  }
  close(INFILE);
  close (OUTILE);
  print "$num Record convert!!\n";
  
  exit;
  
  2、復制DNS記錄:將從windows下復制過來到dns文件復制到 /var/named 下;
  
  主備域此操作相同。
  
  3、在/var/named下執行:
  
  mv CACHE.DNS named.ca #配置文件windows和linux命名不同。
  chown named:named * #更改所有者
  chmod 644 * #更改權限
  
  4、編輯 /etc/resolv.conf 如下:
  
  search mydomain.com.cn
  domain mydomain.com.cn
  nameserver 1.1.1.1
  nameserver 202.96.199.133
  nameserver 202.96.209.5
  
  5、啟動named服務。 /etc/init.d/named start
  6、關閉原來的NS服務器
  7、將linux服務器的IP改成win2k的IP。
  
  現在你可以把原來的NS服務器格式化,裝個XP打CS啦。。。

Copyright © Linux教程網 All Rights Reserved