1

I'm sorry if this question was asked already, but I didn't even know how to search for it, so if you already have a solution, please be kind enough to reply with a link. So a friend of mine has a 4g connection as their internet connection without a public IP address and they wanted to access a samba share remotely. I have a vdsl connection with a public IP address and I run an OpenVPN server on a raspberry pi, so they asked me if they could use my VPN to use my private IP address to connect to their samba share. I can't figure out how to do this but I really want to help my friend out. Thanks in advance to anyone who can help.

1 Answer 1

0

you can do what you asked for, here is some instructions to achieve it.

it is a matter of port forwarding, so you first have to control what internal IP address you give to your 4G client, you can do this by using openssl key, and setup a special profile with a dedicated address attached to this special key using the ccd directory and making a file named after the key in that directory.

that is, in your openvpn server.conf just add

client-config-dir ccd

if your client key name is samba4Gshare then create a file /etc/openvpn/ccd/samba4Gshare

and put in it some dedicated IP address (for example if your openvpn internal lan is 192.168.2.0/24)

ifconfig-push 192.168.2.6 192.168.2.5

So 192.168.2.6 will be the dedicated IP for your samba4Gshare and 192.168.2.5 will be used internally by openvpn for connections with this client.(be aware that openvpn by default use some /30 internal subnets so you have to segment your internal LAN in some /30)

Then you setup an openvpn client on your samba share using this openssl key so your client connect to your openvpn server and got the dedicated IP address.

once the client connect with its dedicated key and it has this special fixed IP address, if you use iptables/netfilter you can just forward connections from your raspberryPI IP with DNAT in table nat/PREROUTING to the samba share openvpn dedicated IP address.

At this time, you may be able to see the share from your RaspberryPI IP address using a client in your local private LAN.

After that, last part is to forward a port from your VDSL to your raspberryPi so you can use this port to access your samba share from the public IP of your VDSL. As a matter of fact you need to ajust route on your samba share so the connections that came from your openvpn links get back to the same ways to the requester. it may require some MASQUERADE or dynamic route based on port if your samba share has different route to reach internet or your openvpn segment.

For instance if you MASQUERADE on your openvpn server it may works correctly directly out of the box, but your samba share may not see what real IP is requesting the share, because for this share every request seems to come from your openvpn server. It may not be very secure to not control the area that is allowed.

VDSL(Pub IP)-->RASPBERRY(Private IP)-->SAMBA(openvpn IP)

where --> mean port forward.

if you give detail on what are your internals IP and router I can give you samples commands.

regards and good luck.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .