I get 3 IP addresses from my ISP, so after my modem I have a switch with three things. Two are servers, one is a router. All my personal computers are behind the router. My old server used to have two ethernet ports, so I would put one on the switch and one on the router so that I could keep server traffic off the router and still be able to have samba shares for media.
My new lower-power server only has one LAN. I will eventually get a USB ethernet plug for it, but until then I'd like to still have my samba shares. I thought to myself, there must be some way to achieve this via VPN.
So what I'd like to do is this, set up a VPN server on the server, allow clients behind the router to connect to it. That seemed simple enough, except that all the guides I've seen assume you can allocate addresses on the server's LAN. Since my server's LAN is the public internet I can't really do that. Is there any way I can make up some 'imaginary' LAN that exists only in the mind of the server and put my VPN clients on that?
To clarify, if the server is 68.232.SSS.SSS and if the router is 68.232.RRR.RRR and if computers behind the router are 10.0.0.1-255 then can I make VPN clients use addresses like 192.168.0.VPN?
OOoOoOOOooOOo
OoO Public OoOOo-----Server eth0 (Real) 68.232.SSS.SSS
OoO Internet OoO eth1 (Virtual) 192.168.0.1
OoOoOOoOOoOOOo
|
\--Router eth0 (WAN) 68.232.RRR.RRR
| eth1 (LAN) 10.0.0.1
|
\-----Client eth1 (Virtual) 192.168.0.2
eth0 (Real) 10.0.0.2
generate the certificates as in the official HOWTO:
Edit /etc/openvpn/easy-rsa/vars and fill in the appropiate values
copy the needed files from /etc/openvpn/easy-rsa/keys on the server to /etc/openvpn
for server: ca.crt dh1024.pem server.crt server.key
for client: ca.crt client.crt client.key
copy the appropriate sample configuration files from /usr/share/doc/openvpn/examples/sample-config-files/ to /etc/openvpn and decompress them
server: server.conf.gz
client: client.conf
edit the "remote" entry on the client /etc/openvpn/client.conf
Input the server name / IP-address. No other changes needs to be done
The service is ready to start now, the server is at 10.8.0.1
I assume you only need to access the server, additional work need to be done if you want to access other internal networks.
configure samba to listen on 10.8.0.0/24
Everything should have been done, leave comment here if something goes wrong.
Install
openvpn
on the server and the clients. On the server this will bring up a tun0 tunnel interface with an IP subnet of your choosing. The relevant options in the configuration file/etc/openvpn/server.conf
are:Unless you want the clients to route all their traffic through the VPN, comment out any lines looking like
push "route A.B.C.D W.X.Y.Z"
from the configuration.In addition to the network configuration, you have to generate certificates for the server and for the clients (both sides authenticate). How to do that is covered in OpenVPN documentation.
Finally, you have to configure the clients to be able to use this connection, so you put in their
/etc/openvpn/client.conf
:The 1194/udp is OpenVPN standard port, which needs to be open to the world in your firewall (hence the need for certificates).
I hope this answer and the documentation and sample configuration from openvpn will get you started.
While not a direct answer to your question, I suggest you consider mounting your server using sshfs instead. All you need is a running ssh server, instead of a complex combination of samba and a bolted-on vpn solution.
On the client, have a look at How to auto mount using sshfs? for a GUI solution or http://ubuntuforums.org/showthread.php?t=430312 for a system-wide fstab solution.