存档

‘DNS’ 分类的存档

FreeBSD: Redundant DNS with CARP

2010年12月11日 16hot 没有评论

http://zi0r.com/2010/02/28/freebsd-redundant-dns-with-carp.html

Improve reliability with CARP and redundant DNS on two boxes. Almost everyone already has (at least) two nameservers, so why not add CARP into the mix to make it appear as if they’re always available?

This setup assumes two nameservers. Both nameservers will have a total of 3 IPs assigned to them, two of which are the floating CARP IPs and one of which is a unique management IP for each box. Each nameserver will be the CARP backup for the other nameservers primary nameserver IP. If one goes down, the other will assume responsibility for the IP.

You’ll need to assign your nameservers two new IPs (to be used for management) and take the original pair of IPs and we’ll use those for the carp interfaces.

1. Rebuild/install your kernel with:
device carp

2. Edit /etc/rc.conf to add:
cloned_interfaces=“carp0 carp1”
ifconfig_carp0=“create”
ifconfig_carp1=“create”

3. Setup the CARP interfaces:

I set the vhid’s to be the last octet of the floaty IP, however, you can set them to be whatever you want as long as they match on both boxes.

On ns1:
Create /etc/start_if.carp0 with the following:
#!/bin/sh
ifconfig carp0 vhid XX advbase 1 advskew 10 pass supersecretpasswordhere netmask

Create /etc/start_if.carp1 with the following:
#!/bin/sh
ifconfig carp1 vhid YY advbase 2 advskew 10 pass othersupersecretpasswordhere netmask

Then run:
chmod go-rwx /etc/start_if.carp*;chmod +x /etc/start_if.carp*

On ns2:
Create /etc/start_if.carp0 with the following:
#!/bin/sh
ifconfig carp0 vhid YY advbase 1 advskew 10 pass supersecretpasswordhere netmask

Create /etc/start_if.carp1 with the following:
#!/bin/sh
ifconfig carp1 vhid XX advbase 2 advskew 10 pass othersupersecretpasswordhere netmask

Then run:
chmod go-rwx /etc/start_if.carp*;chmod +x /etc/start_if.carp*

  • carp0 on both boxes will be its PRIMARY IP whereas carp1 will be the SECONDARY IP on both. In a non-failover scenario, this means that carp0 on both boxes should show up as MASTER and carp1 should show up as BACKUP.

4. Ensure named is configured to bind to the management IP (for zone transfers, etc.), ns1.ip and ns2.ip (on both boxes!) or ensure that it listens on *.

5. Add net.inet.carp.log=2 to /etc/sysctl.conf for some extra logging info.

6. Reboot. Your primary box should come up with ns1.ip as MASTER and ns2.ip as BACKUP. Your secondary box should come up with ns2.ip as MASTER and ns1.ip as BACKUP. Check ifconfig and dmesg to confirm.

  • Note: CARP traffic is multicast and you may need to alter firewalls as appropriate to allow it. The destination is VRRP.MCAST.NET/224.0.0.18.
    For defining masters/slaves, etc. in bind you will want to reference the management IPs of the boxes, not the floating CARP addresses.
  • Note: You can actually skip using the start_if.* files if you elect to put the ifconfig statements into rc.conf. In order to limit access to your CARP authentication key, you would need to change the permissions on rc.conf which could be bad in certain situations.
  • ESX Note: If you’re trying to do this with a box in VMware, you’ll need to disable the vSwitch security features (accept: promisc, forged transmits, mac changes). This is not advisable in production as any VM on that switch can sniff traffic from any other VM. For my setup at home, I simply allocated a second NIC and a second vSwitch and made the security changes on the dedicated vSwitch. No other VMs should share this other vSwitch where the security features have been disabled.
分类: BSD/linux, DNS, 转载 标签: , ,

线程模式下工作

2010年11月8日 16hot 没有评论

这几天将memcached的线程模式移植到ednsd来,性能有所提升,但是没有以为中的高倍提升。下面是不连redis的统计。

Queries per second:   51600.484825 qps
Queries per second:   51664.028522 qps
Queries per second:   49371.465948 qps
Queries per second:   48488.016842 qps
Queries per second:   46953.006773 qps

Queries sent:         4485137 queries
Queries completed:    4485137 queries

经过测试数据表明,不是开的线程越多,性能越高,而是跟CPU(或者内核)数对应,性能最高。比如4核的CPU,4个线程,性能是最优的。另外,在10万个数据请求时,只有3.6万QPS。在440万个数据请求时,能上到5万QPS左右。

另一方面也说明了,线程模式在高负载的情况下,才能发挥性能。否则有点杀鸡用牛刀之嫌。

分类: C/C++, DNS 标签:

ednsd-0.0.1 test

2010年10月25日 16hot 没有评论

% /opt/bin/queryperf -s 127.0.0.1 -p 5053 -d /tmp/redis-test.conf

DNS Query Performance Testing Tool
Version: $Id: queryperf.c,v 1.12 2007/09/05 07:36:04 marka Exp $

[Status] Processing input data
[Status] Sending queries (beginning with 127.0.0.1)
[Status] Testing complete

Statistics:

Parse input file:     once
Ended due to:         reaching end of file

Queries sent:         1711643 queries
Queries completed:    1711643 queries
Queries lost:         0 queries
Queries delayed(?):   0 queries

RTT max:              0.137409 sec
RTT min:              0.000249 sec
RTT average:          0.001683 sec
RTT std deviation:    0.000562 sec
RTT out of range:     0 queries

Percentage completed: 100.00%
Percentage lost:        0.00%

Started at:           Mon Oct 25 18:57:00 2010
Finished at:          Mon Oct 25 18:59:26 2010
Ran for:              145.735860 seconds

Queries per second:   11744.830682 qps

% /opt/bin/queryperf -s 127.0.0.1 -p 5053 -d /tmp/redis-test.conf

DNS Query Performance Testing Tool
Version: $Id: queryperf.c,v 1.12 2007/09/05 07:36:04 marka Exp $

[Status] Processing input data
[Status] Sending queries (beginning with 127.0.0.1)
[Status] Testing complete

Statistics:

Parse input file:     once
Ended due to:         reaching end of file

Queries sent:         2857092 queries
Queries completed:    2857092 queries
Queries lost:         0 queries
Queries delayed(?):   0 queries

RTT max:              0.101593 sec
RTT min:              0.000266 sec
RTT average:          0.001774 sec
RTT std deviation:    0.000632 sec
RTT out of range:     0 queries

Percentage completed: 100.00%
Percentage lost:        0.00%

Started at:           Mon Oct 25 23:36:57 2010
Finished at:          Mon Oct 25 23:41:13 2010
Ran for:              256.322268 seconds

Queries per second:   11146.483769 qps

% /opt/bin/queryperf -s 127.0.0.1 -p 5053 -d /tmp/redis-test.conf

DNS Query Performance Testing Tool
Version: $Id: queryperf.c,v 1.12 2007/09/05 07:36:04 marka Exp $

[Status] Processing input data
[Status] Sending queries (beginning with 127.0.0.1)
[Status] Testing complete

Statistics:

Parse input file:     once
Ended due to:         reaching end of file

Queries sent:         4485137 queries
Queries completed:    4485137 queries
Queries lost:         0 queries
Queries delayed(?):   0 queries

RTT max:              0.102150 sec
RTT min:              0.000549 sec
RTT average:          0.001719 sec
RTT std deviation:    0.000334 sec
RTT out of range:     0 queries

Percentage completed: 100.00%
Percentage lost:        0.00%

Started at:           Tue Oct 26 08:41:45 2010
Finished at:          Tue Oct 26 08:48:15 2010
Ran for:              389.838687 seconds

Queries per second:   11505.110061 qps

酷睿双核2.5GCPU,2G内存,670万记录,占用1.5G左右内存,开始使用交换分区。

/opt/bin/queryperf -s 127.0.0.1 -d /tmp/redis-test.conf

DNS Query Performance Testing Tool
Version: $Id: queryperf.c,v 1.12 2007/09/05 07:36:04 marka Exp $

[Status] Processing input data
[Status] Sending queries (beginning with 61.158.132.223)
[Timeout] Query timed out: msg id 1
[Status] Testing complete

Statistics:

Parse input file:     once
Ended due to:         reaching end of file

Queries sent:         6728279 queries
Queries completed:    6728278 queries
Queries lost:         1 queries
Queries delayed(?):   0 queries

RTT max:              4.468220 sec
RTT min:              0.000157 sec
RTT average:          0.001339 sec
RTT std deviation:    0.002454 sec
RTT out of range:     0 queries

Percentage completed: 100.00%
Percentage lost:        0.00%

Started at:           Fri Oct 29 11:22:11 2010
Finished at:          Fri Oct 29 11:29:48 2010
Ran for:              456.384615 seconds

Queries per second:   14742.560943 qps

分类: DNS 标签:

DNS查询统计图

2010年10月23日 16hot 没有评论

采用rrdtool生成的统计图,可以点击查看完整尺寸图片。

1、总统计图

2、记录类型统计图

分类: DNS, PHP 标签:

DNS报文格式

2010年10月22日 16hot 没有评论
Query Identifier(16) QR OPCodes Flags Reserved RCodes
QDCount(16) ANCount(16)
NSCount(16) ARCount(16)
Question Section(32)
Answer Section(32)
Authority Section(32)
Additional Records Section(32)

以下为各栏位的简要说明:
QID
DNS 查询封包编号,作为确认依据。
QR
查询封包为 0 ﹔回应为 1 。长度为 1 byte 。
OPCodes
封包类别(QUERY, IQUERY, STATUS, Reserved)。长度为 4 bytes。
Flags
共 4 bytes ,各表示:AA(Authoritative Answer)、TC(Truncation)、RD(Recursion Desired)、RA(Recursion Avalable)。
Reserved
保留未用。
RCodes
回应讯息,长 4 bytes ,除 0 及 6-15 保留未用外,1-5 分别为:Format Error、Server Failure、Name Error、Not Implemented、Refused。
Question Section、Answer Section、Authority Section、Additional Records Section
每一 Section 分为 NAME、TYPE、CLASS 三个子栏位,分别作为查询、应答、授权、额外记录等封包之资讯,及各自长度。
好了﹐关于 DNS 协定的讨论﹐暂时介绍到这里﹐相信上面说的这些也够您消化的了。
DNS 协定之 RFC 文件
RFC-822﹑RFC-883﹑RFC-920﹑RFC-973﹑RFC-974﹑RFC-1032﹑RFC-1033﹑RFC-1034﹑RFC-1035﹑RFC-1101﹑RFC-1296

分类: C/C++, DNS 标签:

对DNS报文的理解

2010年3月30日 16hot 没有评论

在这段时间的学习中,我发现通过抓包来学习的方法不错,这样有助于更深刻的理解。下面是我对dns报文的一些理解。
学习了《tcp/ip 卷一》 dns域名系统这一章,下面通过spynet capturenet抓一些dns通信报文进行一下分析,以加深理解。
本人是在windows 上使用nslookup工具来产生的dns通信,见上图。
阅读全文…

分类: DNS, 转载 标签:

DNS漏洞解析

2008年9月1日 16hot 没有评论

http://blog.delphij.net/archives/2008/07/dns-1.html

分类: DNS 标签:

FreeBSD-6.3下的bing9性能-线程

2008年3月16日 16hot 没有评论

近日在调试6.3下bind9。发现怎么性能竟然下降了一半不止,搞的很郁闷。

经过多次重新编译安装,发现竟然是线程搞的鬼。加了 –enable-threads 参数编译,在6.3下,bind9的性能下降60%左右。测试时,只有1400qps/s左右。而不加线程参数,4000qps/s左右。

差异非常大。

同样的测试,在FreeBSD7.0下,开启线程要增加10%左右的性能。

分类: BSD/linux, DNS 标签: ,