LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-04-2014, 07:31 AM   #16
sisu_star
LQ Newbie
 
Registered: Feb 2014
Location: Helsinki, Finland
Distribution: Ubuntu
Posts: 14

Original Poster
Rep: Reputation: Disabled
Working configs


Just wanted to recap the working configs, in case someone has the same dilemma.

Servers config file (/etc/samba/server.conf):
Code:
;local a.b.c.d

port 1194

;proto tcp
proto udp

;dev tap
dev tun

;dev-node MyTap

ca ca.crt
cert [CENSORED].crt
key [CENSORED].key  # This file should be kept secret

dh dh2048.pem

;server 172.31.255.100 255.255.255.254
server 10.8.0.0 255.255.255.0

;ifconfig-pool-persist ipp.txt

;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100

;server-bridge

push "route 192.168.10.0 255.255.255.0"
push "route 192.168.20.0 255.255.255.0"


;client-config-dir ccd
;route 192.168.40.128 255.255.255.248

;client-config-dir ccd
;route 10.9.0.0 255.255.255.252

;learn-address ./script

;push "redirect-gateway"

;push "dhcp-option DNS 192.168.10.1"
;push "dhcp-option DNS 208.67.220.220"

;client-to-client

;duplicate-cn

keepalive 10 120

tls-auth ta.key 0 # This file is secret

;cipher BF-CBC        # Blowfish (default)
;cipher AES-128-CBC   # AES
;cipher DES-EDE3-CBC  # Triple-DES

comp-lzo

;max-clients 100

;user nobody
;group nogroup

persist-key
persist-tun

status openvpn-status.log

;log         openvpn.log
log-append  openvpn.log

verb 6

;mute 20
Clients config file (for OpenVNP GUI found at: https://openvpn.net/index.php/open-s...wnloads.html):
Code:
client

;dev tap
dev tun

;dev-node MyTap

;proto tcp
proto udp

remote [IP.OF.SERVER.HERE] 1194
;remote 192.168.10.53 1194

;remote-random

resolv-retry infinite

nobind

;user nobody
;group nobody

persist-key
persist-tun

;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]

;mute-replay-warnings

ca ca.crt
cert [CENSORED].crt
key [CENSORED].key

ns-cert-type server

tls-auth ta.key 1

;cipher x

comp-lzo

verb 6

;mute 20
In my case the client file is found at "c:\Program Files\OpenVPN\config\client.ovpn". And the keys and certificates are stored here as well.

Remember to run the GUI as ADMIN!!!
 
Old 03-04-2014, 07:38 AM   #17
nikmit
Member
 
Registered: May 2011
Location: Nottingham, UK
Distribution: Debian
Posts: 178

Rep: Reputation: 34
If you want the clients to be seen with the VPN server's IP when browsing the net, you have to use the redirect-gateway option, and configure NAT on the VPN server for the VPN clients - in a similar way to how you have configured your existing devices in the local protected LAN. It is as if you are attaching a new LAN subnet on a new interface.
 
Old 03-04-2014, 09:47 AM   #18
sisu_star
LQ Newbie
 
Registered: Feb 2014
Location: Helsinki, Finland
Distribution: Ubuntu
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by nikmit View Post
If you want the clients to be seen with the VPN server's IP when browsing the net, you have to use the redirect-gateway option, and configure NAT on the VPN server for the VPN clients - in a similar way to how you have configured your existing devices in the local protected LAN. It is as if you are attaching a new LAN subnet on a new interface.
I have zero experience on configuring NAT on the VPN server.

The NAT router (and DSL box) handles all of this. The VPN server is behind the NAT. The Router also works as th DHCP server, and distributes the IP:s to the LAN clients.

To get that to work, will I have to edit the 'interfaces' file? 'Redirect' traffic from tun0 to eth0? Everytime I've messed with the 'interfaces' file, I ended up with no internet connection on the server
 
Old 03-05-2014, 02:49 AM   #19
nikmit
Member
 
Registered: May 2011
Location: Nottingham, UK
Distribution: Debian
Posts: 178

Rep: Reputation: 34
The NAT router can't do anything with the VPN traffic, because it is encapsulated and encrypted in the tunnel.

You would need to add to the iptables config on the VPN router, because that is where the VPN tunnel terminates.
The below is in iptables-restore format:
Code:
*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s 10.8.0.0/24 -d 192.168.10.0/24 -j SNAT --to-source 192.168.10.53
COMMIT
And this is how you would directly add the rules to iptables - first command creates the chain, the second adds a rule to it:
Code:
iptables -t nat -N POSTROUTING
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -d 192.168.10.0/24 -j SNAT --to-source 192.168.10.53
This will look at traffic as it is about to leave the VPN server and if it has a source IP in the 10.8.0.0/24 subnet, will replace it with 192.168.10.53 and change the source port to something unique.

P.S.
If you are the admin of that server, you should look into iptables, and enable some iptables rules to provide a host based firewall for the VPN server.
 
Old 03-13-2014, 09:28 AM   #20
sisu_star
LQ Newbie
 
Registered: Feb 2014
Location: Helsinki, Finland
Distribution: Ubuntu
Posts: 14

Original Poster
Rep: Reputation: Disabled
Thanks again for your help!

There is still one weird problem. The Samba server has multiple shares, and on the client machine I've made all but one "available offline". When I connect to the share through OpenVPN, I can connect to the share that is not available offline. None of the shares made available offline works...
Is there some sort of connection limit somewhere that I'm missing? Either in OpenVPN or Samba. Since all the shares works when connected to within the servers LAN, I'm leaning towards a limitation somewhere else.
 
Old 03-13-2014, 09:41 AM   #21
nikmit
Member
 
Registered: May 2011
Location: Nottingham, UK
Distribution: Debian
Posts: 178

Rep: Reputation: 34
Making the share available offline means that the client will download a local copy of the shared drive. Over a VPN this could be causing excessive load and slow operation, depending on the size of the shares. I'm not sure, but would guess that this is either slow operation which is interpreted as lack of operation or the software is being clever and preventing slow operation by using the shares in offline mode. Check Samba logs?
 
Old 03-17-2014, 07:43 AM   #22
sisu_star
LQ Newbie
 
Registered: Feb 2014
Location: Helsinki, Finland
Distribution: Ubuntu
Posts: 14

Original Poster
Rep: Reputation: Disabled
The point would be to make the shares available offline when connected to the local LAN - Everything will be downloaded to the client. When using the shares when offline, the files would still be available. And when connecting through OpenVPN the bandwidth usage should be smaller, as only the changed files would have to be downloaded (as most are already available as the offline copies). But this might be an issue with the the way Windows checks for the connection speed, and not a problem in the OpenVPN/Samba settings.
 
Old 03-19-2014, 08:14 AM   #23
sisu_star
LQ Newbie
 
Registered: Feb 2014
Location: Helsinki, Finland
Distribution: Ubuntu
Posts: 14

Original Poster
Rep: Reputation: Disabled
The main culprit seems to be the VPN clients "Make available offline" option. When connected to the samba shares through OpenVPN, the client assumes the share that are made available offline are offline. The one share that is NOT made available offline works fine. The shares that are made available offline must be forced to update the folders (right click on the network drive -> Sync -> Sync selected offline files).

OpenVPN server.conf:
Code:
;local a.b.c.d
port 1194
;proto tcp
proto udp
;dev tap
;dev tun
dev tun0
;dev-node MyTap
ca ca.crt
cert [censored].crt
key [censored].key  # This file should be kept secret
dh dh2048.pem
;server 172.31.255.100 255.255.255.254
server 10.8.0.0 255.255.255.0
;server 192.168.10.0 255.255.255.0
;ifconfig-pool-persist ipp.txt
;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100
;server-bridge
push "route 192.168.10.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"
;client-config-dir ccd
;route 192.168.40.128 255.255.255.248
;client-config-dir ccd
;route 10.9.0.0 255.255.255.252
;learn-address ./script
;push "redirect-gateway"
;push "dhcp-option DNS 192.168.10.1"
;push "dhcp-option DNS 208.67.220.220"
client-to-client
;duplicate-cn
keepalive 10 120
tls-auth ta.key 0 # This file is secret
;cipher BF-CBC        # Blowfish (default)
;cipher AES-128-CBC   # AES
;cipher DES-EDE3-CBC  # Triple-DES
comp-lzo
;max-clients 100
;user nobody
;group nogroup
persist-key
persist-tun
status openvpn-status.log
;log         openvpn.log
log-append  openvpn.log
verb 6
;mute 20
OpenVPN client config (client.ovpn located in C:\Program Files\OpenVPN\config\):
Code:
client
dev tun0
proto udp
remote [ip.of.the.server] 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert [nameofclientcertificatefile].crt
key [nameofclientkeyfile].key
ns-cert-type server
tls-auth ta.key 1
comp-lzo
verb 4
Samba config file (smb.conf):
Code:
[global]
   workgroup = [WORKGROUP - Edit to suit needs - Leave out [ and ] symbols]
   netbios name = [SERVERNAME - Leave out [ and ] symbols]
   server string = [Server description - Leave out [ and ] symbols]
   dns proxy = no
   log file = /var/log/samba/log.%m.%I
   max log size = 1000
   syslog = 0
   panic action = /usr/share/samba/panic-action %d
   security = user
   encrypt passwords = true
   passdb backend = tdbsam
   obey pam restrictions = yes
   unix password sync = yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
   pam password change = yes
   map to guest = bad user
   usershare allow guests = yes
[homes]
   comment = Home Directories
   browseable = yes
   hide dot files = yes
   hide unreadable = yes
   read only = no
   create mask = 0700
   directory mask = 0700
   valid users = %S
[printers]
   comment = All Printers
   browseable = no
   path = /var/spool/samba
   printable = yes
   guest ok = no
   read only = yes
   create mask = 0700
[print$]
   comment = Printer Drivers
   path = /var/lib/samba/printers
   browseable = yes
   read only = yes
   guest ok = no
[CustomShare]
   comment = CustomShare
   path = /srv/samba/CustomShare
   browseable = no
   guest ok = no
   read only = no
   create mask = 0770
   directory mask = 0770
   directory security mask = 0770
   force create mode = 0770
   force directory mode = 0770
   force group = smb_CustomShare
   hide dot files = yes
   hide unreadable = yes
   valid users = @smb_CustomShare
   write list = @smb_CustomShare
These settings seem to work on my setup. Pinging "192.168.10.53" (in my case this is the VPN/Samba servers ip on the LAN) finds the server.

Normal webtraffic does not go through the VPN.
 
Old 08-16-2018, 05:50 PM   #24
JamesAM
LQ Newbie
 
Registered: May 2018
Posts: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by sisu_star View Post
Using:
server 10.8.0.0 255.255.255.0
push "route 192.168.10.0 255.255.255.0"
push "redirect-gateway"
push "dhcp-option DNS 19.168.10.1"
It seems like a little explanation is due here.
server defines the network that the client computers will be in
push "route ..." gives you a route into the remote (office) LAN.
push "redirect-gateway" routes ALL traffic through the VPN that is not on the client's local LAN - I don't think you want that.
push "dhcp-option dns ..." tells the client computer to ONLY use the remote (office) dns server. If the office dns server does not forward unknown requests to an outside (internet) dns server, then you will ONLY have access to the remote LAN addresses. If you do not need access to remote LAN name services you should drop that line.

To summarize, judging by the previous conversation, of the 4 lines you posted, you only need the first two.

*EDIT* I also just noticed that you had typed 19.168 instead of 192.168 in the dns line above.

Last edited by JamesAM; 08-16-2018 at 07:11 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can openvpn client connect to multiple servers? Skaperen Linux - Networking 5 09-27-2013 12:21 PM
Configuring Client to choose among 2 DHCP Servers Muhammad Hamid Ashraf Linux - Networking 1 04-08-2013 06:28 AM
openVPN multiple servers, can access all client all of my server bulkiter0z Linux - Networking 1 02-25-2011 09:58 AM
OpenVPN-client connects,cant see servers subnet andbn Linux - Networking 0 10-29-2007 12:24 PM
openvpn client couldn't reach other servers behind vpn server jeffhan Linux - Networking 2 08-27-2006 11:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration