当前位置:七道奇文章资讯系统安全Linux安全
日期:2011-06-03 17:19:00  来源:本站整理

利用mydns构建自己的DNS服务器[Linux安全]

赞助商链接



  本文“利用mydns构建自己的DNS服务器[Linux安全]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
  环境:
  Centos 5.4
  利用软件:
  wget http://mydns.bboy.net/download/mydns-1.1.0.tar.gz
  wget http://soft.vpser.net/datebase/mysql/mysql-5.1.54.tar.gz
  安装前预备:
  yum -y install gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip
  1、安装mysql数据库
  tar zxvf mysql-5.1.54.tar.gz
  cd mysql-5.1.54
  ./configure  --prefix=/usr/local/mysql --with-extra-charsets=all --enable-thread-safe-client --enable-assembler --with-charset=utf8 --with-extra-charsets=all --with-
  big-tables --with-readline --with-ssl --with-embedded-server --enable-thread-safe-client --enable-local-infileser
  make
  make install
  groupadd mysql
  useradd -s /sbin/nologin  -M -g mysql mysql
  cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
  sed -i 's/skip-locking/skip-external-locking/g' /etc/my.cnf
  /usr/local/mysql/bin/mysql_install_db --user=mysql
  chown -R mysql /usr/local/mysql/var
  chgrp -R mysql /usr/local/mysql/.
  cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
  chmod 755 /etc/init.d/mysql
  vim /etc/ld.so.conf.d/mysql.conf增添以下:
  /usr/local/mysql/lib/mysql
  /usr/local/lib
  ldconfig
  ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
  ln -s /usr/local/mysql/include/mysql /usr/include/mysql
  /etc/init.d/mysql start
  ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
  ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
  ln -s /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk
  /usr/local/mysql/bin/mysqladmin -u root password  123456  设置密码
  2、安装mydns:
  tar zxvf mydns-1.1.0.tar.gz
  ./configure  --prefix=/usr/local/mydns --with-mysql-lib=/usr/local/mysql/lib/mysql/ --with-mysql-include=/usr/local/mysql/include/mysql/
  make && make install
  /usr/local/mysql/bin/mysqladmin  -uroot -p create mydns  成立dns数据库
  mysql>insert into mysql.user (host,user,password) values ('localhost','mydns',password('mydns'));     //成立用户mydns,密码mydns
  mysq>flush privileges;    //重载MySQL受权表
  mysql>grant all on mydns.* to mydns@'localhost' identified by 'mydns'; 把数据mydns受权于用户mydns
  生成主配置文件:
  /usr/local/mydns/sbin/mydns  --dump-config > /etc/mydns.conf
  3、配置mydns:
  改正mydns.conf以下:
  # DATABASE INFORMATION
  db-host = localhost             # SQL server hostname
  db-user = mydns                 # SQL server username
  db-password = mydns             # SQL server password
  database = mydns                # MyDNS database name
  # GENERAL OPTIONS
  user = mydns                    # Run with the permissions of this user
  group = mydns                   # Run with the permissions of this group
  listen = 172.16.6.200                   # Listen on these addresses ('*' for all)
  no-listen =                     # Do not listen on these addresses
  # CACHE OPTIONS
  zone-cache-size = 1024          # Maximum number of elements stored in the zone cache
  zone-cache-expire = 60          # Number of seconds after which cached zones expires
  reply-cache-size = 1024         # Maximum number of elements stored in the reply cache
  reply-cache-expire = 30         # Number of seconds after which cached replies expire
  # ESOTERICA
  log = LOG_DAEMON                # Facility to use for program output (LOG_*/stdout/stderr)
  pidfile = /var/run/mydns.pid    # Path to PID file
  timeout = 120                   # Number of seconds after which queries time out
  multicpu = 1                    # Number of CPUs installed on your system
  recursive = 8.8.8.8             # Location of recursive resolver把解析不了的转发到8.8.8
  recursive-timeout =             # Number of seconds before first retry
  recursive-retries =             # Number of retries before abandoning recursion
  recursive-algorithm =           # Recursion retry algorithm one of: linear, exponential, progressive
  allow-axfr = yes                # Should AXFR be enabled?
  allow-tcp = yes                 # Should TCP be enabled?
  allow-update = no               # Should DNS UPDATE be enabled?
  ignore-minimum = no             # Ignore minimum TTL for zone?
  soa-table = soa                 # Name of table containing SOA records
  rr-table = rr                   # Name of table containing RR data
  soa-where =                     # Extra WHERE clause for SOA queries
  rr-where =  # Extra WHERE clause for RR queries
  /usr/local/mydns/sbin/mydns  --background  放入后台运行mydns
  /usr/local/mydns/sbin/mydns  reload  重新加载配置文件
  /usr/local/mydns/sbin/mydns restart 重新启动mydns
  4、测试增添呼应记录:
  use mydns;
  CREATE TABLE soa (
  id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
  origin CHAR(255) NOT NULL,
  ns CHAR(255) NOT NULL,
  mbox CHAR(255) NOT NULL,
  serial INT UNSIGNED NOT NULL DEFAULT '20110601',
  refresh INT UNSIGNED NOT NULL DEFAULT '1800',
  retry INT UNSIGNED NOT NULL DEFAULT '7200',
  expire INT UNSIGNED NOT NULL DEFAULT '604800',
  minimum INT UNSIGNED NOT NULL DEFAULT '300',
  ttl INT UNSIGNED NOT NULL DEFAULT '1800'
  ) TYPE=MyISAM;   成立soa表
  CREATE TABLE rr (
  id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
  zone INT UNSIGNED NOT NULL,
  name CHAR(64) NOT NULL,
  type ENUM('A','AAAA','CNAME','HINFO','MX','NS','PTR','RP','SRV','TXT') NOT NULL,
  data CHAR(128) NOT NULL,
  aux INT UNSIGNED NOT NULL,
  ttl INT UNSIGNED NOT NULL DEFAULT '36000'
  ) TYPE=MyISAM;  成立rr表
  增添数据:
  insert into soa values (1,'crazylinux.cn.','ns.crazylinux.cn.','root.crazylinux.cn.',2011060114,1800,7200,604800,360,1800);
  insert into rr values (1,1,'www','A','172.16.6.202',0,360);增添条A记录www.crazylinux.cn解析到172.16.6.202
  insert into rr values (2,1,'so','CNAME','so.crazylinux.cn.test.com.',0,360);增添条cname记录so.crazylinux.cn解析到so.crazylinux.cn.test.com.
  mysql> select * from rr;
  +----+------+------+-------+----------------------------+-----+-----+
  | id | zone | name | type  | data                       | aux | ttl |
  +----+------+------+-------+----------------------------+-----+-----+
  |  1 |    1 | www  | A     | 172.16.6.202               |   0 | 360 |
  |  2 |    1 | so   | CNAME | so.crazylinux.cn.test.com. |   0 | 360 |
  +----+------+------+-------+----------------------------+-----+-----+
  2 rows in set (0.00 sec)
  测试:
  [root@localhost ~]# dig  @172.16.6.200 www.crazylinux.cn
  ; <<>> DiG 9.3.4-P1 <<>> @172.16.6.200 www.crazylinux.cn
  ; (1 server found
  以上是“利用mydns构建自己的DNS服务器[Linux安全]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
  • 利用mydns构建自己的DNS服务器
  • 在服务器上安装、利用MySQL的注意事项(2)
  • 在服务器上安装、利用MySQL的注意事项(1)
  • 在服务器上安装、利用MySQL的注意事项
  • 怎样在vc、delphi中利用mysql(mysql odbc驱动的利用)
  • 在服务器上安装利用MySQL的注意事项
  • 怎样在vc、delphi中利用mysql
  • 在服务器上安装和利用MySQL的注意事项
  • 利用MySQL内建复制功效来最佳化可用性
  • 若何安全的远程利用MySQL GUI工具
  • 利用MySql ODBC举行MYsql和MS sql7的数据转换
  • <b>精密讲授远程安全若何利用MySQL GUI工具</b>
  • 本文地址: 与您的QQ/BBS好友分享!
    • 好的评价 如果您觉得此文章好,就请您
        0%(0)
    • 差的评价 如果您觉得此文章差,就请您
        0%(0)

    文章评论评论内容只代表网友观点,与本站立场无关!

       评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
    Copyright © 2020-2022 www.xiamiku.com. All Rights Reserved .