Before I ask my question, let me clarify for dear moderators that I've searched a lot for a solution, but none of the questions/answers on Askubuntu (and other Stackexchange sites) addresses my problem.
I've set up openVPN on a Debian server and also on my Ubuntu host, and now I'm trying to route all traffic (except DHCP) at client-side through openVPN tunnel. I read almost all guides on the Web with no success. I read this, this, this, this, this, this, this, this, this, and some other guides and articles. And none of them resolved the porblem. If I use redirect-gateway def1
command at my client.conf
(or push it from server-side (server.conf
)), at client-side I cannot resolve domain names to IPs (basically DNS queries fail), but I can ping public (valid) IPs e.g. Google's DNS server (from my client host).
Here is my server.conf:
proto udp
port 1194
dev tun
ca ca.crt
cert myserver.crt
key myserver.key
dh dh1024.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
duplicate-cn
keepalive 10 120
comp-lzo
persist-key
persist-tun
status openvpn-status.log
log openvpn.log
verb 3
And here's my client.conf
:
client
dev tun
proto udp
remote x.x.x.x 1194
nobind
persist-key
persist-tun
mute-replay-warnings
ca ca.crt
cert client1.crt
key client1.key
ns-cert-type server
comp-lzo
verb 3
redirect-gateway def1 bypass-dns bypass-dhcp
On the server side, I also issued the following command (to NAT the incoming openVPN traffic):
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
Here are the log and openvpn-status.log.
UPDATE:
If I use te following command at server side (redirecting DNS queries) mentioned here, the problem gets resolved (apparently), but how can I make sure that the traffic is going through the VPN link?
iptables -t nat -A PREROUTING -i tun+ -p udp --dport 53 -j DNAT --to-destination 8.8.8.8
0 Answers