<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DSH DSH &#187; bind</title>
	<atom:link href="http://dshdsh.ru/tag/bind/feed" rel="self" type="application/rss+xml" />
	<link>http://dshdsh.ru</link>
	<description>&#1069;&#1090;&#1086; &#1085;&#1072;&#1076;&#1086; &#1074;&#1080;&#1076;&#1077;&#1090;&#1100;!</description>
	<lastBuildDate>Mon, 12 Oct 2009 05:49:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Используем OpenDNS+DynDNS+pdnsd(или Bind) для защиты и ускорения на dynamic IP</title>
		<link>http://dshdsh.ru/22-11-opendns</link>
		<comments>http://dshdsh.ru/22-11-opendns#comments</comments>
		<pubDate>Sat, 22 Nov 2008 17:48:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/pinnokio/public_html/dshdsh.ru/wp-content/plugins/autometa/autometa.php</b> on line <b>364</b><br />
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[bind]]></category>

	<!-- AutoMeta Start -->
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://itbg.wordpress.com/wordpress/?p=12</guid>
		<description><![CDATA[Всем привет.
Нам потребуется:
1)Модем с поддержкой DynDNS(опционально)
2)UNIX система (опционально)
3)Прямые руки
Приступим:
1)Идём на DynDNS.com
Регистрируем там домен, в моём случае myhost.ath.cx
Затем переходим в модем, роутер, прогу и делаем синхронизацию с аккаунтом
2)Идём на OpenDNS.com
Проходим регистрацию
Настраиваем:
Во вкладке Networks ставим имя сети, задаём свой IP
Во вкладке Settings =&#62; Content Filtering =&#62; Choose your filtering level =&#62; Custom Выбираем необходимые фильтры контента.
3)Идём на dnsomatic.com
Аккаунт должен быть создан при регистрации на OpenDNS
Переходим на вкладку Your Services
Затем добавляем Service:DynDNS
User ID:Ваше имя на DynDNS
Password:Ваш пароль
Host/Identifier:Ваш хост, в моё случае myhost.ath.cx
Жмём Update Account Info
Затем добавляем Add a service:OpenDNS
Имя сети: имя указанное при вводе IP на OpenDNS
Жмём Update Account Info
4) Вписываем DNS OpenDNS в свой модем, соединение, и т.д
208.67.222.222
208.67.220.220
В принципе всё. Но мы идём дальше:]]></description>
			<content:encoded><![CDATA[<sape_index><p>Всем привет.<br />
Нам потребуется:<br />
1)Модем с поддержкой DynDNS(опционально)<br />
2)UNIX система (опционально)<br />
3)Прямые руки<br />
Приступим:<br />
1)Идём на DynDNS.com<br />
Регистрируем там домен, в моём случае myhost.ath.cx<br />
Затем переходим в модем, роутер, прогу и делаем синхронизацию с аккаунтом<br />
2)Идём на OpenDNS.com<br />
Проходим регистрацию<br />
Настраиваем:<br />
Во вкладке Networks ставим имя сети, задаём свой IP<br />
Во вкладке Settings =&gt; Content Filtering =&gt; Choose your filtering level =&gt; Custom Выбираем необходимые фильтры контента.<br />
3)Идём на dnsomatic.com<br />
Аккаунт должен быть создан при регистрации на OpenDNS<br />
Переходим на вкладку Your Services<br />
Затем добавляем Service:DynDNS<br />
User ID:Ваше имя на DynDNS<br />
Password:Ваш пароль<br />
Host/Identifier:Ваш хост, в моё случае myhost.ath.cx<br />
Жмём Update Account Info<br />
Затем добавляем Add a service:OpenDNS<br />
Имя сети: имя указанное при вводе IP на OpenDNS<br />
Жмём Update Account Info<br />
4) Вписываем DNS OpenDNS в свой модем, соединение, и т.д<br />
208.67.222.222<br />
208.67.220.220<br />
В принципе всё. Но мы идём дальше:</p>
<p>Поставим кэширующий DNS<br />
Все действия описаны для Gentoo(Linux)<br />
Для начала разберёмся с pdnsd<br />
Я предпочёл его, за перманентный кэш.<br />
1)Ставим pdnsd<br />
В моём случае emerge pdnsd<br />
Исходники доступны здесь<br />
Переходим в /etc/pdnsd/<br />
cd /etc/pdnsd/<br />
Затем cp pdnsd.conf.sample pdnsd.conf<br />
Правим:<br />
У меня в конечном варианте выглядит так<br />
// Sample pdnsd configuration file. Must be customized to obtain a working pdnsd setup!<br />
// Read the pdnsd.conf(5) manpage for an explanation of the options.<br />
// Add or remove &#8216;#&#8217; in front of options you want to disable or enable, respectively.<br />
// Remove &#8216;/*&#8217; and &#8216;*/&#8217; to enable complete sections.<br />
global {<br />
perm_cache=4096;<br />
cache_dir=&#8221;/var/cache/pdnsd&#8221;;<br />
#       pid_file = /var/run/pdnsd.pid;<br />
run_as=&#8221;pdnsd&#8221;;<br />
server_ip = 192.168.1.5;  # Use eth0 here if you want to allow other<br />
# machines on your network to query pdnsd.<br />
status_ctl = on;<br />
#       paranoid=on;       # This option reduces the chance of cache poisoning<br />
# but may make pdnsd less efficient, unfortunately.<br />
query_method=udp_tcp;<br />
min_ttl=15m;       # Retain cached entries at least 15 minutes.<br />
max_ttl=1w;        # One week.<br />
timeout=10;        # Global timeout option (10 seconds).<br />
}<br />
# The following section is most appropriate if you have a fixed connection to<br />
# the Internet and an ISP which provides good DNS servers.<br />
/*<br />
server {<br />
label= &#8220;myisp&#8221;;<br />
ip = 195.54.2.1;  # Put your ISP&#8217;s DNS-server address(es) here.<br />
#       proxy_only=on;     # Do not query any name servers beside your ISP&#8217;s.<br />
# This may be necessary if you are behind some<br />
# kind of firewall and cannot receive replies<br />
# from outside name servers.<br />
timeout=4;         # Server timeout; this may be much shorter<br />
# that the global timeout option.<br />
uptest=if;         # Test if the network interface is active.<br />
interface=eth0;    # The name of the interface to check.<br />
interval=10m;      # Check every 10 minutes.<br />
purge_cache=off;   # Keep stale cache entries in case the ISP&#8217;s<br />
# DNS servers go offline.<br />
}<br />
*/<br />
/*<br />
# The following section is more appropriate for dial-up connections.<br />
# Read about how to use pdnsd-ctl for dynamic configuration in the documentation.<br />
server {<br />
label= &#8220;dialup&#8221;;<br />
file = &#8220;/etc/ppp/resolv.conf&#8221;;  # Preferably do not use /etc/resolv.conf<br />
proxy_only=on;<br />
timeout=4;<br />
uptest=if;<br />
interface = ppp0;<br />
interval=10;       # Check if the interface every 10 seconds.<br />
purge_cache=off;<br />
preset=off;<br />
}<br />
*/<br />
# The servers provided by OpenDNS are fast, but they do not reply with<br />
# NXDOMAIN for non-existant domains, instead they supply you with an<br />
# address of one of their search engines. They also lie about the addresses of<br />
# of the search engines of google, microsoft and yahoo.<br />
# If you do not like this behaviour the &#8220;reject&#8221; option may be useful.<br />
server {<br />
label = &#8220;opendns&#8221;;<br />
ip = 208.67.222.222, 208.67.220.220;<br />
reject = 208.69.32.0/24,  # You may need to add additional address ranges<br />
208.69.34.0/24,  # here if the addresses of their search engines<br />
208.67.219.0/24; # change.<br />
reject_policy = fail;     # If you do not provide any alternative server<br />
# sections, like the following root-server<br />
# example, &#8220;negate&#8221; may be more appropriate here.<br />
timeout = 4;<br />
uptest = ping;            # Test availability using ICMP echo requests.<br />
ping_timeout = 100;       # ping test will time out after 10 seconds.<br />
interval = 15m;           # Test every 15 minutes.<br />
preset = off;<br />
}<br />
#Это нужно для того, что бы при отказе соединения или посещении запрещённого ресурса<br />
#у вас выводилось окно OpenDNS, если нижнюю секцию opendns убрать то тогда<br />
#в место окна OpenDNS будет показываться ошибка 404 вашего браузера.<br />
server {<br />
label= &#8220;opendns&#8221;;<br />
ip = 208.67.222.222,208.67.220.220;  # Put your ISP&#8217;s DNS-server address(es) here.<br />
#       proxy_only=on;     # Do not query any name servers beside your ISP&#8217;s.<br />
# This may be necessary if you are behind some<br />
# kind of firewall and cannot receive replies<br />
# from outside name servers.<br />
timeout=4;         # Server timeout; this may be much shorter<br />
# that the global timeout option.<br />
uptest=if;         # Test if the network interface is active.<br />
interface=eth0;    # The name of the interface to check.<br />
interval=10m;      # Check every 10 minutes.<br />
purge_cache=off;   # Keep stale cache entries in case the ISP&#8217;s<br />
# DNS servers go offline.<br />
}<br />
server {<br />
label= &#8220;myisp&#8221;;<br />
ip = 195.54.2.1;  # Put your ISP&#8217;s DNS-server address(es) here.<br />
#       proxy_only=on;     # Do not query any name servers beside your ISP&#8217;s.<br />
# This may be necessary if you are behind some<br />
# kind of firewall and cannot receive replies<br />
# from outside name servers.<br />
timeout=4;         # Server timeout; this may be much shorter<br />
# that the global timeout option.<br />
uptest=if;         # Test if the network interface is active.<br />
interface=eth0;    # The name of the interface to check.<br />
interval=10m;      # Check every 10 minutes.<br />
purge_cache=off;   # Keep stale cache entries in case the ISP&#8217;s<br />
# DNS servers go offline.<br />
}<br />
# This section is meant for resolving from root servers.<br />
server {<br />
label = &#8220;root-servers&#8221;;<br />
root_server = on;<br />
randomize_servers = on; # Give every root server an equal chance<br />
# of being queried.<br />
ip =    198.41.0.4<br />
,       192.228.79.201<br />
,       192.33.4.12<br />
,       128.8.10.90<br />
,       192.203.230.10<br />
,       192.5.5.241<br />
,       192.112.36.4<br />
,       128.63.2.53<br />
,       192.36.148.17<br />
,       192.58.128.30<br />
,       193.0.14.129<br />
,       198.32.64.12<br />
,       202.12.27.33<br />
;<br />
timeout = 5;<br />
uptest = query;         # Test availability using empty DNS queries.<br />
interval = 30m;         # Test every half hour.<br />
ping_timeout = 300;     # Test should time out after 30 seconds.<br />
purge_cache = off;<br />
exclude = .localdomain;<br />
policy = included;<br />
preset = off;<br />
}<br />
source {<br />
owner=localhost;<br />
#       serve_aliases=on;<br />
file=&#8221;/etc/hosts&#8221;;<br />
}<br />
/*<br />
include {file=&#8221;/etc/pdnsd.include&#8221;;}    # Read additional definitions from /etc/pdnsd.include.<br />
*/<br />
rr {<br />
name=localhost;<br />
reverse=on;<br />
a=127.0.0.1;<br />
owner=localhost;<br />
soa=localhost,root.localhost,42,86400,900,86400,86400;<br />
}<br />
/*<br />
neg {<br />
name=doubleclick.net;<br />
types=domain;   # This will also block xxx.doubleclick.net, etc.<br />
}<br />
*/<br />
/*<br />
neg {<br />
name=bad.server.com;   # Badly behaved server you don&#8217;t want to connect to.<br />
types=A,AAAA;<br />
}<br />
*/<br />
Думаю тут всё понятно<br />
По непонятной причине pdnsd у меня так и не заработал, решил скомпилировать сам<br />
cd /tmp<br />
wget http://www.phys.uu.nl/~rombouts/pdnsd/releases/pdnsd-1.2.7-par.tar.gz<br />
tar xvfz pdnsd-1.2.7-par.tar.gz<br />
cd pdnsd-1.2.7<br />
./configure &#8211;enable-ipv6  &#8211;program-prefix=/usr/local<br />
make<br />
cp /etc/pdnsd/pdnsd/pdnsd.conf /usr/local/etc/<br />
cp -r src /usr/local/pdnsd<br />
cd /usr/local/pdnsd<br />
./pdnsd -d<br />
Запуск в режиме Демона для проверки<br />
Ставим bind-tools для проверки DNS<br />
emerge bind-tools<br />
dig ya.ru<br />
Просмотр вывода, в моём случае<br />
; &lt;&lt;&gt;&gt; DiG 9.4.2-P2 &lt;&lt;&gt;&gt; ya.ru<br />
;; global options:  printcmd<br />
;; Got answer:<br />
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 17622<br />
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0<br />
;; QUESTION SECTION:<br />
;ya.ru.                         IN      A<br />
;; ANSWER SECTION:<br />
ya.ru.                  6382    IN      A       213.180.204.8<br />
;; Query time: 1 msec<br />
;; SERVER: 192.168.1.5#53(192.168.1.5)<br />
;; WHEN: Sat Nov 22 13:22:42 2008<br />
;; MSG SIZE  rcvd: 39<br />
Значит работает<br />
Осталось добавить в автозапуск<br />
Исправленный скрипт<br />
#!/sbin/runscript<br />
# Copyright 1999-2004 Gentoo Foundation<br />
# Distributed under the terms of the GNU General Public License v2<br />
# $Header: /var/cvsroot/gentoo-x86/net-dns/pdnsd/files/pdnsd.rc6,v 1.13 2007/07/13 07:46:00 mrness Exp $<br />
opts=&#8221;reload&#8221;<br />
depend() {<br />
need net<br />
provide dns<br />
}<br />
checkconfig() {<br />
if [ ! -e /usr/local/etc/pdnsd.conf ] ; then<br />
eerror &#8220;You need an  /usr/local/etc/pdnsd.conf file first.&#8221;<br />
eerror &#8220;There is a sample in  /usr/local/etc/pdnsd.conf.sample&#8221;<br />
return 1<br />
fi<br />
}<br />
start() {<br />
checkconfig || return 1<br />
ebegin &#8220;Starting pdnsd&#8221;<br />
start-stop-daemon &#8211;start &#8211;quiet &#8211;exec /usr/local/pdnsd/pdnsd &#8212; -d -p /var/run/pdnsd.pid<br />
eend $?<br />
}<br />
stop() {<br />
ebegin &#8220;Stopping pdnsd&#8221;<br />
start-stop-daemon &#8211;stop &#8211;quiet &#8211;pidfile /var/run/pdnsd.pid<br />
eend $?<br />
}<br />
Убиваем pdnsd<br />
Добавляем в автозапуск<br />
rc-update add pdnsd default<br />
Запускаем<br />
/etc/init.d/pdnsd start<br />
правим resolv.conf<br />
nano /etc/resolv.conf<br />
В моём случае<br />
# Generated by dhclient for interface eth0<br />
nameserver 192.168.1.5<br />
nameserver 192.168.1.1 # на модеме то-же вписан OpenDNS+DNS провайдера<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220<br />
2) Для Bind<br />
ставим его<br />
emerge bind<br />
правим конфиг<br />
В моём случае:<br />
options {<br />
directory &#8220;/var/bind&#8221;;<br />
// uncomment the following lines to turn on DNS forwarding,<br />
// and change the forwarding ip address(es) :<br />
//forward first;<br />
//forwarders {<br />
//      123.123.123.123;<br />
//      123.123.123.123;<br />
//};<br />
listen-on-v6 { none; };<br />
listen-on { 127.0.0.1;192.168.1.5; };<br />
// to allow only specific hosts to use the DNS server:<br />
allow-query {<br />
any;<br />
};<br />
forwarders { 208.67.222.222;208.67.220.220; }; // Здесь  IP OpenDNS<br />
// if you have problems and are behind a firewall:<br />
query-source address * port 53;<br />
pid-file &#8220;/var/run/named/named.pid&#8221;;<br />
};<br />
// Briefly, a zone which has been declared delegation-only will be effectively<br />
// limited to containing NS RRs for subdomains, but no actual data beyond its<br />
// own apex (for example, its SOA RR and apex NS RRset). This can be used to<br />
// filter out &#8220;wildcard&#8221; or &#8220;synthesized&#8221; data from NAT boxes or from<br />
// authoritative name servers whose undelegated (in-zone) data is of no<br />
// interest.<br />
// See http://www.isc.org/products/BIND/delegation-only.html for more info<br />
//zone &#8220;COM&#8221; { type delegation-only; };<br />
//zone &#8220;NET&#8221; { type delegation-only; };<br />
zone &#8220;.&#8221; IN {<br />
type hint;<br />
file &#8220;named.ca&#8221;;<br />
};<br />
zone &#8220;localhost&#8221; IN {<br />
type master;<br />
file &#8220;pri/localhost.zone&#8221;;<br />
allow-update { none; };<br />
notify no;<br />
};<br />
zone &#8220;127.in-addr.arpa&#8221; IN {<br />
type master;<br />
file &#8220;pri/127.zone&#8221;;<br />
allow-update { none; };<br />
notify no;<br />
};<br />
Сохраняем.<br />
Запускаем<br />
/etc/init.d/named start<br />
Проверяем<br />
dig ya.ru<br />
Добавляем в атозапуск<br />
rc-update add named default<br />
Правим resolv.conf по образцу выше<br />
nano /etc/resolv.conf<br />
Всё.<br />
UPD<br />
После чтения доков по www.dnsomatic.com выяснилось, что это не совсем то, что нужно.<br />
Это сервис для синхронизации IP между сервисами.<br />
Для UNIX единственное, что предлагается, так это воспользоваться ddclient<br />
Если техника позволяет, можно вписать с свой роутер, модем и т.д сервер updates.dnsomatic.com<br />
Имя пользователя и пароль.<br />
Мы же пойдём более простым путём:<br />
Синхронизироваться будем через скрипт, который добавим в cron на выполнение каждые 10 минут<br />
Для этого понадобится wget или curl<br />
Wget:</p>
<p>wget -O &#8211; &#8211;no-check-certificate &#8220;https://имя_пользователя:пароль@updates.dnsomatic.com/nic/update?wildcard=YESG&amp;mx=YES&amp;backmx=NOCHG&#8221;<br />
&#8211;14:13:23&#8211; https://имя_пользователя:пароль@updates.dnsomatic.com/nic/update?wildcard=YESG&amp;mx=YES&amp;backmx=NOCHG<br />
=&gt; `-&#8217;<br />
Resolving updates.dnsomatic.com&#8230; 67.215.64.64<br />
Connecting to updates.dnsomatic.com|67.215.64.64|:443&#8230; connected.<br />
WARNING: Certificate verification error for updates.dnsomatic.com: unable to get local issuer certificate<br />
HTTP request sent, awaiting response&#8230; 200 OK<br />
Length: 16 [text/html]<br />
100%[============================================================================================================================&gt;] 16 &#8211;.&#8211;K/s<br />
14:13:24 (144.52 KB/s) &#8211; `-&#8217; saved [16/16]</p>
<p>Curl:</p>
<p>curl &#8211;insecure &#8220;https://имя_пользователя:пароль@updates.dnsomatic.com/nic/update?wildcard=YESG&amp;mx=YES&amp;backmx=NOCHG&#8221;</p>
</sape_index><!--c249110617320--><div></div>]]></content:encoded>
			<wfw:commentRss>http://dshdsh.ru/22-11-opendns/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

