You cant detect connection type based on IP address because your mobile network and home WiFi network, both can assign private IP address.
What you need to do is to first detect either you have mobile network or WiFi connection, and then based on that info get the IP address of that connection.