Access USB HDD from OpenVPN Client

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
racerx250
DD-WRT Novice


Joined: 08 Aug 2020
Posts: 6

PostPosted: Tue Aug 11, 2020 0:34    Post subject: Access USB HDD from OpenVPN Client Reply with quote
Router: Netgear R6700v3
DD-WRT Build 43420 std 6/15/20

I have an external USB HDD plugged into the router's usb port. I can access that drive from any PC on the local network. I have an OpenVPN server setup on the router.

When I try to access the same drive while connected as an OpenVPN client, it's not there. I have found a few threads on this forum with the exact issue, but the configurations they've used are quite a bit dated.(2014)

https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=916665
Specifically this one.

I've used the most updated OpenVPN server configuration released by user "egc" (huge thanks to you for that!) to get it up and running. I'm out of ideas.

Any advice is greatly appreciated.
Sponsor
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9157

PostPosted: Tue Aug 11, 2020 2:13    Post subject: Reply with quote
First try disabling the "CVE-2019-14899 Mitigation" option.

Make sure you're referencing the USB drive by its IP on the private network (e.g., 192.168.1.1) and NOT the OpenVPN server's IP on the tunnel. Of course, you also have to push that private network to OpenVPN client in the OpenVPN server Additional Config field. I'm just using 192.168.1.x as an example, so adjust accordingly.

Code:
push "route 192.168.1.0 255.255.255.0"


Note, the above is NOT necessary if you're already pushing the OpenVPN server as the default gateway to the OpenVPN client, but it never hurts to push it anyway (in case you later decide NOT to push the default gateway).

If it's still not working, try the following firewall script.

Code:
LAN_IP="$(nvram get lan_ipaddr)"
OVPN_NET="$(nvram get openvpn_net)/$(nvram get openvpn_tunmask)"
iptables -t nat -I POSTROUTING -s $OVPN_NET -o br0 -j SNAT --to $LAN_IP

_________________
ddwrt-ovpn-split-basic.sh (UPDATED!) * ddwrt-ovpn-split-advanced.sh (UPDATED!) * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-remote-access.sh * ddwrt-ovpn-client-backup.sh * ddwrt-mount-usb-drives.sh * ddwrt-blacklist-domains.sh * ddwrt-wol-port-forward.sh * ddwrt-dns-monitor.sh (NEW!)
racerx250
DD-WRT Novice


Joined: 08 Aug 2020
Posts: 6

PostPosted: Tue Aug 11, 2020 17:47    Post subject: Reply with quote
I just disabled cve mitigation, added the push route(edited to 192.168.2.0), and added those firewall scripts. Still did not have any luck. The only firewall script I have up (before adding yours) was

Code:
iptables -t nat -I POSTROUTING -s 10.8.0.0/24 -o $(get_wanface) -j MASQUERADE


Additional server config

Code:
# Additional config starts here
dh /jffs/etc/openvpn/dh2048.pem
ca /jffs/etc/ssl/certs/ca.crt
cert /jffs/etc/ssl/certs/router.server.crt
key /jffs/etc/ssl/private/router.key
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12917
Location: Netherlands

PostPosted: Tue Aug 11, 2020 21:32    Post subject: Reply with quote
See the openvpn troubleshooting guide:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=318795

You have to tweak ksmbd , the samba server to listen on the tun interface.

_________________
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
racerx250
DD-WRT Novice


Joined: 08 Aug 2020
Posts: 6

PostPosted: Tue Aug 11, 2020 23:45    Post subject: Reply with quote
egc, I followed that guide down to the letter just now. I have successfully been able to remote in the the HDD from my android phone while it's connected to OpenVPN.

Still can't get my laptop to see it. I've connected to the local network, mapped the drive, connected to a remote network then through OpenVPN. When attempting to connect to the mapped drive, it gives an error (see below). I've triple checked file sharing is enabled and tried turning off the windows defender firewall. Still nothing.

I've also tried removing the mapped drive and letting windows find it while connected remotely. Also no luck.
Any ideas?

edit: I forgot to add, I can ping the router's IP while connected to OpenVPN, I can ping the clients IP as well connected locally. I also have internet access as well.
racerx250
DD-WRT Novice


Joined: 08 Aug 2020
Posts: 6

PostPosted: Wed Aug 12, 2020 0:54    Post subject: Reply with quote
I forgot to mention, these lines must be added for the HDD to be accessed from the android device.

Code:
push "dhcp-option DNS 192.168.2.0"
push "dhcp-option DNS 8.8.8.8"


Forced DNS direction must also be unchecked @ Setup>Basic Setup.

Still haven't had luck getting access from the laptop while connected via OpenVPN.
mrjcd
DD-WRT Guru


Joined: 31 Jan 2015
Posts: 6291
Location: Texas

PostPosted: Wed Aug 12, 2020 2:18    Post subject: Reply with quote
iffin you will only:
push "dhcp-option DNS ovpn server IP "

from your pic that would be:
push "dhcp-option DNS 10.8.0.1"

all ovpn clients should then use whatever DNS your local net uses...
...that's just what I have done for years on the EA8500

---
EDIT:
push router's IP or ovpn server's IP as DNS should work same but ---
reason I said you could push ovpn server IP as DNS ---
if also running unbound and pushing router's IP as DNS thru its ovpn server did NOT work...
...used to in old days but somepin changed with all that...or so it is on the EA8500.


Last edited by mrjcd on Thu Aug 13, 2020 8:27; edited 1 time in total
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12917
Location: Netherlands

PostPosted: Wed Aug 12, 2020 8:19    Post subject: Reply with quote
Use the IP address of the router. (like \\192.168.1.1 in windows explorer)

You can use local DNS but besides pushing the router as DNS server you have to set DNSMasq to listen on the tun interface (see the guide)

_________________
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
racerx250
DD-WRT Novice


Joined: 08 Aug 2020
Posts: 6

PostPosted: Thu Aug 13, 2020 17:46    Post subject: Reply with quote
egc wrote:
Use the IP address of the router. (like \\192.168.1.1 in windows explorer)

You can use local DNS but besides pushing the router as DNS server you have to set DNSMasq to listen on the tun interface (see the guide)


egc,

I messed with this for almost a week. I re-read your setup and troubleshooting guide again, paying a bit closer attention to what you were telling me.

IT WORKS!!!

Thank you so much for taking time to keep redirecting me to re-read your guide.
racerx250
DD-WRT Novice


Joined: 08 Aug 2020
Posts: 6

PostPosted: Thu Aug 13, 2020 18:19    Post subject: Reply with quote
For those that see this in the future, there were only a few small changes I had to make.

My server additional config now looks like this
Code:
# Additional config starts here
dh /jffs/etc/openvpn/dh2048.pem
ca /jffs/etc/ssl/certs/ca.crt
cert /jffs/etc/ssl/certs/router.server.crt
key /jffs/etc/ssl/private/router.key


route 192.168.43.0 255.255.255.0 10.8.0.0
push "dhcp-option DNS 10.8.0.1"
push "route 192.168.2.0 255.255.255.0 10.8.0.0"
client-config-dir /jffs/ccd

The lines for cert directory are not in egc's guide. I used that from anther guide on this forum while I was configuring the OpenVPN server.

My firewall commands
Code:
iptables -t nat -I POSTROUTING -s 10.8.0.0/24 -o $(get_wanface) -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.43.0/24 -o $(get_wanface) -j MASQUERADE


I had skipped the part to make a ccd directory in /jffs and creating the ccd config file as well.

I tried to remove the push route command because redirect default gateway is enabled but didn't work without it. Again, big thanks to egc for publishing this content for all of us. Thank you to everyone else that chimed in with suggestions as well.

edit: The USB HDD can also be accessed from my Android phone using AndSMB.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking 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