There are 2 types of IP addresses associated with a computer connected to an internet – Private and Public IP
What is the difference between public and private IP address?
Private IP – Private IP address is the address used for identification of a device within a network.
Public IP – Public IP address is the address that is assigned to a computer by your Internet Service Provider(ISP) to allow direct access to the Internet.
The devices residing outside of your local network cannot directly communicate via the private IP address but uses your router’s public IP address to communicate.
How to know Public IP in the Angular project?
Client Public IP can be accessed by making an API call to 3rd party services like ipify.org or ipinfo.io. Since this API will be issued from the client browser, you don’t have to worry about security failure as this call will not be flow through any of your server resources.
How to know Private IP in the Angular project?
WebRTC Details – https://webrtc.org/
Refer my GitHub project to access the source code for this article. Below screenshot shows final output –
Github location – https://github.com/programmingwithnaveen/get-IP
Demo video – https://www.youtube.com/watch?v=MOW8LmO_TqY