Hello, I have very basic linux knowledge and I'd really like if someone can help me out here.
I currently have my raspberry Pi configured as a
vpn gateway (working perfectly). Openvpn is setup to act as a client (tun0) and it connects to a vpn service provider, that way my devices in my house are connected through the vpn tunnel.
I'm trying to have
another instance of openvpn running as a server in the same raspberry pi in order to be able to access my home network whenever I'm outside but I have not been able to do it.
Independently I've been able to set up the raspberry as an openvpn client to my vpn service provider and also as a personal openvpn server successfully, allowing me to connect to my home but I haven't been able to have both instances
running at the same time. Ports are forwarded correctly in the main router as I'm able to use the my personal oepnvpn server when I set it up alone (independently of the client conf)
Currently my home network is like
(rpi acting only as a openvpn client):
Ex.
Notebook 192.168.3.130
Gateway 192.168.3.100 --> everything goes through the VPN tunnel (vpn service provider)
Dns 192.168.3.100
iPad 192.168.3.125
Gateway 192.168.3.1 --> everything goes through my ISP (public IP exposed)
Dns 8.8.8.8
*** Now
at the same time I want to have another instance of openvpn running where it would allow me to browse my local lan remotely.***
I currently have the openvpn daemon autorun every time the rpi boots by using
systemctl enable openvpn@torguard
Here are my conf files:
torguard.conf (client conf file for private vpn provider)
client
dev tun
proto udp
remote la.serveraddress.com 443
resolv-retry infinite
remote-cert-tls server
nobind
tun-mtu 1500
tun-mtu-extra 32
mssfix 1450
ca /etc/openvpn/ca.crt
auth-user-pass /etc/openvpn/login.txt
comp-lzo
fast-io
ping-restart 0
route-delay 2
route-method exe
script-security 3 system
mute-replay-warnings
verb 3
and my
server.conf file (which is my personal openvpn server configuration file)
local 192.168.3.100 # Raspberry IP address
dev tun1
proto tcp #Using TCP
port 443
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/Home.crt # My CRT file
key /etc/openvpn/easy-rsa/keys/Home.key # My Key
dh /etc/openvpn/easy-rsa/keys/dh2048.pem
server 10.8.0.0 255.255.255.0
ifconfig 10.8.0.1 10.8.0.2 # server and remote endpoints
# Route to Client routing table for the OpenVPN Server
push "route 10.8.0.1 255.255.255.255"
# Route to Client routing table for the OpenVPN Subnet
push "route 10.8.0.0 255.255.255.0"
# My local subnet
push "route 192.168.3.0 255.255.255.0" # Raspberry PI network range address
push "dhcp-option DNS 192.168.3.1"
push "redirect-gateway def1"
client-to-client
duplicate-cn
keepalive 10 120
tls-auth /etc/openvpn/easy-rsa/keys/ta.key 0
cipher AES-128-CBC
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status /var/log/openvpn-status.log 20
log /var/log/openvpn.log
verb 1
My
Nat and Routing setup is as follows (rules are persistent through boot) when running openvpn as client in the rpi:
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
iptables -A FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0 -o tun0 -j ACCEPT
And the one specified below when setting up de raspberrypi as a personal vpn server.
Also already have net.ipv4.ip_forward=1 enabled in /etc/sysctl.conf
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j SNAT --to-source 192.168.3.100
Any guidance on how I can accomplish this would be greatly appreciated.
Thanks