dnscrypt可谓是防DNS污染的神器,是opendns官方的客户端工具,用于加密dns传输,有点类似http和https的区别。服务端和客户端都使用密钥进行传输,是所有抗DNS污染里面最强的手段了。然而国内的网络状况并不理想,很多时候连不上opendns(你懂的),或者我们搭建代理的时候想使用远程vps当地的dns解析结果来加速被wall网站的访问,这个时候想到能不能自己搭建一个dnscrypt的服务端呢?找了一圈,发现opendns官方并没有提供服务端源码╮(╯▽╰)╭……
不过在中国这个神奇的国度,总不缺乏大神,在v2ex上找到了@Cofyc 大神的自己写的dnscry-wrapper服务端,以下是原文:
[dnscrypt]写了一个 dnscrypt 的服务器端代理 dnscrypt-wrapper
———————————————————————-
https://github.com/Cofyc/dnscrypt-wrapperdnscrypt 是 opendns.com 设计的给 dns 协议加密的协议,类似 ssl 与 http 的关系。
opendns 有实现一个客户端代理 dnscrypt-proxy,但目前以我所知只有 opendns 的 dns 服务器上有实现 dnscrypt 协议。
dnscrypt-wrapper 是从 dnscrypt-proxy 修改而来,给任意 dns server 在服务端增加 dnscrypt 加密支持。适合想使用 dnscrypt 但想自架 dns 服务器的情形。
我在自己服务器上有架设一个测试 dns,可以使用以下命令测试:
$ sudo ./dnscrypt-proxy -a 127.0.0.1:55 –provider-name=2.dnscrypt-cert.yechengfu.com -r 106.187.34.45:53 –provider-key=4298:5F65:C295:DFAE:2BFB:20AD:5C47:F565:78EB:2404:EF83:198C:85DB:68F1:3E33:E952
$ dig -p 55 google.com @127.0.0.1参考:
– http://dnscrypt.org/
– dnscrypt-proxy https://github.com/opendns/dnscrypt-proxy
– http://www.opendns.com/technology/dnscrypt/
嗯,于是我兴冲冲地跑去下载编译了,过程中遇到不少问题,折腾了两小时,原作者也比较热心解决我的问题,现在我把编译过程(CentOS x86)分享下,希望对你有帮助:
1 | yum update |
更新软件源。
1 2 | yum -y install autoconf gettext libltdl* libevent git libsodium libevent* libtool-ltdl-devel yum -y groupinstall 'Development Tools' |
如果你是debian/ubuntu用户,可以尝试运行
1 | apt-get install libsodium* |
libsodium这个库低版本centos可能没有……于是自己下载编译:
下载地址http://download.libsodium.org/libsodium/releases/
我选择的是当前最新的libsodium(下载可能会卡,毕竟服务器在国外):
1 2 3 4 | cd ~ wget https://download.libsodium.org/libsodium/releases/LATEST.tar.gz tar xf LATEST.tar.gz cd libsodium* |
解压好就进去编译安装:
1 2 3 4 5 6 | CFLAGS="-O3 -fPIC" ./configure ./autogen.sh ./configure make make install ldconfig |
至此libsodium安装完毕。
我用最新的ubuntu百衲衣似乎没什么问题,centos软件源上的libevent也不是最新的,而服务端要求2.0以上的版本,软件源提供的是1.4版本,因此导致编译出错。二话不说跑去官网下载源码编译:
下载地址:http://libevent.org/
我选择的是当前最新的稳定版本:
release-2.1.6-beta
2016.08.27
下载解压:
1 2 3 4 | ~ https://codeload.github.com/libevent/libevent/zip/release-2.1.6-beta unzip release* cd libevent* |
编译安装:
1 2 3 4 5 6 7 | ./configure --prefix=/usr ./autogen.sh ./configure make make install echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf ldconfig |
至此libevent安装完毕。
现在可以下载dnscrypt-wrapper源码来编译了:
1 2 3 4 5 | cd ~ git clone --recursive git://github.com/Cofyc/dnscrypt-wrapper.git cd dnscrypt-wrapper make configure ./configure |
如果执行./configure有出现错误,请根据错误信息找原因,基本上库完整的话没什么问题。有问题欢迎留言。./configure检查通过的话,我们就可以直接执行make命令来编译了。最后生成dnscrypt-wrapper可执行文件。
[[email protected] dnscrypt-wrapper]# make install
install -d -m 755 ‘/usr/local/bin’
install -p dnscrypt-wrapper ‘/usr/local/bin’
附录
DNSCRYPT-WRAPPER的使用方法
DNSCRYPT-PROXY客户端(WINDOWS)
原文链接:https://03k.org/centos-make-dnscrypt-wrapper.html
本站博文无特别声明均为原创,转载请注明原文链接。本站软件均搜集自互联网,供学习研究之用,请下载后24小时内删除。
疑问OR交流点我加QQ群喵喵喵!
按照楼主的方式来编译,最后一步的时候还是报错,看错误应该是找不到libevent库,我确认是已经安装过的,反正就是失败,也尝试改Makefile文件,仍然不生效。整个周末都在考虑怎么解决。
周日晚上临睡之前,又在网上搜了一下,看到一篇文章在 ./configure之前带了一个参数,我也尝试了一下,居然成功了!
特把这个贴出来,如果有需要的同学可以参考一下。
CFLAGS=”-g -O2 -Wall -I/usr/local/include/” LDFLAGS=”-L/usr/local/lib/ -levent” ./configure
make install
非常感谢你的分享!不好意思去泡图书馆了,现在才看到?
请问CFLAGS=”-g -O2 -Wall -I/usr/local/include/” LDFLAGS=”-L/usr/local/lib/ -levent” ./configure
-bash: -O2: command not found
这是什么原因?
升级下你的gcc?
我也碰到你这个问题:
checking for event_base_new in -levent… no
configure: error: libevent2 is required – see http://libevent.org/
明明安装了livevent库
libevent-2.1.so.5 -> libevent-2.1.so.5.0.0
但是按照你的办法,还是没有解决问题
请问大师还有高招吗?
抱歉现在才看到(因为评论带URL自动被丢回收站了)
请问你的什么系统?问题解决了吗?
./configure 检测通过了
但是make install 出错如下:
make install
CC dnscrypt.o
在包含自 dnscrypt.h:4 的文件中,
从 dnscrypt.c:1:
compat.h:52:1: 警告:“_XOPEN_SOURCE”重定义
在包含自 /usr/include/assert.h:36 的文件中,
从 compat.h:7,
从 dnscrypt.h:4,
从 dnscrypt.c:1:
/usr/include/features.h:156:1: 警告:这是先前定义的位置
CC udp_request.o
在包含自 dnscrypt.h:4 的文件中,
从 udp_request.c:2:
compat.h:52:1: 警告:“_XOPEN_SOURCE”重定义
在包含自 /usr/include/assert.h:36 的文件中,
从 compat.h:7,
从 dnscrypt.h:4,
从 udp_request.c:2:
/usr/include/features.h:156:1: 警告:这是先前定义的位置
CC tcp_request.o
在包含自 dnscrypt.h:4 的文件中,
从 tcp_request.c:1:
compat.h:52:1: 警告:“_XOPEN_SOURCE”重定义
在包含自 /usr/include/assert.h:36 的文件中,
从 compat.h:7,
从 dnscrypt.h:4,
从 tcp_request.c:1:
/usr/include/features.h:156:1: 警告:这是先前定义的位置
CC edns.o
在包含自 dnscrypt.h:4 的文件中,
从 edns.c:1:
compat.h:52:1: 警告:“_XOPEN_SOURCE”重定义
在包含自 /usr/include/assert.h:36 的文件中,
从 compat.h:7,
从 dnscrypt.h:4,
从 edns.c:1:
/usr/include/features.h:156:1: 警告:这是先前定义的位置
CC logger.o
在包含自 logger.h:9 的文件中,
从 logger.c:1:
compat.h:52:1: 警告:“_XOPEN_SOURCE”重定义
在包含自 /usr/include/assert.h:36 的文件中,
从 compat.h:7,
从 logger.h:9,
从 logger.c:1:
/usr/include/features.h:156:1: 警告:这是先前定义的位置
CC rfc1035.o
在包含自 rfc1035.h:4 的文件中,
从 rfc1035.c:20:
compat.h:52:1: 警告:“_XOPEN_SOURCE”重定义
在包含自 /usr/include/assert.h:36 的文件中,
从 compat.h:7,
从 rfc1035.h:4,
从 rfc1035.c:20:
/usr/include/features.h:156:1: 警告:这是先前定义的位置
CC safe_rw.o
CC cert.o
在包含自 dnscrypt.h:4 的文件中,
从 cert.c:1:
compat.h:52:1: 警告:“_XOPEN_SOURCE”重定义
在包含自 /usr/include/assert.h:36 的文件中,
从 compat.h:7,
从 dnscrypt.h:4,
从 cert.c:1:
/usr/include/features.h:156:1: 警告:这是先前定义的位置
CC pidfile.o
在包含自 dnscrypt.h:4 的文件中,
从 pidfile.h:4,
从 pidfile.c:1:
compat.h:52:1: 警告:“_XOPEN_SOURCE”重定义
在包含自 /usr/include/assert.h:36 的文件中,
从 compat.h:7,
从 dnscrypt.h:4,
从 pidfile.h:4,
从 pidfile.c:1:
/usr/include/features.h:156:1: 警告:这是先前定义的位置
CC debug.o
在包含自 debug.h:7 的文件中,
从 debug.c:1:
compat.h:52:1: 警告:“_XOPEN_SOURCE”重定义
在包含自 /usr/include/assert.h:36 的文件中,
从 compat.h:7,
从 debug.h:7,
从 debug.c:1:
/usr/include/features.h:156:1: 警告:这是先前定义的位置
CC main.o
在包含自 dnscrypt.h:4 的文件中,
从 main.c:1:
compat.h:52:1: 警告:“_XOPEN_SOURCE”重定义
在包含自 /usr/include/assert.h:36 的文件中,
从 compat.h:7,
从 dnscrypt.h:4,
从 main.c:1:
/usr/include/features.h:156:1: 警告:这是先前定义的位置
make[1]: Entering directory
/data/tools/dnscrypt-wrapper-v0.1.17/argparse'
/data/tools/dnscrypt-wrapper-v0.1.17/argparse’cc -o argparse.o -c -Wall -O3 -g -ggdb -fPIC argparse.c
ar rcs libargparse.a argparse.o
make[1]: Leaving directory
LINK dnscrypt-wrapper
install -d -m 755 ‘/usr/local/sbin’
install -p dnscrypt-wrapper ‘/usr/local/sbin’
求解决办法?
解决了吗?先make再make install?_(:3」∠)_
完全按照博主的步骤来安装的,最后报这个错,不知道是什么原因,请指导一下。
make[1]: Entering directory
/usr/local/src/dnscrypt-wrapper/argparse'
/usr/local/src/dnscrypt-wrapper/argparse’cc -o argparse.o -c -Wall -O3 -g -ggdb -fPIC argparse.c
ar rcs libargparse.a argparse.o
make[1]: Leaving directory
LINK dnscrypt-wrapper
udp_request.o: In function
udp_request_kill':
event_get_callback_arg’/usr/local/src/dnscrypt-wrapper/udp_request.c:102: undefined reference to
/usr/local/src/dnscrypt-wrapper/udp_request.c:103: undefined reference to
event_free'
event_free’/usr/local/src/dnscrypt-wrapper/udp_request.c:107: undefined reference to
udp_request.o: In function
udp_listener_stop':
event_free’/usr/local/src/dnscrypt-wrapper/udp_request.c:563: undefined reference to
udp_request.o: In function
udp_listener_start':
event_new’/usr/local/src/dnscrypt-wrapper/udp_request.c:575: undefined reference to
/usr/local/src/dnscrypt-wrapper/udp_request.c:586: undefined reference to
event_new'
sendto_with_retry’:udp_request.o: In function
/usr/local/src/dnscrypt-wrapper/udp_request.c:190: undefined reference to
event_get_callback_arg'
event_get_callback_arg’/usr/local/src/dnscrypt-wrapper/udp_request.c:160: undefined reference to
/usr/local/src/dnscrypt-wrapper/udp_request.c:165: undefined reference to
event_free'
event_get_callback_arg’/usr/local/src/dnscrypt-wrapper/udp_request.c:199: undefined reference to
/usr/local/src/dnscrypt-wrapper/udp_request.c:203: undefined reference to
event_new'
resolver_to_proxy_cb’:udp_request.o: In function
/usr/local/src/dnscrypt-wrapper/udp_request.c:469: undefined reference to
evutil_sockaddr_cmp'
sendto_with_retry_timer_cb’:udp_request.o: In function
/usr/local/src/dnscrypt-wrapper/udp_request.c:141: undefined reference to
event_get_fd'
client_to_proxy_cb’:udp_request.o: In function
/usr/local/src/dnscrypt-wrapper/udp_request.c:402: undefined reference to
event_new'
udp_listener_bind’:udp_request.o: In function
/usr/local/src/dnscrypt-wrapper/udp_request.c:529: undefined reference to
evutil_make_socket_closeonexec'
evutil_make_socket_closeonexec’/usr/local/src/dnscrypt-wrapper/udp_request.c:551: undefined reference to
/usr/local/src/dnscrypt-wrapper/udp_request.c:548: undefined reference to
evutil_closesocket'
evutil_closesocket’/usr/local/src/dnscrypt-wrapper/udp_request.c:537: undefined reference to
tcp_request.o: In function
tcp_listener_start':
evconnlistener_enable’/usr/local/src/dnscrypt-wrapper/tcp_request.c:456: undefined reference to
tcp_request.o: In function
tcp_listener_bind':
evconnlistener_new’/usr/local/src/dnscrypt-wrapper/tcp_request.c:429: undefined reference to
/usr/local/src/dnscrypt-wrapper/tcp_request.c:441: undefined reference to
evconnlistener_disable'
evconnlistener_set_error_cb’/usr/local/src/dnscrypt-wrapper/tcp_request.c:446: undefined reference to
/usr/local/src/dnscrypt-wrapper/tcp_request.c:442: undefined reference to
evconnlistener_free'
tcp_accept_error_cb’:tcp_request.o: In function
/usr/local/src/dnscrypt-wrapper/tcp_request.c:397: undefined reference to
evconnlistener_disable'
event_new’/usr/local/src/dnscrypt-wrapper/tcp_request.c:388: undefined reference to
tcp_request.o: In function
tcp_accept_timer_cb':
event_free’/usr/local/src/dnscrypt-wrapper/tcp_request.c:375: undefined reference to
tcp_request.o: In function
tcp_request_kill':
event_free’/usr/local/src/dnscrypt-wrapper/tcp_request.c:13: undefined reference to
tcp_request.o: In function
tcp_connection_cb':
bufferevent_socket_new’/usr/local/src/dnscrypt-wrapper/tcp_request.c:315: undefined reference to
/usr/local/src/dnscrypt-wrapper/tcp_request.c:323: undefined reference to
bufferevent_socket_new'
event_new’/usr/local/src/dnscrypt-wrapper/tcp_request.c:336: undefined reference to
/usr/local/src/dnscrypt-wrapper/tcp_request.c:351: undefined reference to
bufferevent_socket_connect'
evutil_closesocket’/usr/local/src/dnscrypt-wrapper/tcp_request.c:319: undefined reference to
tcp_request.o: In function
tcp_listener_stop':
evconnlistener_free’/usr/local/src/dnscrypt-wrapper/tcp_request.c:465: undefined reference to
tcp_request.o: In function
resolver_proxy_read_cb':
bufferevent_get_input’/usr/local/src/dnscrypt-wrapper/tcp_request.c:235: undefined reference to
/usr/local/src/dnscrypt-wrapper/tcp_request.c:255: undefined reference to
evbuffer_get_length'
evbuffer_pullup’/usr/local/src/dnscrypt-wrapper/tcp_request.c:262: undefined reference to
/usr/local/src/dnscrypt-wrapper/tcp_request.c:242: undefined reference to
evbuffer_get_length'
proxy_resolver_event_cb’:tcp_request.o: In function
/usr/local/src/dnscrypt-wrapper/tcp_request.c:221: undefined reference to
bufferevent_getfd'
client_proxy_read_cb’:tcp_request.o: In function
/usr/local/src/dnscrypt-wrapper/tcp_request.c:91: undefined reference to
bufferevent_get_input'
evbuffer_get_length’/usr/local/src/dnscrypt-wrapper/tcp_request.c:110: undefined reference to
/usr/local/src/dnscrypt-wrapper/tcp_request.c:123: undefined reference to
evbuffer_remove_buffer'
evbuffer_get_length’/usr/local/src/dnscrypt-wrapper/tcp_request.c:97: undefined reference to
tcp_request.o: In function
tcp_accept_timer_cb':
evconnlistener_enable’/usr/local/src/dnscrypt-wrapper/tcp_request.c:377: undefined reference to
main.o: In function
sockaddr_from_ip_and_port':
evutil_parse_sockaddr_port’/usr/local/src/dnscrypt-wrapper/main.c:44: undefined reference to
/usr/local/src/dnscrypt-wrapper/main.c:55: undefined reference to `evutil_parse_sockaddr_port’
collect2: ld returned 1 exit status
make: *** [dnscrypt-wrapper] Error 1