使用OpenVPN的Ubuntu 12.04上的DNS问题


11

我按照本指南在家庭网络上设置了openvpn。

我一开始不小心下载了ubuntu 12.10,却没有注意到,我继续按照指南进行操作...

然后,我从这里进行了一些操作:推送“重定向网关def1” iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE

启用浏览。

OpenVPN功能全面。

我的意思是,我可以远程访问(访问内部服务)并从外部浏览时屏蔽我的IP。

然后我意识到我想要ubuntu 12.04,所以我在新安装中遵循相同的过程。

现在的问题是DNS无法解析。

我注意到下载openvpn时下载了我卸载的resolvconf,并尝试手动进行此操作。

这是我系统中的一些内容:

openvpn server.conf:

mode server
tls-server

local 192.168.1.101 ## ip/hostname of server
port 80 ## default openvpn port
proto udp

#bridging directive
dev tap0 ## If you need multiple tap devices, add them here
up "/etc/openvpn/up.sh br0 tap0 1500"
down "/etc/openvpn/down.sh br0 tap0"

persist-key
persist-tun

#certificates and encryption
ca ca.crt
cert server.crt
key server.key  # This file should be kept secret
dh dh1024.pem
tls-auth ta.key 0 # This file is secret

cipher BF-CBC        # Blowfish (default)
comp-lzo

#DHCP Information
ifconfig-pool-persist ipp.txt
server-bridge 192.168.1.10 255.255.255.0 192.168.1.100 192.168.1.110
push "redirect-gateway def1"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"


#push "dhcp-option DOMAIN yourdomain.com"
#push "redirect-gateway local def1"
#push "dhcp-option DNS 8.8.8.8"
#push "redirect-gateway def1 bypass-dhcp"
#push "dhcp-option DNS 192.168.1.1"
#push "dhcp-option DNS 8.8.8.8"


max-clients 10 ## set this to the max number of clients that should be connected at a time

#log and security
user nobody
group nogroup
keepalive 10 120
status openvpn-status.log
verb 3

/ etc / network / interfaces:

root@ironman:~# cat /etc/network/interfaces 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
#auto lo
#iface lo inet loopback

# The primary network interface
#auto eth0
#iface eth0 inet dhcp
#############OPEN VPN SETUP###############
## This is the network bridge declaration

## Start these interfaces on boot
auto lo br0

iface lo inet loopback

iface br0 inet static 
  address 192.168.1.101 
  netmask 255.255.255.0
  gateway 192.168.1.1
  bridge_ports eth0
  nameserver 8.8.8.8
iface eth0 inet manual
  up ip link set $IFACE up promisc on
  down ip link set $IFACE down promisc off
  nameserver 8.8.8.8

root@ironman:~# cat /etc/resolv.conf 
nameserver 8.8.8.8
nameserver 192.168.1.1


root@ironman:~# ping google.com
PING google.com (74.125.239.100) 56(84) bytes of data.
64 bytes from nuq05s01-in-f4.1e100.net (74.125.239.100): icmp_req=1 ttl=55 time=22.6 ms
64 bytes from nuq05s01-in-f4.1e100.net (74.125.239.100): icmp_req=2 ttl=55 time=21.7 ms
64 bytes from nuq05s01-in-f4.1e100.net (74.125.239.100): icmp_req=3 ttl=55 time=22.8 ms

任何帮助,将不胜感激


您可以ping原始IP吗?我遇到了类似的问题,结果发现找到了DNS,但是我的防火墙阻止了所有内容。在我禁用该功能和/或添加一条规则之后,OpenVPN可以正常工作。
塞林2015年

Answers:


32

这对我有用:http : //www.softwarepassion.com/solving-dns-problems-with-openvpn-on-ubuntu-box/

重要的步骤是将以下三行添加到客户端openvpn配置文件中:

script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

另外,请确保该resolvconf软件包已安装在客户端上,因为此脚本依赖于此脚本。

它适用于openvpn客户端服务或命令(sudo openvpn youropenvpn.conf)。

但是,Ubuntu网络管理器不适用于此配置。到目前为止这是一个问题:https : //bugs.launchpad.net/ubuntu/+source/openvpn/+bug/1211110


我希望有一种方法可以给你这个答案1K的分数,而这个答案似乎到处都是缺失的!
nobeh

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.