Internet Protocol
lastmod 2026-02-04created 2014-03-2852 edits
(Both IPv4 and IPv6 redirect to this page.)
(For the Linux command, see ip_command (or ip (linux command), iproute2).)
The Internet Protocol (IP; North Korean standard term: hosangmang gyuyak) is an information-oriented convention (protocol) that a sending host and a receiving host use to exchange information over a packet-switched network (Packet Switching Network). At the OSI network layer, it handles host addressing and the splitting and reassembly of packets. It is also called IP for short.
Information in IP is split into chunks called packets or datagrams and transmitted. In IP, no route setup is needed to send packets to a host you have never communicated with before.
IP is characterized by unreliability and connectionlessness. Unreliability means that because IP does not take part in flow control, it does not guarantee that the information sent arrived correctly. For example, packets may be damaged during transmission, packets sent from the same host may arrive out of order, the same packet may be sent twice, or a packet may disappear entirely. To guarantee packet delivery and correct ordering, you must use a protocol above IP, such as TCP.
The standard protocol currently used on the Internet is IPv4, the fourth version of the Internet Protocol. However, IPv4 is suffering from address space exhaustion, so IPv6, the sixth version, is expected to become widespread soon. Most widely used operating systems today, such as Microsoft Windows XP, Mac OS X, and Linux, support the IPv6 protocol.
Categories
Routing schemes
Checking your global IP
You can check your global IP with the curl ifconfig.me command.
IP Address
This can occasionally be confusing, but an IP number is assigned not to hosts but to interfaces (also called LAN cards or Ethernet cards). Every LAN card has its own unique number (Ethernet Address), and an IP number is assigned to each Ethernet interface by mapping the IP number to this Ethernet number.
Special-use addresses
The Internet Engineering Task Force (IETF) and the Internet Assigned Numbers Authority (IANA) have restricted from general use various reserved IP addresses for special purposes. Some are used for maintenance of routing tables, for multicast traffic, operation under failure modes, or to provide addressing space for public, unrestricted uses on private networks.
| Address block | Address range | Number of addresses | Scope | Description |
| 0.0.0.0/8 | 0.0.0.0–0.255.255.255 | 16777216 | Software | Current network (only valid as source address). |
| 10.0.0.0/8 | 10.0.0.0–10.255.255.255 | 16777216 | Private network | Used for local communications within a private network. |
| 100.64.0.0/10 | 100.64.0.0–100.127.255.255 | 4194304 | Private network | Shared address space for communications between a service provider and its subscribers when using a carrier-grade NAT. |
| 127.0.0.0/8 | 127.0.0.0–127.255.255.255 | 16777216 | Host | Used for loopback addresses to the local host. |
| 169.254.0.0/16 | 169.254.0.0–169.254.255.255 | 65536 | Subnet | Used for link-local addresses between two hosts on a single link when no IP address is otherwise specified, such as would have normally been retrieved from a DHCP server. |
| 172.16.0.0/12 | 172.16.0.0–172.31.255.255 | 1048576 | Private network | Used for local communications within a private network. |
| 192.0.0.0/24 | 192.0.0.0–192.0.0.255 | 256 | Private network | IETF Protocol Assignments. |
| 192.0.2.0/24 | 192.0.2.0–192.0.2.255 | 256 | Documentation | Assigned as TEST-NET-1, documentation and examples. |
| 192.88.99.0/24 | 192.88.99.0–192.88.99.255 | 256 | Internet | Reserved. Formerly used for IPv6 to IPv4 relay (included IPv6 address block 2002::/16). |
| 192.168.0.0/16 | 192.168.0.0–192.168.255.255 | 65536 | Private network | Used for local communications within a private network. |
| 198.18.0.0/15 | 198.18.0.0–198.19.255.255 | 131072 | Private network | Used for benchmark testing of inter-network communications between two separate subnets. |
| 198.51.100.0/24 | 198.51.100.0–198.51.100.255 | 256 | Documentation | Assigned as TEST-NET-2, documentation and examples. |
| 203.0.113.0/24 | 203.0.113.0–203.0.113.255 | 256 | Documentation | Assigned as TEST-NET-3, documentation and examples. |
| 224.0.0.0/4 | 224.0.0.0–239.255.255.255 | 268435456 | Internet | In use for IP multicast. (Former Class D network). |
| 240.0.0.0/4 | 240.0.0.0–255.255.255.254 | 268435456 | Internet | Reserved for future use. (Former Class E network). |
| 255.255.255.255/32 | 255.255.255.255 | 1 | Subnet | Reserved for the "limited broadcast" destination address. |
Private networks
Of the approximately four billion addresses defined in IPv4, three ranges are reserved for use in private networks. Packets addresses in these ranges are not routable in the public Internet, because they are ignored by all public routers. Therefore, private hosts cannot directly communicate with public networks, but require network address translation at a routing gateway for this purpose.
| Name | CIDR block | Address range | Number of addresses | Classful description |
| 24-bit block | 10.0.0.0/8 | 10.0.0.0 – 10.255.255.255 | 16777216 | Single Class A. |
| 20-bit block | 172.16.0.0/12 | 172.16.0.0 – 172.31.255.255 | 1048576 | Contiguous range of 16 Class B blocks. |
| 16-bit block | 192.168.0.0/16 | 192.168.0.0 – 192.168.255.255 | 65536 | Contiguous range of 256 Class C blocks. |
See Private network for details.
Comparison
| Name | IPv4 | IPv6 | Description |
| Loopback Address | | | - |
| Unspecified Address | | | Only valid as a bind address (Source Address). This allows connections on any interface address. |
IPv4
IPv4 units (classes)
- [Recommended] Understanding IP addresses and IP classes A, B, C, D, E
- IP addressing scheme and how to tell classes apart
Why loopback is 127.0.0.0/8 in IPv4
- Why is there more than one loopback IP address?
- Why are there so many loopback addresses? - Explains the historical reasons.
127/8 (shorthand for 127.0.0.0/8) is reserved by IANA.
- Historical limitation: there is no MASK in the first implementation of tcpip, that means network nodes use the first number to distinguish network size and host ID. moreover, since class A is determined by its first octet, the higher-order bit is 0, so 127.x.x.x (01111111.x.x.x) is the latest segement of class A addresses. people often use all zero or all one numbers for special usages, reserving a class A segment is for maximum flexibility.
- Easy implementation: as what I say above, there was no MASK concept in early days, segment address 01111111.00000000.00000000.00000000 is easy to be determined by AND/XOR operations quickly and easily. Even nowadays, such pattern is still easy for matching subnets by applying XOR operation.
- Reserved for future use: class A has 16,777,216 hosts, so it allows people have more space to divide it into a lot of reasonable zones for specific usages, different devices, systems and applications.
IPv6
- Wikipedia (en) article on IPv6
- Toast - Passing Apple's IPv6 review, which gives developers a hard time
- IPv6 is not less secure just because it has no NAT | GeekNews
IPv6 tutorial for IPv4 users
Hello IPv6: a minimal tutorial for IPv4 users
- It is true that IPv6 simply gives more addresses, but many things we learned in IPv4 have changed or disappeared in IPv6
- A guide for people using it at home or in a small office
- How ARP, DHCP, NAT, etc. work in IPv6
- IPv6 has a different Ethernet frame type: 0x0800 (v4) vs. 0x86DD (v6)
- An IPv6 address is 128-bit (16 bytyes) = 64-bit (network) prefix + 64-bit interface id
- IPv6 uses NDP (Neighbor Discovery Protocol), not ARP (Address Resolution Protocol)
- IPv6 has no broadcast address concept. Some multicast addresses perform this function
- IPv6 can be configured dynamically like DHCPv4, but using DHCPv6, RA, PD, and SLAAC it can be configured more often and without maintaining state.
- NAT is not needed in IPv6. If needed for security, random/temporary IPv6 addresses can be used
How to check for IP conflicts
You can send an ARP request or a neighbor solicitation for your own address. If you get a reply, the address is duplicated.
For IPv6, this is done automatically. Run ip addr and look at the address flags.
- Addresses currently being checked have the
tentative" flag, and - conflicting addresses have
dadfailed.
Use ndisc6 to perform a manual check/query. For example:
IPv4 did not require automatic duplicate detection, but some systems do it anyway. For example, Windows tells you about duplicates immediately.
Many DHCP servers also perform an ARP check before issuing a lease, so if you used DHCP you don't need to worry.
The corresponding IPv4 tool is arping:
How to set up communication between IPs in different ranges
For example, such as 192.168.0.xxx and 10.0.0.xxx ...
Method 1. Use two LAN cards on the PC
How_to_set_up_communication_between_IPs_of_different_bands-1.png
In this case, be careful not to set the Binding Address to 0.0.0.0 when creating the socket.
Method 2. Assign two IPs to a LAN card
How_to_set_up_communication_between_IPs_of_different_bands-2.png
Assign multiple IPs to a single interface:
Or, to save it in the /etc/network/interfaces configuration file:
Method 3. Add an entry to the router's Routing Table
How_to_set_up_communication_between_IPs_of_different_bands-3.png
In a case like the screenshot, go to the router's settings page and add a routing table entry:
- Target: 10.10.10.0
- Mask: 255.255.255.0
- Gateway: 192.168.0.1
See also
- Time to live (TTL)
- Classless Inter-Domain Routing (pronounced "cider"; CIDR) A classless inter-domain routing scheme. Written like
192.168.0.0/16. - Internet protocol suite
- TCP
- Port
- Network class
- Loopback
- Routing table
- Private network
- Classful network
- Subnetwork/SubnetMask
- Network address translation (NAT)
- DHCP
- Medium access control (MAC)
- ipcalc - IP calculator. Calculates host ranges, netmasks, etc.
- netplan - To set a static IP on Ubuntu, see Netplan#How to set a static IP.
- Ipinfo
Favorite site
- Wikipedia (en) article on IP
- Special IP Addresses 2
- TCP/IP A, B, C network classes
- IP Header, IP packet header, IPv4 header
- (Network is Fun!) Addresses for communication (MAC Address/IP Address)
Programming Tips
Articles
References
- Arpanet
- Classful network
- Classless Inter-Domain Routing
- Communication protocol
- Computer Network
- ComputerNetwork:Basic
- Ethernet
- Fly.io
- Internet
- Internet protocol suite
- Internetwork Packet Exchange
- Ip
- IP address spoofing
- Ipcalc
- Ipinfo
- Iproute2
- IPSec
- Iptables
- Localhost
- Loopback
- Multicast
- Nanomsg-next-gen
- Network monitoring
- Network Programming
- Network switch
- NetworkManager
- OSI Model
- Port
- Private network
- Programming
- Protocol
- Python:ipaddress
- Routing table
- SolutionStack:FullStackDeveloper:Curriculum
- Stateless protocol
- Subnetwork
- Time to live
- Traceroute
- Transmission Control Protocol
- User Datagram Protocol
- World Wide Web