How to only allow samba through the vpn tunnel?

How to customize and extend your OpenVPN installation.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
them8
OpenVpn Newbie
Posts: 4
Joined: Sat Mar 02, 2019 12:34 pm

How to only allow samba through the vpn tunnel?

Post by them8 » Sat Mar 02, 2019 1:24 pm

I have managed to setup openvpn with ufw, all seems to work, but I want clients to still browse the internet via their local gateway while connected to the vpn. I only want samba traffic to go through the vpn. How can I do this? Is it even possible please help :(

I there something I can add to the client.conf which allow for this happen?

them8
OpenVpn Newbie
Posts: 4
Joined: Sat Mar 02, 2019 12:34 pm

Re: How to only allow samba through the vpn tunnel?

Post by them8 » Sat Mar 02, 2019 1:33 pm

My configs

*** server.conf ***

Code: Select all

port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key  # This file should be kept secret
dh dh2048.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
keepalive 10 120
tls-auth ta.key 0 # This file is secret
cipher AES-256-CBC
comp-lzo
max-clients 100
user nobody
group nobody
persist-key
persist-tun
status openvpn-status.log
log         /var/log/openvpn.log
log-append  /var/log/openvpn.log
verb 3
explicit-exit-notify 1

*** client.conf ***

Code: Select all

client
dev tun
proto udp
remote vpn.server 1194
resolv-retry infinite
nobind
user nobody
group nobody
persist-key
persist-tun
remote-cert-tls server
tls-auth ta.key 1
cipher AES-256-CBC
comp-lzo
verb 3

them8
OpenVpn Newbie
Posts: 4
Joined: Sat Mar 02, 2019 12:34 pm

Re: How to only allow samba through the vpn tunnel?

Post by them8 » Sat Mar 02, 2019 3:17 pm

Code: Select all

route www.google.com 255.255.255.255 net_gateway
Above works for a specific website, but I want all client traffic to go though their LAN gateway & only file server (samba) traffic to go through the VPN. Does anyone know how I can modify the line above for a port number at least?

them8
OpenVpn Newbie
Posts: 4
Joined: Sat Mar 02, 2019 12:34 pm

Re: How to only allow samba through the vpn tunnel?

Post by them8 » Sat Mar 02, 2019 4:08 pm

Code: Select all

push "redirect-gateway def1 bypass-dhcp"
Commenting the line above from server.conf did the trick. I hope this will others like me.

Post Reply