Class A vs B vs C IP Address: Key Differences and Usage
Class A supports very large networks with IPs from 1.0.0.0 to 126.255.255.255, Class B supports medium-sized networks from 128.0.0.0 to 191.255.255.255, and Class C supports smaller networks from 192.0.0.0 to 223.255.255.255.Quick Comparison
Here is a quick table comparing Class A, B, and C IP addresses by their key features.
| Feature | Class A | Class B | Class C |
|---|---|---|---|
| IP Range | 1.0.0.0 - 126.255.255.255 | 128.0.0.0 - 191.255.255.255 | 192.0.0.0 - 223.255.255.255 |
| Default Subnet Mask | 255.0.0.0 | 255.255.0.0 | 255.255.255.0 |
| Number of Networks | 126 (0 and 127 reserved) | 16,384 | 2,097,152 |
| Hosts per Network | 16,777,214 | 65,534 | 254 |
| Typical Use | Very large networks | Medium-sized networks | Small networks or LANs |
Key Differences
Class A IP addresses are designed for very large networks. They use the first 8 bits for the network part and the remaining 24 bits for hosts. This allows over 16 million hosts on a single network, making it suitable for huge organizations or ISPs.
Class B addresses split the IP into 16 bits for the network and 16 bits for hosts. This supports medium-sized networks with up to about 65,000 hosts. It balances network and host capacity for universities or large businesses.
Class C addresses allocate 24 bits for the network and only 8 bits for hosts, allowing up to 254 hosts per network. This is ideal for small local area networks (LANs) like small offices or home networks. The classes also differ in their default subnet masks, which define how the IP address is divided between network and host parts.
Code Comparison
Here is a simple Python code snippet that checks the class of an IP address based on its first octet.
def get_ip_class(ip): first_octet = int(ip.split('.')[0]) if 1 <= first_octet <= 126: return 'Class A' elif 128 <= first_octet <= 191: return 'Class B' elif 192 <= first_octet <= 223: return 'Class C' else: return 'Other' # Example usage print(get_ip_class('10.0.0.1')) # Class A print(get_ip_class('172.16.0.1')) # Class B print(get_ip_class('192.168.1.1')) # Class C
Class B Equivalent
Here is the same IP class check implemented in JavaScript for Class B and others.
function getIpClass(ip) { const firstOctet = parseInt(ip.split('.')[0], 10); if (firstOctet >= 1 && firstOctet <= 126) { return 'Class A'; } else if (firstOctet >= 128 && firstOctet <= 191) { return 'Class B'; } else if (firstOctet >= 192 && firstOctet <= 223) { return 'Class C'; } else { return 'Other'; } } console.log(getIpClass('10.0.0.1')); // Class A console.log(getIpClass('172.16.0.1')); // Class B console.log(getIpClass('192.168.1.1')); // Class C
When to Use Which
Choose Class A IP addresses when you need to support extremely large networks with millions of hosts, such as major ISPs or large multinational companies.
Choose Class B for medium-sized networks like universities or large businesses that require thousands to tens of thousands of hosts.
Choose Class C for small networks such as small offices or home networks where only a few hundred devices need IP addresses.