I tried to make a setup with a tap device, but I got some connectivity problems. Before openvpn started up, every system could only reach those in its own network segment. After openvpn startup, the only thing that's changed is that VM4 can now reach 192.168.178.128 (the dynamically allocated new ip for the client).
My test-setup looks like this:
-------------------------- -----------------
| VM 2 | | VM 3 |
|OVPN-Server | Internal Network 1 |IP: (eth2) |
|eth1: 192.168.178.20 |--------------------------|192.168.178.30 |
|eth2: 192.168.56.20 | 192.168.178.0/24 | |
|tap0: (ethernet) | | |
|br0: ...178.20 (on eth1)| | |
-------------------------- -----------------
| |
| | Host-Only Network: 192.168.56.0/24
| |
-------------------------- -----------------
| VM 1 | | VM 4 |
|OVPN-Client | Internal Network 3 |IP: (eth3) |
|eth2: 192.168.178.10 |--------------------------|192.168.178.40 |
|eth3: 192.168.56.10 | 192.168.178.0/24 | |
|tap0: 192.168.178.128 | | |
-------------------------- -----------------
To start it all up, I ran
this script with the settings for the OVPN server (eth=eth1 and so on). Then, I started openvpn with this server.conf:
local 192.168.56.20
port 1194
proto udp
dev tap
server-bridge 192.168.178.20 255.255.255.0 192.168.178.128 192.168.178.254
dh /etc/openvpn/keys/dh1024.pem
ca /etc/openvpn/keys/ca.crt
key /etc/openvpn/keys/server01.key
cert /etc/openvpn/keys/server01.crt
ifconfig-pool-persist ipp.txt # file initially empty
keepalive 10 60
comp-lzo
Fairly straightforward. The client (VM1) looks like this:
port 1194
proto udp
dev tap
client
remote 192.168.56.20
ca /root/easyrsa/toclient/ca.crt
key /root/easyrsa/toclient/vpnclient01.key
cert /root/easyrsa/toclient/vpnclient01.crt
comp-lzo
Do I have to set up something to forward layer 2* traffic on VM1 and VM2 ? It looks alot like a bug in the routing, but this is layer 2...
nathaniel
*) /proc/sys/net/ipv4/ip_forward is set to 1.