Hi all,
I just started using OpenVPN and am a bit baffled. Pleas be kind 😉
Some friends an me sometimes meet up for LAN Parties, but naturally there are always one or to who can't make it but want to join via a remote connection. We tried some commercial solutions (Tunngle, hamachi) but are somewhat repelled.
After diving into the topic we found several possible solutions for our problem (Masquerading, Forwarding, changing topology) and settled for bridging the VPN and the LAN, using TAP.
Our LAN consists of several Computers with IP from 192.168.2.0/24. The LAN is behind a router 192.168.2.1, which is also the Internet Gateway and DHCP Server. Unfortunately it is a cheap piece so no changes possible here besides port forwarding. The OpenVPN Server is behind the router. Now we want to connect a remote Computer, such that the remote computer is accessible in the same address space than all the other LAN Computers. I've drawn a picture which hopefully clarifies what we want to achieve (btw please excuse my poor English)
All computers run Win7/8/10, the VPN-Server runs Linux though.
What we tried so far is set up a simple VPN server (Tunneling) and connect to it remotely, which worked like charm. But the VPN connection had an other address space than the LAN Computers.
After further reading we decided for using a (server-)bridge and TAP. So we setup the bridge with bridge-utils, configured the gateway for the bridge (route add) and than started the VPN Server. Now the remote computer couldn't join at all.
I think we are missing something, but then again most of our efforts are copy and paste from different tutorials...
I attached the configs and logs. Thanks for reading! Also if there is a better approach, we are keen to learn something new!
start-script
#!/bin/bash
# iptables for propagating packages through all networks
iptables -A INPUT -i tap0 -j ACCEPT
iptables -A INPUT -i br0 -j ACCEPT
iptables -A FORWARD -i br0 -j ACCEPT
# define iface names
br="br0"
tap="tap0"
# define network to be bridged
eth="eth0"
eth_ip="192.168.2.108"
eth_netmask="255.255.255.0"
eth_broadcast="192.168.2.255"
for t in $tap; do
openvpn --mktun --dev $t
done
# create bridge between eth0 and tap0
brctl addbr $br
brctl addif $br $eth
for t in $tap; do
brctl addif $br $t
done
# make interfaces promiscure to send packages to kernel (but mainly because a tutorial told us to)
for t in $tap; do
ifconfig $t 0.0.0.0 promisc up
done
ifconfig $eth 0.0.0.0 promisc up
# configure bridge with correct address space and add route for gateway
ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast
route add default gw 192.168.2.1 $br
# basicly the same as service openvpn start (I removed it from init.d/upated rc to prevent autostart on boot)
./openvpn-init start
server.conf
local 192.168.2.112
port 1194
proto udp
dev tap0
ca ./easy-rsa2/keys/ca.crt
cert ./easy-rsa2/keys/server.crt
key ./easy-rsa2/keys/server.key # This file should be kept secret
dh ./easy-rsa2/keys/dh1024.pem
ifconfig-pool-persist ipp.txt
# as far as we understood, we tell the VPN server where to listen, and which subnet to use for
# ip for clients
server-bridge 192.168.2.112 255.255.255.0 192.168.2.200 192.168.2.210
# we want everyone to have access to all resources be it LAN or VPN resource
client-to-client
# using it just for debugging
duplicate-cn
keepalive 10 120
comp-lzo
user openvpn
group openvpn
persist-key
persist-tun
status openvpn-status.log
log openvpn.log
verb 4
client.ovpn
client
dev tap
# name of TAP adapter is changed accordingly
dev-node EmsterTAP
proto udp
resolv-retry infinite
nobind
user openvpn
group openvpn
persist-key
persist-tun
ca "keys\\ca.crt"
cert "keys\\kuebelwagen.crt"
key "keys\\kuebelwagen.key"
ns-cert-type server
comp-lzo
verb 4