Public and private IP addresses

All computers need at least 3 pieces of information to connect to a network.

An IP address, a subnet mask and a default gateway.

The difference between a private and a public IP address depends on the network you are connecting to.

Private IPs

If the network is local, such as your home or office network, then your computer will be issued with a private IP address.

This IP address is typically IPv4 (4 octets in the format XXX.XXX.XXX.XXX where X is a number) and falls under 1 of 3 network classes...

ClassPrivate IP Address RangeSubnet Mask
A1.0.0.0 - 10.255.255.255255.0.0.0
B172.16.0.0 - 172.16.31.255255.255.0.0
C192.168.0.0 - 192.168.255.255255.255.255.0

Class A is typically used for larger organisations since you can have more hosts per network, whereas Class C is typically used for home networks since you can have more networks at the sacrifice of fewer hosts per network.

There are some other classes (D and E) which are reserved for multicasting (sending traffic to multiple users at the same time) and experimental usage.

There's also a special IP address reserved for local machine testing called a loopback or localhost address, which is 127.0.0.1.

Public IPs

Public IP addresses are different to private IP addresses as they are only needed for connecting to the Internet.

This is so that other computers on the Internet can communicate with it.

ISPs usually reserve blocks of IP addresses from which they will assign one.

This will likely be a dynamic IP address, which means it will change over time and this will be assigned to your router, rather than your computer.

The reason for this is to save on addresses, as they are in limited supply.

References

networkel.com/ip-address-classes

geeksforgeeks.org/introduction-of-classful-..

sciencedirect.com/topics/computer-science/l..