Free reference
Subnet, CIDR and port cheat sheet
The table everyone keeps reopening in a browser tab, plus the reserved ranges worth recognising on sight and the arithmetic nobody does in their head at 3am.
CIDR
| CIDR | NETMASK | ADDRS | HOSTS |
|---|---|---|---|
/8 | 255.0.0.0 | 16777216 | 16777214 |
/16 | 255.255.0.0 | 65536 | 65534 |
/20 | 255.255.240.0 | 4096 | 4094 |
/22 | 255.255.252.0 | 1024 | 1022 |
/23 | 255.255.254.0 | 512 | 510 |
/24 | 255.255.255.0 | 256 | 254 |
/25 | 255.255.255.128 | 128 | 126 |
/26 | 255.255.255.192 | 64 | 62 |
/27 | 255.255.255.224 | 32 | 30 |
/28 | 255.255.255.240 | 16 | 14 |
/29 | 255.255.255.248 | 8 | 6 |
/30 | 255.255.255.252 | 4 | 2 |
/31 | 255.255.255.254 | 2 | 2 |
/32 | 255.255.255.255 | 1 | 1 |
Hosts is addresses minus two, for the network and the broadcast. /31 and /32 are the exceptions.
SUBNET MATH
Usable hosts = 2 to the power of (32 minus prefix), minus 2.
Block size = 256 minus the last octet of the mask. A /26 is .192, so blocks of 64: .0, .64, .128, .192.
RANGES TO KNOW
10.0.0.0/8 | private |
172.16.0.0/12 | private, 172.16 to 172.31 |
192.168.0.0/16 | private |
127.0.0.0/8 | loopback |
169.254.0.0/16 | link-local, DHCP failed |
224.0.0.0/4 | multicast |
TOOLS
ip a addresses | |
ip r routes | |
ping -c 4 host | |
mtr host traceroute, live | |
dig +short host | |
dig @8.8.8.8 host | |
dig -x 1.2.3.4 reverse | |
nc -zv host 443 | |
ss -tulpn | |
curl -sSI https://host | |
tcpdump -i any -n port 443 |
PORTS
20/21 | FTP |
22 | SSH, SCP, SFTP |
25 | SMTP |
53 | DNS |
67/68 | DHCP |
80 | HTTP |
88 | Kerberos |
110 | POP3 |
123 | NTP |
135/139 | NetBIOS |
143 | IMAP |
161/162 | SNMP |
179 | BGP |
389 | LDAP |
443 | HTTPS |
445 | SMB |
465 | SMTPS |
500 | IPsec IKE |
514 | syslog |
587 | SMTP submission |
636 | LDAPS |
993 | IMAPS |
995 | POP3S |
1194 | OpenVPN |
1521 | Oracle DB |
1812/13 | RADIUS auth, acct |
2049 | NFS |
3000 | dev servers |
3306 | MySQL |
3389 | RDP |
5060/61 | SIP |
5353 | mDNS |
5432 | PostgreSQL |
5672 | AMQP |
6379 | Redis |
6443 | Kubernetes API |
8080 | HTTP alt |
8443 | HTTPS alt |
9090 | Prometheus |
9092 | Kafka |
9100 | node exporter |
11211 | memcached |
15672 | RabbitMQ UI |
27017 | MongoDB |
The parts people get wrong
These are the distinctions that cost real time. They are the reason this sheet exists rather than another list of commands.
Does 172.16.0.0/12 include 172.255?
172.16.0.0/12 covers 172.16 through 172.31. Not through 172.255. This is the single most common subnetting mistake.
What a 169.254 IP address means
An address starting 169.254 means DHCP never answered. Nothing is routing and no amount of DNS work will help.
Can you use a /31 subnet?
A /31 on a point-to-point link is legal and standard. RFC 3021. Both addresses are usable.
Why dev servers run on port 3000 and 8080
Ports above 1023 do not need root to bind. That is the only reason dev servers live at 3000 and 8080.
Ping works but the service is unreachable
Ping succeeding proves ICMP works, nothing more. Test the actual port with nc -zv before blaming the network.
Mismatched subnet masks on the same network
Two hosts in the same subnet with different masks will talk one way and not the other. Check the mask on both ends.