mydns mysql_轻便的MYDNS

案例:

搭建mydns

环境:redhat 5.4

软件:mysql mysql-server php mydns(http://mydns.bboy.net/)

安装步骤:

1、准备工作(配置本地yum)e47d5ee77676010ff2cc847b241ca7c8.png1fa840c45d0b9dcb8da7dee2f0057380.png 44ca7792b4557afb1fba60fc34f6a167.png 4f047bc818a29df6125964943f9f44c7.png

2、安装mysql

35f5054e56b9086c0e2df333c054b7d8.png 576520d18d44a1ab9bf6e25a9e91ed50.png

3、安装http

e7ceaacbf5a76263e05dbcf9ffc44c79.png 76c290752ae97dc9c671eebbd5d17a0f.png 0d35e878030e39e3c9019d0d96e68b57.png

4、安装php

c6d014c2250ac655cbeb37545b3d5bdc.png 7a058d4c20f729b793c0288374e4706c.pngcb7476beccc332f9dc8c65549c110fb0.png

5、安装mydns

5fc279bfdfa2abfb0a746e5d535f7b24.png c8b9595d07950e873f01dca17326d23d.png 6eb9ac7d3e536d3ea7cd1681d7280912.png

9db19d603abd852e2dd5a8cf428e5e47.png

b09ad70dbbb38180a6c4a81b1c00d695.png

6、配置

a、数据库配置

创建数据库

mysqladmin  -u root -p create mydns

4d2d92d47efebc58b80677e3df566ae0.png

//建立用户mydns,密码mydns

mysql>insert into mysql.user (host,user,password) values ('localhost','mydns',password('mydns'));

//重载MySQL授权表

mysq>flush privileges;

5325ae2aad055706be21d3432ec2efa4.png

把数据mydns授权于用户mydns

mysql>grant all on mydns.* to mydns@'localhost' identified by 'mydns';

创建soa表

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;

创建rr表

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; l

d53cb3ed48e8603ae0f0db67f2c9316e.png

添加区域

insert into soa values (1,'crazylinux.cn.','ns.crazylinux.cn.','root.crazylinux.cn.',2011060114,1800,7200,604800,360,1800);

添加条A记录www.crazylinux.cn解析到172.16.6.202

insert into rr values (1,1,'www','A','172.16.6.202',0,360);

添加条cname记录so.crazylinux.cn解析到so.crazylinux.cn.test.com.

insert into rr values (2,1,'so','CNAME','so.crazylinux.cn.test.com.',0,360);

c31dce986b3424b0246e3d4d464f1e66.png

b、配置mydns

生成主配置文件:

/usr/local/mydns/sbin/mydns  --dump-config > /etc/mydns.conf

2330c7e8859dc44a3ae7bc7edb233ba3.png

修改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 = 192.168.102.188           # 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

c、配置web页面

f315560701c38984d479a7401eb4e7fa.png

99a8e7fe15196ce6d3c2ec7c647f426e.png

修改这些内容

dbhost = "localhost";

$dbuser = "mydns";

$dbpass = "mydns";

$dbname = "mydns";

5e82a344ceaf63e99391b5389c537b3b.png

88d485e834e7fbf408aa3a99200b6055.png

7、测试

在地址栏输入

http://mydns服务器ip/admin.php

ddd6fc655a8fbe24baff2c67d832c5ba.png

点一下浏览,可以看到我们在数据库中添加的域

495dfb700a58ebf7d118e75a0295ac8c.png

点击,可以看得此域的详细信息

db4ae3b0a5e19cbf590b5b347b1bd9b3.png

新建一个

0b541c82441932d5517094eca69b5216.png

c75d3c35cf6ddb321ae5d4607614afaf.png

新建一个域,点击new

45f3c8aaa005b5a1e78221d8c4afccd9.png

填入详细信息

cb746cac6a23c126cf8e16fad7df877b.png

在另一台主机上将dns指向mydns服务器

29c9d8a7d7152a645c86ce273a974fc6.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值