my first post here and maybe someone can give me a little advise. I have a little knowledge and have installed a few openvpn-servers. There was always the requirement to access resources on the server side from the client. That worked just fine.
Now the requirement is to reach a subnet behind a client from another client of the vpn-network.
I have a running configuration which is as follows:
Configuration of the server:
/etc/openvpn/server.conf
Code: Select all
port 1194
proto udp
dev tun0
mode server
tls-server
topology subnet
server 10.0.0.0 255.255.255.0
client-to-client
client-config-dir /etc/openvpn/client-config
keepalive 10 120
comp-lzo
up /etc/openvpn/up-cmd
down /etc/openvpn/down-cmd
learn-address /etc/openvpn/learn-address-cmd
client-connect /etc/openvpn/client-connect-cmd
client-disconnect /etc/openvpn/client-disconnect-cmd
dh /etc/openvpn/rsa/keys/dh1024.pem
ca /etc/openvpn/rsa/keys/ca.crt
cert /etc/openvpn/rsa/keys/ovpn-server.crt
key /etc/openvpn/rsa/keys/ovpn-server.key
crl-verify /etc/openvpn/rsa/keys/crl.pem
cipher AES-256-CBC
script-security 2
log /var/log/ovpn-mpaconcentrator.log
verb 6
/etc/openvpn/client-config/linux-client
Code: Select all
iroute 172.16.0.0 255.255.255.0
Code: Select all
push "route 172.16.0.0 255.255.255.0"
Code: Select all
client
remote x.x.x.x
dev tun
port 1194
tls-client
keepalive 10 120
nobind
pull
comp-lzo
verb 6
cipher aes-256-cbc
<ca>
# ca-cert
</ca>
<cert>
# certificate
</cert>
<key>
# private key
</key>
Code: Select all
client
remote x.x.x.x
dev tun
port 1194
tls-client
keepalive 10 120
nobind
pull
comp-lzo
verb 6
cipher aes-256-cbc
ca /etc/openvpn/ca.crt
cert /etc/openvpn/linux-client.crt
key /etc/openvpn/linux-client.key
A little drawing to give you an overview:
Code: Select all
*windows-client* <---------> *ovpn-server* <--------> *linux-client* <-------> *network-devices* 172.16.0.0 /24
VPN-IP: 10.0.0.3 VPN-IP: 10.0.0.1 VPN-IP: 10.0.0.2
Routing-table: (ip-forwarding enabled)
172.16.0.0 /24 via 10.0.0.1
I am able to ping a client in the 172.16.0.0 /24 subnet from the windows-client. So internal routing of openvpn seems to work.
My first problem is the following:
Because I only want to allow communications over certain ports between the openvpn-clients I need to be able to filter all traffic between the windows-client and the linux-client with iptables.
But at the moment all traffic goes directly from the linux-client to the windows-client because i used the "client-to-client" directive in the server configuration file.
Is it possible to do the routing "outside" of the openvpn process on the ovpn-server?
That would allow me to do things like policy based routing and so on. For example i could route all traffic from a specific source to a specific vpn-client (no more need for the "iroute" stuff!)
Second problem is: In the future there will be more linux-clients with the same subnets attached to them (more details in the ascii drawing). This is because the "network-devices" behind the linux-client are preconfigured industrial machines. They almost always use the same ip-address ranges and i am not allowed to change these.
My thought was as follows:
Create a routing-table entry on a windows-client like this:
/etc/openvpn/client-config/windows-client
Code: Select all
push "route 172.16.0.0 255.255.255.0 10.0.0.2"
Code: Select all
push "route 172.16.0.0 255.255.255.0 10.0.0.6"
Code: Select all
*windows-client* ------------------ -------------*linux-client* <-------> *network-devices* 172.16.0.0 /24
VPN-IP: 10.0.0.3 | | VPN-IP: 10.0.0.2
Routing-table: | | (ip-forwarding enabled)
172.16.0.0 /24 via 10.0.0.2 | |
| |
| |
*ovpn-server VPN-IP: 10.0.0.1 *
| |
| |
| |
*another-windows-client* ----------- ------------*another-linux-client* <-------> *network-devices* 172.16.0.0 /24
VPN-IP: 10.0.0.3 VPN-IP: 10.0.0.6
Routing-table: (ip-forwarding enabled)
172.16.0.0 /24 via 10.0.0.6
I was not able to send any packet to a subnet behind a openvpn-client with this way.
What am I doing wrong?
Is there an alternative method for my goal?
Do you need any more information?