To start with, classful addressing has not been used since the mid-90s. Everything uses CIDR now, which allows splitting an IPv4 address space into any size from a /32
(2^(32-32) = 1 address) to /0
(2^(32-0) addresses). The corresponding size for an (ancient) class C network would be a /24
subnet in CIDR.
From a theoretical point of view, you can have networks of any size (that is a power of two). Of course, as you've correctly guessed, you will run into practical issues at some point, so we have to put some design effort into our networks.
Now, routers generally don't care how many addresses are in a single subnet. They'll forward them to the correct destination all the same. Where you might run into problems at the routing level is if you have too many subnets - we've been splitting subnets smaller and smaller to deal with IPv4 exhaustion, so where a company might have been able to purchase a single contiguous /28
of 14 usable addresses in the past, they might need to purchase two separate /29
s of 6 usable addresses each now.
What used to be a single /16
(originally assigned as a class B some 30 years ago) might now be split into 1000 /26
s, which means 1000 more entries in routing tables. Do this a few (thousand) times and your tables are now full. This has caused major outages before, and will likely do so again.
This only really matters with publicly routable addresses on internet core routers, which have to know the route to every network. Your home "router" is just going to forward everything via its default route and let your ISP deal with it. This is also largely irrelevant for private addresses, which are by definition not publicly routable.
The other potential issue you mention applies below the routing level, within a single subnet. Where you might run into issues here is if your broadcast domain is too big. While a broadcast domain is not necessarily the same thing as a subnet, for most (especially consumer/home) purposes it is the same.
When your broadcast domain gets too big, you can run into issues: your OS's ARP tables might overflow (~256 by default in Windows, ~1024 by default in Linux, but tunable on both). This means your OS starts forgetting which MAC address an IP address corresponds to, and needs to discover it again by sending an ARP request ... which is broadcast to every host. With too many hosts, a good chunk of your network bandwidth is taken by ARP requests and responses.
Also, your network switches (often built into consumer routers as the 4 "LAN" ports) can get a bit unhappy with too many hosts because their fowarding tables (based on MAC addresses, not IP addresses) are only of a fixed size, and they can start "forgetting" which port to forward to.
Luckily (or by design?), these issues tend to appear somewhere north of 256 hosts, so 254 in a single subnet probably won't run into them. They are a reason you're generally supposed to route between /24
s rather than using, say, a single /16
.
One other advantage of assigning a whole /24
is so we have some spare room for DHCP-assigned addresses. Most home networks these days don't have a static address assigned to each host - they are instead chosen by a DHCP server and reserved for a period of time, so e.g. your phone doesn't get a new address every time it disconnects for a second. When your network is almost full, you force the DHCP server to start recycling addresses sooner.
Most DHCP servers on consumer routers default to an address pool of only 100 addresses, so you will never reach 254 without either adjusting the pool size or assigning static addresses.
At the end of the day, while we have issues with IPv4 exhaustion at the global level, there's absolutely no shortage of private addresses (which have three large ranges, a /8
, a /12
and a /16
, to play with -- that can contain over 65000 /24
s). There's little reason to try conserving them, so no one bothers going smaller than a /24
.
And, if you want to, you certainly can have 254 hosts active on a /24
. Most consumer routers/switches and OSes will even handle it fine for the most part, though some tweaking (esp. DHCP) may be required.
110
. (Class A started with0
, Class B started with10
, Class C started with110
, Class D started with1110
, and Class E started with1111
). Each class A to C had a default mask, but10.0.0.0
with mask255.255.255.0
was still a Class A network.