サブネット化とCIDRの詳細
可変長サブネットマスクとCIDR表記を習得し、アドレス空間を計画し、範囲を計算し、ルートを効率的に集約する方法を学びます。
「サブネット化とCIDRの詳細」はCoddyKit上の無料Linux Networking & TCP/IP for Developersレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはLinux Networking & TCP/IP for Developers学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Linux Networking & TCP/IP for Developersコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Why Subnetting Matters
Subnetting splits a large network into smaller, manageable segments. It improves security, performance, and address efficiency.
CIDR (Classless Inter-Domain Routing) replaced rigid class A/B/C boundaries with flexible prefix lengths.
CIDR Notation
A CIDR block is written as address/prefix. The prefix counts the number of leading network bits.
192.168.1.0/24— 24 network bits, 8 host bits10.0.0.0/8— 8 network bits, 24 host bits
The Subnet Mask
A prefix maps directly to a dotted-decimal mask.
/24= 255.255.255.0/26= 255.255.255.192/30= 255.255.255.252
Each set bit in the mask is a network bit.
Counting Hosts
Host count = 2^(host bits) minus 2 (network and broadcast addresses).
/24-> 2^8 - 2 = 254 hosts/26-> 2^6 - 2 = 62 hosts/30-> 2^2 - 2 = 2 hosts (perfect for point-to-point links)
Finding the Network Address
Bitwise-AND the IP with the mask to get the network address. The example below computes it in Python.
import ipaddress
net = ipaddress.ip_network('192.168.5.130/26', strict=False)
print('network:', net.network_address)
print('broadcast:', net.broadcast_address)Determining the Range
For 192.168.5.130/26: block size is 64, so subnets start at .0, .64, .128, .192.
The .130 address falls in the 192.168.5.128/26 subnet (usable .129 to .190, broadcast .191).
Variable-Length Subnet Masking (VLSM)
VLSM lets different subnets use different prefix lengths from one block, matching size to need.
Allocate largest subnets first to avoid fragmentation and wasted address space.
Route Aggregation (Supernetting)
Adjacent subnets can be summarized into one larger prefix, shrinking routing tables.
192.168.0.0/24+192.168.1.0/24->192.168.0.0/23
Aggregation only works when blocks are contiguous and aligned.
Subnetting with Python
The ipaddress module can split a network into smaller subnets automatically.
import ipaddress
big = ipaddress.ip_network('10.0.0.0/24')
for sub in big.subnets(new_prefix=26):
print(sub)Checking Membership
Verify whether an address belongs to a network — essential for ACLs and routing decisions.
import ipaddress
addr = ipaddress.ip_address('10.0.0.45')
net = ipaddress.ip_network('10.0.0.0/26')
print(addr in net)Common Pitfalls
Watch out for:
- Forgetting to subtract network and broadcast addresses
- Misaligned aggregation that overlaps other blocks
- Using
/31links (valid per RFC 3021 for point-to-point) without device support
Quick Check
Test your subnetting math.
Recap
You can now plan address space confidently:
- Read and convert CIDR prefixes and masks
- Calculate network, broadcast, and host ranges
- Apply VLSM to size subnets to need
- Aggregate contiguous blocks to shrink routing tables
- Use Python's
ipaddressmodule for verification
This underpins the IPv6, routing, and NAT topics in this course.
よくある質問
「サブネット化とCIDRの詳細」レッスンは無料ですか?
はい。「サブネット化とCIDRの詳細」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Linux Networking & TCP/IP for Developersコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Linux Networking & TCP/IP for Developersコースには全4レッスンが含まれています。
「サブネット化とCIDRの詳細」で何を学びますか?
可変長サブネットマスクとCIDR表記を習得し、アドレス空間を計画し、範囲を計算し、ルートを効率的に集約する方法を学びます。 ブラウザで直接実行するハンズオンコードでLinux Networking & TCP/IP for Developersを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Linux Networking & TCP/IP for Developersを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのLinux Networking & TCP/IP for Developersは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「サブネット化とCIDRの詳細」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このLinux Networking & TCP/IP for Developersレッスンでコードを書いて実行できますか?
はい。すべてのLinux Networking & TCP/IP for Developersレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。