Hello Everyone,
Configuration:
---------------------------------------------------------------------------------------------------------------------------------------------
Location 1 = Router 1:
1. Router 192.168.1.1 255.255.255.0, this router provide access to the internet, and have public and static WAN IP
2. Raspberry PI as VPN server LAN address 192.168.1.201 255.255.255.0
3. Friend's computer 192.168.1.4 255.255.255.0
4. Friend's computer 192.168.1.5 255.255.255.0
Location 2 = Router 2:
1. Router 192.168.2.1 255.255.255.0, this router provide access to the internet, and has private and dynamic WAN IP
2. Raspberry PI as VPN clinet LAN address ethernet card 1 -> 192.168.2.45 255.255.255.0
address ethernet card 2 -> 192.168.4.1 255.255.255.0
to Card2 i have connected three PLCs (Programable Logic Controller):
PLC 1 - 192.168.4.2 255.255.255.0
PLC 2 - 192.168.4.3 255.255.255.0
PLC 3 - 192.168.4.4 255.255.255.0
Location 3 = Router 3:
1. Router 192.168.3.1 255.255.255.0, this router provide access to the internet, and has private and dynamic WAN IP
2. Computer as VPN client LAN address 192.168.3.23 255.255.255.0
Image on google drive (right click and copy link)
Similar situation:
https://superuser.com/questions/956684/openvpn-client-with-two-interfaces
---------------------------------------------------------------------------------------------------------------------------------------------
Server Configuration:
dev tun
proto udp
port 1194
ca /etc/openvpn/easy-rsa/pki/ca.crt
cert /etc/openvpn/easy-rsa/pki/issued/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.crt
key /etc/openvpn/easy-rsa/pki/private/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.key
dh none
ecdh-curve prime256v1
topology subnet
server 10.8.0.0 255.255.255.0
# Set your primary domain name server address for clients
push "dhcp-option DNS 9.9.9.9"
push "dhcp-option DNS 149.112.112.112"
# Prevent DNS leaks on Windows
push "block-outside-dns"
# Override the Client default gateway by using 0.0.0.0/1 and
# 128.0.0.0/1 rather than 0.0.0.0/0. This has the benefit of
# overriding but not wiping out the original default gateway.
push "redirect-gateway def1"
client-to-client
client-config-dir /etc/openvpn/ccd
keepalive 15 120
remote-cert-tls client
tls-version-min 1.2
tls-crypt /etc/openvpn/easy-rsa/pki/ta.key
cipher AES-256-CBC
auth SHA256
user openvpn
group openvpn
persist-key
persist-tun
crl-verify /etc/openvpn/crl.pem
status /var/log/openvpn-status.log 20
status-version 3
syslog
verb 3
#DuplicateCNs allow access control on a less-granular, per user basis.
#Remove # if you will manage access by user instead of device.
#duplicate-cn
# Generated for use by PiVPN.io
route 192.168.2.0 255.255.255.0
push "route 192.168.2.0 255.255.255.0"
Client 1 configuration in /etc/openvpn/ccd server's folder
ifconfig-push 10.8.0.2 255.255.255.0
iroute 192.168.2.0 255.255.255.0
Client 2 configuration in /etc/openvpn/ccd server's folder
ifconfig-push 10.8.0.3 255.255.255.0
Client 1 - RaspberryPI in Location 2
client
dev tun
proto udp
remote X.X.X.X XXXX
resolv-retry infinite
nobind
remote-cert-tls server
tls-version-min 1.2
verify-x509-name xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx name
cipher AES-256-CBC
auth SHA256
auth-nocache
verb 3
<ca>
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
</ca>
<cert>
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
</cert>
<key>
-----BEGIN ENCRYPTED PRIVATE KEY-----
-----END ENCRYPTED PRIVATE KEY-----
</key>
<tls-crypt>
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
-----END OpenVPN Static key V1-----
</tls-crypt>
Client 2 - Computer in Location 3
client
dev tun
proto udp
remote X.X.X.X XXXX
resolv-retry infinite
nobind
remote-cert-tls server
tls-version-min 1.2
verify-x509-name raspberrypi_f2fec350-8142-46c1-a734-3e4245c49c7c name
cipher AES-256-CBC
auth SHA256
auth-nocache
verb 3
<ca>
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
</ca>
<cert>
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
</cert>
<key>
-----BEGIN ENCRYPTED PRIVATE KEY-----
-----END ENCRYPTED PRIVATE KEY-----
</key>
<tls-crypt>
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
-----END OpenVPN Static key V1-----
</tls-crypt>
And now what i want to do with this, 🙂
1. I want to by able to connect computer (OpenVPN Client) from Location 3 to these three PLCs in Location 2 via RaspberryPI (OpenVPN Client). Is it possible at all ? Can someone help me with configuration of OpenVPN server and clients ?
I've already add in server config these lines:
route 192.168.4.0 255.255.255.0
push "route 192.168.4.0 255.255.255.0"
And in client config (file on server):
ifconfig-push 10.8.0.2 255.255.255.0
iroute 192.168.4.0 255.255.255.0
After that i reset OpenVPN process.
sudo systemctl restart openvpn
I think i should change somethins in routers, but i don't know what, and with what values.
2. Do i really need second ethernet card (for example USB-Ethernet adapter) in Raspberry PI ?