librespeed / speedtest

Self-hosted Speed Test for HTML5 and more. Easy setup, examples, configurable, mobile friendly. Supports PHP, Node, Multiple servers, and more
https://librespeed.org
GNU Lesser General Public License v3.0
12.18k stars 2.2k forks source link

Get private IP Address instead of Public IP Address #480

Open samotelf opened 2 years ago

samotelf commented 2 years ago

Hello and thank you for this awesome software. I was wondering if it is possible when doing a speedtest to get the private ip address of the device when not connected to the company vpn? I implemented librespeed in my company and it works very well, however I've noticed that when doing a test with vpn I get the private ip address but when not on vpn I get the public ip address.
Is this the default behaviour? Is there a way to get the private ip address when not connected by vpn? And if so, where can I change that?

Thank you very much.

Best regards.

Computroniks commented 2 years ago

The way IPv4 networks would make this impossible. When not connecting via the VPN, the client will be using NAT in order to transform the private IP range into a single public address. This makes it impossible to get the private IP of the client. The reason you can get the private IP when using the VPN is because the client is not going through NAT and is instead connecting directly to your internal network. You can find out more about NAT on Wikipedia or by googling it. Here is a link to a Wikipedia article on NAT: https://en.wikipedia.org/wiki/Network_address_translation

samotelf commented 2 years ago

Hello @Computroniks. Thank you for the explanation. I think I understand what you mean, but actually what I was wondering is if when the endpoint doing the test via librespeed-cli it could also get the private and public ip address and write them both in the librespeed database.

All my target endpoints have a randomized scheduled task to run librespeed-cli and it would be nice to have the private and public ip address also.

Actually forget the VPN example, it was actually a bad example.

But yeah, essentially I would like to know if that's possible to implement?

Computroniks commented 2 years ago

To do something like that, the cli would have to look at the interface on the machine to get the local IP address. This could be problematic on machines with multiple interfaces. This could then be sent to the server theoretical. I don't think that this feature is currently implemented.

maddie commented 2 years ago

To do something like that, the cli would have to look at the interface on the machine to get the local IP address. This could be problematic on machines with multiple interfaces. This could then be sent to the server theoretical. I don't think that this feature is currently implemented.

CLI author here. Can confirm no such feature was implemented, the IP fetching logic is the same as web version.

samotelf commented 2 years ago

Thank you @maddie do you think it is possible in the future to do something like that? Is it worth it to make a feature request?

maddie commented 2 years ago

To be honest, I don't see much of a use case with this feature in most scenarios, so it probably won't get implemented.