41. Internet Protocol (IPv4 and IPv6)

IP is used to give devices logical addresses (addresses used by the network to identify devices) so they can communicate across networks. The two main versions are IPv4 (older IP version) and IPv6 (newer IP version).

IPv4
IPv4 uses a 32-bit address (an address made of 32 binary digits). It is written as four octets (four number sections) separated by dots, such as 192.168.0.1.

Each octet ranges from 0 to 255. An IPv4 address is divided into a network portion (the part that identifies the network) and a host portion (the part that identifies the specific device on that network).

Networks are often split into subnets (smaller parts of a network), and a subnet mask (a value that shows which part of the IP address is network and which part is host) is used to show which part of the address identifies the subnet. A common example is 255.255.255.0.

IPv4

Because IPv4 has a limited number of addresses, private addressing (addresses used only inside local/internal networks) is used inside internal networks.

IPv4 Range

These private addresses are used inside local networks and are not meant to be routed (sent across other networks, especially the internet) directly on the internet.

The 127.x.x.x range is reserved for loopback (the device talking to itself). The most common loopback address is 127.0.0.1, which refers to the local machine.

People mostly say that "There is no place like 127.0.0.1", it points to yourself or in simple words it mean home.

IPv6
IPv6 was created to solve IPv4 address shortage and improve networking features. It uses a 128-bit address (a much longer address made of 128 binary digits), which provides a much larger address space (the total number of possible addresses).

IPv6 addresses are written as eight groups of four hexadecimal digits (numbers using 0–9 and letters a–f) separated by colons. Example:
2001:0db8:0000:0000:0000:ffff:0000:0001

IPv6 addresses can be shortened by:

So the example above can become:
2001:db8::ffff:0:1

IPv6 improvements

Special IPv6 addresses

Main Idea
IPv4 and IPv6 are the two main IP versions. IPv4 uses 32-bit addresses and has limited space, while IPv6 uses 128-bit addresses and provides a much larger, more modern addressing system.


discord :