(Solved) Help with using VPN assigned DNS

Post new topic   Reply to topic    DD-WRT Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.)
Goto page 1, 2  Next
Author Message
wildcat2083
DD-WRT Novice


Joined: 10 Apr 2016
Posts: 24

PostPosted: Tue Aug 20, 2019 22:29    Post subject: (Solved) Help with using VPN assigned DNS Reply with quote
I have a WRT32X running VPN, through openvpn, Ive subscribed to a vpn service (expressvpn) got everything working including Policy Based Routing, my last step is getting the dns to use the vpn's dns provided when the tunnel is created, If I do not use pbr, this function works but it breaks remote access to my router so its not a viable option at this time, does anyone know of a script that can obtain the VPN's DNS server when the connection is established and forward it to the the addresses used in PBR?

Last edited by wildcat2083 on Tue Sep 03, 2019 20:02; edited 1 time in total
Sponsor
scar1943
DD-WRT User


Joined: 10 Nov 2018
Posts: 350
Location: South Carolina

PostPosted: Wed Aug 21, 2019 12:44    Post subject: Re: Help with using VPN assigned DNS Reply with quote
wildcat2083 wrote:
I have a WRT32X running VPN, through openvpn, Ive subscribed to a vpn service (expressvpn) got everything working including Policy Based Routing, my last step is getting the dns to use the vpn's dns provided when the tunnel is created, If I do not use pbr, this function works but it breaks remote access to my router so its not a viable option at this time, does anyone know of a script that can obtain the VPN's DNS server when the connection is established and forward it to the the addresses used in PBR?


I'm not sure how it is with OpenVPN, but I use NordVPN, and I enter the DNS servers manually in the "Basic Setup" tab. I don't think an auto-define is available with my provider, and if I don't define them, the setup uses my ISP definitions, which I don't want.
illuminati_tri
DD-WRT Novice


Joined: 15 Jul 2019
Posts: 41
Location: Texas

PostPosted: Wed Aug 21, 2019 15:34    Post subject: Re: Help with using VPN assigned DNS Reply with quote
wildcat2083 wrote:
I have a WRT32X running VPN, through openvpn, Ive subscribed to a vpn service (expressvpn) got everything working including Policy Based Routing, my last step is getting the dns to use the vpn's dns provided when the tunnel is created, If I do not use pbr, this function works but it breaks remote access to my router so its not a viable option at this time, does anyone know of a script that can obtain the VPN's DNS server when the connection is established and forward it to the the addresses used in PBR?


I use ExpressVPN and also have this issue. As mentioned above, you have to manually define them. The only way to find out what the DNS servers are is as follows (as far as I can tell):

Disconnect from VPN (this is important! otherwise you cannot click the Configure DNS button)
Go to My Account > DNS Settings > Configure DNS on this device

You will be forwarded to a page about "Mediastreamer" which will give you the primary and secondary DNS servers to use. These will not change based on which server you connect to.

Personally, I just use Cloudflare DNS (1.1.1.1) since they are privacy oriented/don't keep logs anyway and I find it to be faster. Also note that this DNS will be used for everything, including devices not going through the VPN.

Edited for clarification.

_________________
Linksys WRT3200ACM r41586
- ExpressVPN | VAP & PBR | Synology NAS
wildcat2083
DD-WRT Novice


Joined: 10 Apr 2016
Posts: 24

PostPosted: Wed Aug 21, 2019 19:38    Post subject: Re: Help with using VPN assigned DNS Reply with quote
So unless I feel like writing a script that gets dnsmasq to use the defined DNS from expressvpn, Im pretty well forced to track them down manually and add it to the dns section on the setup page
illuminati_tri
DD-WRT Novice


Joined: 15 Jul 2019
Posts: 41
Location: Texas

PostPosted: Wed Aug 21, 2019 19:43    Post subject: Re: Help with using VPN assigned DNS Reply with quote
wildcat2083 wrote:
So unless I feel like writing a script that gets dnsmasq to use the defined DNS from expressvpn, Im pretty well forced to track them down manually and add it to the dns section on the setup page


Pretty much yes, but the DNS servers aren't dynamically assigned for ExpressVPN as far as I can tell, so you can just find them that one time and put them in on the setup page.

_________________
Linksys WRT3200ACM r41586
- ExpressVPN | VAP & PBR | Synology NAS
Monza
DD-WRT User


Joined: 01 Jul 2018
Posts: 444

PostPosted: Wed Aug 21, 2019 20:27    Post subject: Reply with quote
I don't think this will help with your question but did you add the short code at the bottom of the setup page? Part of the process is also adding the code (interface=tun1) near the bottom of this page (see link) to the Services, Dnsmasq Options. I feel sure you did but thought I would mention it as it is sometimes overlooked.

https://www.expressvpn.com/support/vpn-setup/manual-config-for-dd-wrt-router-with-openvpn/

When I first signed up the code was "dhcp-option=6, xxx.xxx.xxx.xxx, xxx.xxx.xxx.xxx , xxx.xxx.xxx.xxx" replacing the x's with the DNS server addresses. Finding the change to "interface=tun1" later I talked with ExVPN support and they verified I could use either. I found no difference regardless of which code I used. I still use the original code above but it is more trouble if I change DNS servers as I need to remember to change this input as well. Not sure it would work for you but you might try it?

Also, if you have not, try the DNS leak test under tools at the bottom of the site page. It should confirm if you are using ExpVPN DNS servers.

Edit: I should add that the servers I have entered are public DNS no-log servers not the ExpVPN DNS servers. The ExpVPN DNS leak test tells me I am using ExpVPN DNS servers regardless of what I have entered.
scar1943
DD-WRT User


Joined: 10 Nov 2018
Posts: 350
Location: South Carolina

PostPosted: Wed Aug 21, 2019 22:34    Post subject: Reply with quote
Monza wrote:

Also, if you have not, try the DNS leak test under tools at the bottom of the site page. It should confirm if you are using ExpVPN DNS servers.

Edit: I should add that the servers I have entered are public DNS no-log servers not the ExpVPN DNS servers. The ExpVPN DNS leak test tells me I am using ExpVPN DNS servers regardless of what I have entered.


Try this one folks:

https://ipleak.net/
Monza
DD-WRT User


Joined: 01 Jul 2018
Posts: 444

PostPosted: Wed Aug 21, 2019 22:58    Post subject: Reply with quote
scar1943 wrote:
Try this one folks:


ExpVPN is working GREAT !! That site's info makes me proud of my vpn's smoke and mirrors =D

Thanks, will bookmark that site for future tests.
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12917
Location: Netherlands

PostPosted: Fri Aug 23, 2019 11:57    Post subject: Reply with quote
Most VPN providers push their DNS servers to you (if you are using PBR this might not be the case)

Until recently those pushed DNS servers were ignored.

Recent builds from BS (and some from Kong) add those pushed DNS servers at the top of /tmp/resolv.dnsmasq (where the DNS servers are stored)
Here an example of my /tmp/resolv.dnsmasq:
Code:
nameserver 209.222.18.222
nameserver 209.222.18.218
nameserver 9.9.9.9
nameserver 8.8.8.8
nameserver 192.168.0.1

The lower three are what is in Setup/Static DNS
the first two are added by my VPN provider.
If you enable "Query DNS in strict order" those will be used.

So take a look in your own /tmp/resolv.dnsmasq to see what is going on Smile

However it is not a fool proof solution, because if the first two are not responding the third etc. is used.
For a fool proof solution add the following to Additional DNSMasq options:
Code:
no-resolv
server=209.222.18.222
server=209.222.18.218


I use dnsleaktest.com and ipleak.net to also check

For some background reading:
https://svn.dd-wrt.com/ticket/6733

https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=318662 in the second posting there is a paper about DNS leak

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Monza
DD-WRT User


Joined: 01 Jul 2018
Posts: 444

PostPosted: Fri Aug 23, 2019 12:31    Post subject: Reply with quote
egc wrote:

Until recently those pushed DNS servers were ignored.

Recent builds from BS (and some from Kong) add those pushed DNS servers at the top of /tmp/resolv.dnsmasq (where the DNS servers are stored)


Thanks for this info as it clarified several questions I had about the VPN DNS servers not being used until recently.
wildcat2083
DD-WRT Novice


Joined: 10 Apr 2016
Posts: 24

PostPosted: Sat Aug 31, 2019 3:41    Post subject: Reply with quote
my issue with this is I AM using PBR as i also run a vpn server as well, oddly enough tho when I connect to my router via my server I have the client IP block in the openvpn client PBR and only when i connect via my server as a client to my router then I will connect only to Expressvpn DNS and it bypasses the manual ones i have set which are google and opendns, but if I am attached locally either via wifi or Ethernet then my router will not assign my pbr clients to use the VPN (client) dns provided, its weird, I can't figure this out

i have tried to set my dns settings to match the openvpn client dns that's pushed but the problem with that is the DNS changes each time the client openvpn changes so if I make a change or reboot then that solution doesn't work, what I need is a script that reads the first line of /tmp/resolv.dnsmasq (as the DNS I need is on the first line) and have any of my dhcp clients that match PBR to use that ... then my devices assigned to PBR would route correctly and the non VPN devices would continue to use opendns or google, the odd part is seeing when i connect remotly via my server openvpn and it uses the Client vpn dns which is exactly what Im trying to get wifi or LAN (ethernet) to do, unfortunatly the only option is to NOT use PBR but then I can't access my vpn server
SurprisedItWorks
DD-WRT Guru


Joined: 04 Aug 2018
Posts: 1447
Location: Appalachian mountains, USA

PostPosted: Sat Aug 31, 2019 14:31    Post subject: Reply with quote
If you are using PBR to run clients on some interface athXXX (even a VAP) through the vpn and want to have clients on that interface in particular use the vpn provider's recommended DNS server (without forcing the entire router to use that server), go to GUI>Wireless>BasicSettings, find the section for athXXX, check the "Advanced Settings" box, scroll to the bottom of the material that then appears, and enter the vpn provider's DNS server in "Optional DNS Target." For an additional bridge beyond br0, see the GUI>Setup>Networking page instead. The "main bridge" br0 is handled by the basic dnsmasq setup.

Of note, however: Whether you use this method to deal with one interface or put the DNS-server IPs in Basic Settings for the whole router, the router's interactions with your specified DNS server do not go through the vpn. They go unencrypted through the wan interface.

If you want encrypted DNS, you can go with the modern approach, which is trickier to set up (requires using /jffs), and use DNS-over-TLS as outlined in tutorial https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1166512. Or you can use the venerable DNSCrypt system.

DNSCrypt uses encryption to/from your specified DNS provider, but there is no encryption further upstream, from your chosen DNS provider to/from authoritative DNS servers. Secure validation of DNS traffic, to prevent DNS spoofing, was apparently the major DNSCrypt design goal. It also appears that DNSCrypt is being phased out of dd-wrt, as the "Encrypt DNS" button no longer appears in the DNSMasq config section (GUI>Services>Services) in recent releases. However, the underlying DNSCrypt tools are still there (at least as of BS release r40784 for my WRT1900ACSv2) in the router and can be used.

See my Sun Jan 06, 2019 post at https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=318094&start=6 for details of setting up DNSCrypt in the Startup commands in GUI>Administration>Commands. My setup is specific to IPv4, as I have IPv6 disabled in the router. To have this DNSCrypt setup be used for a subnet 192.168.Y.0/24 such as one set up for athXX as discussed above, enter 192.168.Y.1 as the "Optional DNS Target". It doesn't matter what you put for DNS servers in the Basic Setup, as the no-resolv line my post mentions putting in "Additional Dnsmasq Options" has dnsmasq ignore those Basic Setup entries and use the DNSCrypt system exclusively.

For the past eight months I have used that DNSCrypt approach using Quad9 DNS with Adguard DNS as backup, and it works great. I simply decided I felt safer with encrypted interactions with Quad9 than with unencrypted access to the VPN provider's DNS system. When I flash a new release, I always verify that Quad9 DNS is actually being accessed by going into the CLI and running the command tcpdump -i eth0 | grep -i quad9 and watching its output while I access websites on my phone or computer. Should be lots of packets going to and from dns9.quad9.net.8443. (Exit the tcpdump with control-C.) Here eth0 is my WAN interface. Change for your system as appropriate. Verify also by looking for ISP WoodyNet in the tests at https://www.dnsleaktest.com/. The test at https://ipleak.net/ is interesting but is harder to interpret, as it sends so many requests to Quad9 in a short time that it seems to trigger Quad9 to switch to different servers. Unless you know specifically what DNS servers your ISP uses, you won't know what to watch for to spot leaks. My ISP uses dozens of servers, so for me it's hopeless.

See https://quad9.net/ if you are not familiar with Quad9 and https://adguard.com/en/adguard-dns/overview.html for more on Adguard DNS. Both DNS providers screen out malware domains, claim reasonable privacy policies (i.e. not logging your IP), and have servers worldwide. Adguard DNS also filters out ad servers and trackers, but ad filtering will break some websites and streaming systems (e.g. hulu). Quad9 is by far the bigger system, has way more servers, is really fast, and provides DNSSEC validation as well when possible. Adguard also offers optional screening out of "adult" domains -- use "adguard-dns-family" instead of "adguard-dns" in the setup -- but it's not clear to me whether they offer DNSSEC. I have seen in the past that they intended to move to that. I don't know whether they are there. However, dd-wrt will not support DNSSEC unless you both configure it in dnsmasq and set up only DNSSEC-capable DNS servers. Test DNSSEC capability of your system at https://dnssec.vs.uni-due.de/. Don't obsess over DNSSEC though; it's only useful for domains that implement it on the other end, and very few banks or other important domains seem to have it set up. Test at https://dnssec-debugger.verisignlabs.com/.

_________________
2x Netgear XR500 and 3x Linksys WRT1900ACSv2 on 53544: VLANs, VAPs, NAS, station mode, OpenVPN client (AirVPN), wireguard server (AirVPN port forward) and clients (AzireVPN, AirVPN, private), 3 DNSCrypt providers via VPN.
wildcat2083
DD-WRT Novice


Joined: 10 Apr 2016
Posts: 24

PostPosted: Sat Aug 31, 2019 16:21    Post subject: Reply with quote
SurprisedItWorks wrote:
If you are using PBR to run clients on some interface athXXX (even a VAP) through the vpn and want to have clients on that interface in particular use the vpn provider's recommended DNS server (without forcing the entire router to use that server), go to GUI>Wireless>BasicSettings, find the section for athXXX, check the "Advanced Settings" box, scroll to the bottom of the material that then appears, and enter the vpn provider's DNS server in "Optional DNS Target." For an additional bridge beyond br0, see the GUI>Setup>Networking page instead. The "main bridge" br0 is handled by the basic dnsmasq setup.

Of note, however: Whether you use this method to deal with one interface or put the DNS-server IPs in Basic Settings for the whole router, the router's interactions with your specified DNS server do not go through the vpn. They go unencrypted through the wan interface.

If you want encrypted DNS, you can go with the modern approach, which is trickier to set up (requires using /jffs), and use DNS-over-TLS as outlined in tutorial https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1166512. Or you can use the venerable DNSCrypt system.

DNSCrypt uses encryption to/from your specified DNS provider, but there is no encryption further upstream, from your chosen DNS provider to/from authoritative DNS servers. Secure validation of DNS traffic, to prevent DNS spoofing, was apparently the major DNSCrypt design goal. It also appears that DNSCrypt is being phased out of dd-wrt, as the "Encrypt DNS" button no longer appears in the DNSMasq config section (GUI>Services>Services) in recent releases. However, the underlying DNSCrypt tools are still there (at least as of BS release r40784 for my WRT1900ACSv2) in the router and can be used.

See my Sun Jan 06, 2019 post at https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=318094&start=6 for details of setting up DNSCrypt in the Startup commands in GUI>Administration>Commands. My setup is specific to IPv4, as I have IPv6 disabled in the router. To have this DNSCrypt setup be used for a subnet 192.168.Y.0/24 such as one set up for athXX as discussed above, enter 192.168.Y.1 as the "Optional DNS Target". It doesn't matter what you put for DNS servers in the Basic Setup, as the no-resolv line my post mentions putting in "Additional Dnsmasq Options" has dnsmasq ignore those Basic Setup entries and use the DNSCrypt system exclusively.

For the past eight months I have used that DNSCrypt approach using Quad9 DNS with Adguard DNS as backup, and it works great. I simply decided I felt safer with encrypted interactions with Quad9 than with unencrypted access to the VPN provider's DNS system. When I flash a new release, I always verify that Quad9 DNS is actually being accessed by going into the CLI and running the command tcpdump -i eth0 | grep -i quad9 and watching its output while I access websites on my phone or computer. Should be lots of packets going to and from dns9.quad9.net.8443. (Exit the tcpdump with control-C.) Here eth0 is my WAN interface. Change for your system as appropriate. Verify also by looking for ISP WoodyNet in the tests at https://www.dnsleaktest.com/. The test at https://ipleak.net/ is interesting but is harder to interpret, as it sends so many requests to Quad9 in a short time that it seems to trigger Quad9 to switch to different servers. Unless you know specifically what DNS servers your ISP uses, you won't know what to watch for to spot leaks. My ISP uses dozens of servers, so for me it's hopeless.

See https://quad9.net/ if you are not familiar with Quad9 and https://adguard.com/en/adguard-dns/overview.html for more on Adguard DNS. Both DNS providers screen out malware domains, claim reasonable privacy policies (i.e. not logging your IP), and have servers worldwide. Adguard DNS also filters out ad servers and trackers, but ad filtering will break some websites and streaming systems (e.g. hulu). Quad9 is by far the bigger system, has way more servers, is really fast, and provides DNSSEC validation as well when possible. Adguard also offers optional screening out of "adult" domains -- use "adguard-dns-family" instead of "adguard-dns" in the setup -- but it's not clear to me whether they offer DNSSEC. I have seen in the past that they intended to move to that. I don't know whether they are there. However, dd-wrt will not support DNSSEC unless you both configure it in dnsmasq and set up only DNSSEC-capable DNS servers. Test DNSSEC capability of your system at https://dnssec.vs.uni-due.de/. Don't obsess over DNSSEC though; it's only useful for domains that implement it on the other end, and very few banks or other important domains seem to have it set up. Test at https://dnssec-debugger.verisignlabs.com/.


Thank you for the information, seems I have some options, the DNScrypt looks appealing
anon_me
DD-WRT Novice


Joined: 20 Mar 2019
Posts: 16

PostPosted: Tue Sep 03, 2019 3:06    Post subject: Reply with quote
Similar situation for me. Looking for some clarification or required config.

Have OpenVPN setup (Windscribe) and working as expected except the single ethernet LAN client is receiving the DNS servers from Setup > Basic Setup, which the other LAN clients require for content filtering (OpenDNS).

How can I push the VPN DNS client through to the single VPN LAN client without effecting the other non-VPN LAN clients?

I did see the comment about "Optional DNS Target" but this is an Ethernet client nor a Wireless client and I'm struggling to find the equivalent place for the Ethernet client.

Edit I do see mention of this in the OpenVPN UI page but unsure if it will do what I want.

Quote:
to push DNS/WINS add 'push "dhcp-option DNS (or WINS) IP"' to the config.


Also of note. I do not see my VPN's DNS servers in the resolve.dnsmasq file. It only shows the OpenDNS servers, google, and 1 other I'm unfamiliar with.

I'm running DD-WRT v3.0-r37305 std ( 10/10/18 ). If a newer release would resolve this I can investigate an update.


Last edited by anon_me on Tue Sep 03, 2019 5:56; edited 1 time in total
anon_me
DD-WRT Novice


Joined: 20 Mar 2019
Posts: 16

PostPosted: Tue Sep 03, 2019 6:08    Post subject: Reply with quote
anon_me wrote:
Similar situation for me. Looking for some clarification or required config.

Have OpenVPN setup (Windscribe) and working as expected except the single ethernet LAN client is receiving the DNS servers from Setup > Basic Setup, which the other LAN clients require for content filtering (OpenDNS).

How can I push the VPN DNS client through to the single VPN LAN client without effecting the other non-VPN LAN clients?

I did see the comment about "Optional DNS Target" but this is an Ethernet client nor a Wireless client and I'm struggling to find the equivalent place for the Ethernet client.

Edit I do see mention of this in the OpenVPN UI page but unsure if it will do what I want.

Quote:
to push DNS/WINS add 'push "dhcp-option DNS (or WINS) IP"' to the config.


Also of note. I do not see my VPN's DNS servers in the resolve.dnsmasq file. It only shows the OpenDNS servers, google, and 1 other I'm unfamiliar with.

I'm running DD-WRT v3.0-r37305 std ( 10/10/18 ). If a newer release would resolve this I can investigate an update.


After more digging I see that my version of DD-WRT does not have the fix that will allow the push DNS settings to propagate through to the VPN clients. That was seemingly addressed in this change https://svn.dd-wrt.com/changeset/40444 and as mentioned above was very recent (about a month ago).

Before verifying that I did attempt the DNSmasq alternate fix mentioned above (and https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1130455#1130455), but that did not seem to do anything even after removing the OpenDNS servers and rebooting (just to make sure they did not interfere).

Still hoping to find a fix outside of a firmware upgrade as that's an undertaking I can't deal with right now.


Last edited by anon_me on Tue Sep 03, 2019 6:27; edited 3 times in total
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.) All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum