I've been able to set up an OpenVPN server with several clients using static ips, the static ip is set by adding a line like ifconfig-push 192.168.254.6 192.168.255.1
in the ccd for each of the clients. I can ping or ssh from the server to each of these clients.
In my server configuration I have the following lines (among other config):
server 192.168.255.0 255.255.255.0
and
route 192.168.254.0 255.255.255.0
Now what I'm trying to do, is to be able to ssh or curl from one client to another, so after reading the documentation I added the line client-to-client
to the configuration.
I've noticed that when restarting the servers and reconnecting the clients, it added the following line to ip route
to my clients:
192.168.255.0/24 via 192.168.255.1 dev tun0
Which I seem to understand it is indicating the client, that every address like 192.168.255.X
would go to the VPN server. And in fact, I tried to verify by running traceroute 192.168.255.30
and getting:
traceroute to 192.168.255.30 (192.168.255.30), 30 hops max, 60 byte packets
1 192.168.255.1 (192.168.255.1) 11.454 ms 14.491 ms 14.493 ms
However, the other clients I want to connect to have addresses like 192.168.254.X
so I guess I'm missing something and I don't actually know what. I've tried manually adding this route:
ip route add 192.168.254.0/24 via 192.168.255.1 dev tun0
Which to me would mean like, also addresses like 192.168.254.X are going through the VPN server. But if I then do traceroute 192.168.254.30
the results are different:
traceroute 192.168.254.30
traceroute to 192.168.254.30 (192.168.254.30), 30 hops max, 60 byte packets
Also from the client machine I can ping 192.168.255.1
but I cannot ping other clients in the 254 range like ping 192.168.254.30
.
My networking knowledge is quite limited, What is missing to be able to let a client like 192.168.254.30
access services on another client like 192.168.254.32
Update: I've connected a new client to the vpn, this time assigning in the ccd file an ip in the 192.168.255.X range, and then I tried to run traceroute from the client I was testing with. I cannot connect to this client in the 255 range either, moreover, if I run traceroute the following happens.
This new client has 192.168.255.22
, if in my testing client I do traceroute 192.168.255.3
I get:
traceroute to 192.168.255.3 (192.168.255.3), 30 hops max, 60 byte packets
1 192.168.255.1 (192.168.255.1) 11.481 ms 21.192 ms 21.472 ms
The same happens for ips 4, 5, 6... that have no clients, until I get to 22
which is the ip of the new client, in that case when I do traceroute 192.168.255.22
I get:
traceroute to 192.168.255.22 (192.168.255.22), 30 hops max, 60 byte packets
Why is this happening?