OpenVPN: Connect your LANs over the Internet

Routed static setup

by ross at 11:52:17 on June 2, 2017

Let's assume that we need to connect server's LAN (192.168.10.0/24) and client's LAN (192.168.20.0/24).

Server

/usr/local/etc/openvpn/openvpn_officelan.conf:

port 1194
dev tun0 # use unique tunN for every config
ifconfig 172.16.0.1 172.16.0.2 # our-ip, remote-ip
up openvpn_officelan.up.sh
secret openvpn_officelan.key
cipher AES-256-CBC
script-security 2 # needed to execute .sh scripts

/usr/local/etc/openvpn/openvpn_officelan.up.sh:

#!/bin/sh

/sbin/route add -net 192.168.20.0/24 -interface $1
# chmod a+x *.sh

Client

/usr/local/etc/openvpn/openvpn_officelan.conf:

remote vpn.example.com 1194 # replace with your server address
dev tun0 # use unique tunN for every config
ifconfig 172.16.0.2 172.16.0.1 # our-ip, remote-ip
up openvpn_officelan.up.sh
secret openvpn_officelan.key
cipher AES-256-CBC
script-security 2 # needed to execute .sh scripts

/usr/local/etc/openvpn/openvpn_officelan.up.sh:

#!/bin/sh

/sbin/route add -net 192.168.10.0/24 -interface $1
# chmod a+x *.sh

Run

Create rc.d script and run the daemon as described on the last page.

Comments