有关OpenVPN的DNS设置

来源:互联网 发布:阿里云搭梯子 编辑:程序博客网 时间:2024/06/11 17:05

在使用OpenVPN时,有的时候需要使用VPN的DNS,有的时候却需要使用本地网络的DNS。
OpenVPN可以在配置中支持DNS设置,如果是server来配置客户端DNS, 需要在配置文件中加入:
push "dhcp-option DNS 202.106.0.20"
push "dhcp-option DNS 8.8.8.8"

如果是在客户端配置,需要在配置文件设置:
dhcp-option DNS 202.106.0.20
dhcp-option DNS 8.8.8.8

对于非win32下比较麻烦
使用 /etc/openvpn/update-resolv-conf 这个脚本。在客户端配置文件 client.conf 后面加上如下三行:
script-security 2
up ./update-resolv-conf
down ./update-resolv-conf
连接成功后,脚本会自动修改 /etc/resolv.conf ,将 OpenVPN 服务器推送过来的 DNS 服务器地址填入。断开连接后,又会自动清空 /etc/resolv.conf。注意 update-resolv-conf 有没有执行权限,没有的话 chmod +x update-resolv-conf。

http://blog.chinaunix.net/uid-192452-id-3060529.html



0 0