network manager openvpn use local dns

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite
1












When you connect to openvpn from network manager. it does not encrypt dns requests through vpn, the result is that ubuntu uses local goverment dns results.







share|improve this question





















  • I have developed method with NetworkManager dispatcher and it works for 16.04 LTS. You can test it on 18.04 LTS.
    – N0rbert
    Jun 11 at 11:18










  • @N0rbert Not solved the problem. This is the profile : ufile.io/l5cvt
    – M-E-Activist
    Jun 11 at 18:01











  • @N0rbert adding these lines script-security 2 up /etc/openvpn/update-resolv-conf down /etc/openvpn/update-resolv-conf and running via openvpn command solve it, but I want to use it by network manager, but even sudo nmcli did not solve problem
    – M-E-Activist
    Jun 11 at 23:09















up vote
1
down vote

favorite
1












When you connect to openvpn from network manager. it does not encrypt dns requests through vpn, the result is that ubuntu uses local goverment dns results.







share|improve this question





















  • I have developed method with NetworkManager dispatcher and it works for 16.04 LTS. You can test it on 18.04 LTS.
    – N0rbert
    Jun 11 at 11:18










  • @N0rbert Not solved the problem. This is the profile : ufile.io/l5cvt
    – M-E-Activist
    Jun 11 at 18:01











  • @N0rbert adding these lines script-security 2 up /etc/openvpn/update-resolv-conf down /etc/openvpn/update-resolv-conf and running via openvpn command solve it, but I want to use it by network manager, but even sudo nmcli did not solve problem
    – M-E-Activist
    Jun 11 at 23:09













up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





When you connect to openvpn from network manager. it does not encrypt dns requests through vpn, the result is that ubuntu uses local goverment dns results.







share|improve this question













When you connect to openvpn from network manager. it does not encrypt dns requests through vpn, the result is that ubuntu uses local goverment dns results.









share|improve this question












share|improve this question




share|improve this question








edited Jun 14 at 19:19
























asked Jun 11 at 2:03









M-E-Activist

63




63











  • I have developed method with NetworkManager dispatcher and it works for 16.04 LTS. You can test it on 18.04 LTS.
    – N0rbert
    Jun 11 at 11:18










  • @N0rbert Not solved the problem. This is the profile : ufile.io/l5cvt
    – M-E-Activist
    Jun 11 at 18:01











  • @N0rbert adding these lines script-security 2 up /etc/openvpn/update-resolv-conf down /etc/openvpn/update-resolv-conf and running via openvpn command solve it, but I want to use it by network manager, but even sudo nmcli did not solve problem
    – M-E-Activist
    Jun 11 at 23:09

















  • I have developed method with NetworkManager dispatcher and it works for 16.04 LTS. You can test it on 18.04 LTS.
    – N0rbert
    Jun 11 at 11:18










  • @N0rbert Not solved the problem. This is the profile : ufile.io/l5cvt
    – M-E-Activist
    Jun 11 at 18:01











  • @N0rbert adding these lines script-security 2 up /etc/openvpn/update-resolv-conf down /etc/openvpn/update-resolv-conf and running via openvpn command solve it, but I want to use it by network manager, but even sudo nmcli did not solve problem
    – M-E-Activist
    Jun 11 at 23:09
















I have developed method with NetworkManager dispatcher and it works for 16.04 LTS. You can test it on 18.04 LTS.
– N0rbert
Jun 11 at 11:18




I have developed method with NetworkManager dispatcher and it works for 16.04 LTS. You can test it on 18.04 LTS.
– N0rbert
Jun 11 at 11:18












@N0rbert Not solved the problem. This is the profile : ufile.io/l5cvt
– M-E-Activist
Jun 11 at 18:01





@N0rbert Not solved the problem. This is the profile : ufile.io/l5cvt
– M-E-Activist
Jun 11 at 18:01













@N0rbert adding these lines script-security 2 up /etc/openvpn/update-resolv-conf down /etc/openvpn/update-resolv-conf and running via openvpn command solve it, but I want to use it by network manager, but even sudo nmcli did not solve problem
– M-E-Activist
Jun 11 at 23:09





@N0rbert adding these lines script-security 2 up /etc/openvpn/update-resolv-conf down /etc/openvpn/update-resolv-conf and running via openvpn command solve it, but I want to use it by network manager, but even sudo nmcli did not solve problem
– M-E-Activist
Jun 11 at 23:09











1 Answer
1






active

oldest

votes

















up vote
0
down vote













If you have set up your own VPN, you can modify the following line in the openvpn configuration file.



push "redirect-gateway def1 bypass-dhcp bypass-dns"


Change that to



push "redirect-gateway def1 bypass-dhcp"


and change the default configuration:



push "dhcp-option DNS 208.67.222.222"
push "dhcp-option DNS 208.67.220.220"


to



push "dhcp-option DNS 10.8.0.1"


Assuming 10.8.0.1 is the gateway you setup for your vpn clients. Note: Normally you don't want DHCP to go over VPN, if you do, remove the bypass-dhcp also.



Also make sure your server can handle the traffic by adding the following to the firewall rules.



iptables -v -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE


If those doesn't fix not your problem, then you need to look at your routing table on your client side to ensure that the gateway route over 10.8.0.1 has lower metric over the gateway configured on client machine (typically 19.168.0.1 or something). You can modify increase the non-vpn gateway to a higher number, lower metric have higher routing priority.



On your client machine after connected to the VPN, check the routing metric.



ip route
default via 10.8.0.1 dev tun0 proto static metric 50
default via 192.168.0.1 dev enx00 proto dhcp metric 100
default via 192.168.0.1 dev wlps proto dhcp metric 600
10.8.0.0/24 dev tun0 proto kernel scope link src 10.8.0.4 metric 50
100.77.34.23 via 192.168.0.1 dev enx00 proto static metric 100
....


As you can see, 10.8.0.1 tunnel have the lowest metric and hence will be tried first. The 192.168.0.1 of the local ISP on ethernet interface will be tried next, and so on.






share|improve this answer























  • My problem is only when you connecting from the network manager. It appears that it change DNS but send dns request unencrypted (not through vpn), which cause the government changes the result to its local DNS server (sink)
    – M-E-Activist
    Jun 14 at 19:38










  • Have you check your routing priority, the 10.8.0.1 dateway needs to have lower metric and also that the gateway can process the dns request (hence the masquerade rule). Try "ip route" to check the metric, it will only traverse down the route when it failed to match or cannot resolve.
    – Bernard Wei
    Jun 14 at 21:17










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1045445%2fnetwork-manager-openvpn-use-local-dns%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













If you have set up your own VPN, you can modify the following line in the openvpn configuration file.



push "redirect-gateway def1 bypass-dhcp bypass-dns"


Change that to



push "redirect-gateway def1 bypass-dhcp"


and change the default configuration:



push "dhcp-option DNS 208.67.222.222"
push "dhcp-option DNS 208.67.220.220"


to



push "dhcp-option DNS 10.8.0.1"


Assuming 10.8.0.1 is the gateway you setup for your vpn clients. Note: Normally you don't want DHCP to go over VPN, if you do, remove the bypass-dhcp also.



Also make sure your server can handle the traffic by adding the following to the firewall rules.



iptables -v -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE


If those doesn't fix not your problem, then you need to look at your routing table on your client side to ensure that the gateway route over 10.8.0.1 has lower metric over the gateway configured on client machine (typically 19.168.0.1 or something). You can modify increase the non-vpn gateway to a higher number, lower metric have higher routing priority.



On your client machine after connected to the VPN, check the routing metric.



ip route
default via 10.8.0.1 dev tun0 proto static metric 50
default via 192.168.0.1 dev enx00 proto dhcp metric 100
default via 192.168.0.1 dev wlps proto dhcp metric 600
10.8.0.0/24 dev tun0 proto kernel scope link src 10.8.0.4 metric 50
100.77.34.23 via 192.168.0.1 dev enx00 proto static metric 100
....


As you can see, 10.8.0.1 tunnel have the lowest metric and hence will be tried first. The 192.168.0.1 of the local ISP on ethernet interface will be tried next, and so on.






share|improve this answer























  • My problem is only when you connecting from the network manager. It appears that it change DNS but send dns request unencrypted (not through vpn), which cause the government changes the result to its local DNS server (sink)
    – M-E-Activist
    Jun 14 at 19:38










  • Have you check your routing priority, the 10.8.0.1 dateway needs to have lower metric and also that the gateway can process the dns request (hence the masquerade rule). Try "ip route" to check the metric, it will only traverse down the route when it failed to match or cannot resolve.
    – Bernard Wei
    Jun 14 at 21:17














up vote
0
down vote













If you have set up your own VPN, you can modify the following line in the openvpn configuration file.



push "redirect-gateway def1 bypass-dhcp bypass-dns"


Change that to



push "redirect-gateway def1 bypass-dhcp"


and change the default configuration:



push "dhcp-option DNS 208.67.222.222"
push "dhcp-option DNS 208.67.220.220"


to



push "dhcp-option DNS 10.8.0.1"


Assuming 10.8.0.1 is the gateway you setup for your vpn clients. Note: Normally you don't want DHCP to go over VPN, if you do, remove the bypass-dhcp also.



Also make sure your server can handle the traffic by adding the following to the firewall rules.



iptables -v -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE


If those doesn't fix not your problem, then you need to look at your routing table on your client side to ensure that the gateway route over 10.8.0.1 has lower metric over the gateway configured on client machine (typically 19.168.0.1 or something). You can modify increase the non-vpn gateway to a higher number, lower metric have higher routing priority.



On your client machine after connected to the VPN, check the routing metric.



ip route
default via 10.8.0.1 dev tun0 proto static metric 50
default via 192.168.0.1 dev enx00 proto dhcp metric 100
default via 192.168.0.1 dev wlps proto dhcp metric 600
10.8.0.0/24 dev tun0 proto kernel scope link src 10.8.0.4 metric 50
100.77.34.23 via 192.168.0.1 dev enx00 proto static metric 100
....


As you can see, 10.8.0.1 tunnel have the lowest metric and hence will be tried first. The 192.168.0.1 of the local ISP on ethernet interface will be tried next, and so on.






share|improve this answer























  • My problem is only when you connecting from the network manager. It appears that it change DNS but send dns request unencrypted (not through vpn), which cause the government changes the result to its local DNS server (sink)
    – M-E-Activist
    Jun 14 at 19:38










  • Have you check your routing priority, the 10.8.0.1 dateway needs to have lower metric and also that the gateway can process the dns request (hence the masquerade rule). Try "ip route" to check the metric, it will only traverse down the route when it failed to match or cannot resolve.
    – Bernard Wei
    Jun 14 at 21:17












up vote
0
down vote










up vote
0
down vote









If you have set up your own VPN, you can modify the following line in the openvpn configuration file.



push "redirect-gateway def1 bypass-dhcp bypass-dns"


Change that to



push "redirect-gateway def1 bypass-dhcp"


and change the default configuration:



push "dhcp-option DNS 208.67.222.222"
push "dhcp-option DNS 208.67.220.220"


to



push "dhcp-option DNS 10.8.0.1"


Assuming 10.8.0.1 is the gateway you setup for your vpn clients. Note: Normally you don't want DHCP to go over VPN, if you do, remove the bypass-dhcp also.



Also make sure your server can handle the traffic by adding the following to the firewall rules.



iptables -v -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE


If those doesn't fix not your problem, then you need to look at your routing table on your client side to ensure that the gateway route over 10.8.0.1 has lower metric over the gateway configured on client machine (typically 19.168.0.1 or something). You can modify increase the non-vpn gateway to a higher number, lower metric have higher routing priority.



On your client machine after connected to the VPN, check the routing metric.



ip route
default via 10.8.0.1 dev tun0 proto static metric 50
default via 192.168.0.1 dev enx00 proto dhcp metric 100
default via 192.168.0.1 dev wlps proto dhcp metric 600
10.8.0.0/24 dev tun0 proto kernel scope link src 10.8.0.4 metric 50
100.77.34.23 via 192.168.0.1 dev enx00 proto static metric 100
....


As you can see, 10.8.0.1 tunnel have the lowest metric and hence will be tried first. The 192.168.0.1 of the local ISP on ethernet interface will be tried next, and so on.






share|improve this answer















If you have set up your own VPN, you can modify the following line in the openvpn configuration file.



push "redirect-gateway def1 bypass-dhcp bypass-dns"


Change that to



push "redirect-gateway def1 bypass-dhcp"


and change the default configuration:



push "dhcp-option DNS 208.67.222.222"
push "dhcp-option DNS 208.67.220.220"


to



push "dhcp-option DNS 10.8.0.1"


Assuming 10.8.0.1 is the gateway you setup for your vpn clients. Note: Normally you don't want DHCP to go over VPN, if you do, remove the bypass-dhcp also.



Also make sure your server can handle the traffic by adding the following to the firewall rules.



iptables -v -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE


If those doesn't fix not your problem, then you need to look at your routing table on your client side to ensure that the gateway route over 10.8.0.1 has lower metric over the gateway configured on client machine (typically 19.168.0.1 or something). You can modify increase the non-vpn gateway to a higher number, lower metric have higher routing priority.



On your client machine after connected to the VPN, check the routing metric.



ip route
default via 10.8.0.1 dev tun0 proto static metric 50
default via 192.168.0.1 dev enx00 proto dhcp metric 100
default via 192.168.0.1 dev wlps proto dhcp metric 600
10.8.0.0/24 dev tun0 proto kernel scope link src 10.8.0.4 metric 50
100.77.34.23 via 192.168.0.1 dev enx00 proto static metric 100
....


As you can see, 10.8.0.1 tunnel have the lowest metric and hence will be tried first. The 192.168.0.1 of the local ISP on ethernet interface will be tried next, and so on.







share|improve this answer















share|improve this answer



share|improve this answer








edited Jun 14 at 21:21


























answered Jun 13 at 22:01









Bernard Wei

677313




677313











  • My problem is only when you connecting from the network manager. It appears that it change DNS but send dns request unencrypted (not through vpn), which cause the government changes the result to its local DNS server (sink)
    – M-E-Activist
    Jun 14 at 19:38










  • Have you check your routing priority, the 10.8.0.1 dateway needs to have lower metric and also that the gateway can process the dns request (hence the masquerade rule). Try "ip route" to check the metric, it will only traverse down the route when it failed to match or cannot resolve.
    – Bernard Wei
    Jun 14 at 21:17
















  • My problem is only when you connecting from the network manager. It appears that it change DNS but send dns request unencrypted (not through vpn), which cause the government changes the result to its local DNS server (sink)
    – M-E-Activist
    Jun 14 at 19:38










  • Have you check your routing priority, the 10.8.0.1 dateway needs to have lower metric and also that the gateway can process the dns request (hence the masquerade rule). Try "ip route" to check the metric, it will only traverse down the route when it failed to match or cannot resolve.
    – Bernard Wei
    Jun 14 at 21:17















My problem is only when you connecting from the network manager. It appears that it change DNS but send dns request unencrypted (not through vpn), which cause the government changes the result to its local DNS server (sink)
– M-E-Activist
Jun 14 at 19:38




My problem is only when you connecting from the network manager. It appears that it change DNS but send dns request unencrypted (not through vpn), which cause the government changes the result to its local DNS server (sink)
– M-E-Activist
Jun 14 at 19:38












Have you check your routing priority, the 10.8.0.1 dateway needs to have lower metric and also that the gateway can process the dns request (hence the masquerade rule). Try "ip route" to check the metric, it will only traverse down the route when it failed to match or cannot resolve.
– Bernard Wei
Jun 14 at 21:17




Have you check your routing priority, the 10.8.0.1 dateway needs to have lower metric and also that the gateway can process the dns request (hence the masquerade rule). Try "ip route" to check the metric, it will only traverse down the route when it failed to match or cannot resolve.
– Bernard Wei
Jun 14 at 21:17












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1045445%2fnetwork-manager-openvpn-use-local-dns%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

pylint3 and pip3 broken

Missing snmpget and snmpwalk

How to enroll fingerprints to Ubuntu 17.10 with VFS491