0
0
Computer-networksComparisonBeginner · 4 min read

Class A vs B vs C IP Address: Key Differences and Usage

Class A, B, and C IP addresses differ mainly in their network size and range. 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.

FeatureClass AClass BClass C
IP Range1.0.0.0 - 126.255.255.255128.0.0.0 - 191.255.255.255192.0.0.0 - 223.255.255.255
Default Subnet Mask255.0.0.0255.255.0.0255.255.255.0
Number of Networks126 (0 and 127 reserved)16,3842,097,152
Hosts per Network16,777,21465,534254
Typical UseVery large networksMedium-sized networksSmall 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.

python
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
Output
Class A Class B Class C
↔️

Class B Equivalent

Here is the same IP class check implemented in JavaScript for Class B and others.

javascript
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
Output
Class A Class B 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.

Key Takeaways

Class A supports very large networks with over 16 million hosts per network.
Class B balances network and host sizes for medium-sized networks.
Class C is best for small networks with up to 254 hosts.
Default subnet masks differ: Class A uses 255.0.0.0, Class B 255.255.0.0, Class C 255.255.255.0.
Use IP class based on network size needs to optimize address allocation.