I've managed to get this resolved with the help of Ethernet Bridging.
These would be the steps:
- Stop the OpenVPN Server, on CentOS:
systemctl stop openvpn@server, - Install bridge-utils package on CentOS 7
yum install bridge-utils, - Create tap0 Virtual ethernet device
openvpn --mktun --dev tap0, - Create a bridge
brctl addbr br0, - Add eth0 device (the one with private IP) to new bridge
brctl addif br0 eth0, - Add tap0 device to bridge
brctl addif br0 tap0 - Enable promiscuous mode to tap0 device
ifconfig tap0 0.0.0.0 promisc up - Enable promiscuous mode to eth0 device
ifconfig eth0 0.0.0.0 promisc up - Assign an IP address that was set to eth0 previously to br0
ifconfig br0 10.0.4.23 netmask 255.255.0.0 broadcast 10.0.255.255 - Add iptables rules so new interfaces can accept traffic
iptables -A INPUT -i tap0 -j ACCEPT
iptables -A INPUT -i br0 -j ACCEPT
iptables -A FORWARD -i br0 -j ACCEPT
- Open up VPN Server config file, for example
/etc/openvpn/server/server.conf, comment out thedev tunand add thedev tap0right bellow or above it. - Comment out the entire line that begins with the
serverand add IP address that was originally on eth0 and now on br0, also add the DHCP range of the addresses that the VPN will assign to clients, like this:
bridge 10.0.4.23 255.255.0.0 10.0.13.2 10.0.13.254
This will allow server to lease addresses from 10.0.13.2 - 10.0.13.256254 to clients.
- Now start the openvpn server and enjoy :)
systemctl start openvpn@servers.