IPアドレスとは?IPv4、IPv6、Public IPとPrivate IPを解説
インターネットに接続するすべてのdeviceにはIP addressがあります。これはdataを正しい宛先へ届けるための一意なnetwork labelです。Webサイト表示、email送信、動画streaming、online game、appとserverの接続は、IP addressによるroutingの上に成り立っています。
目次
IPアドレスとは?
IP addressはInternet Protocol addressの略で、network上のdeviceに割り当てられる数値の識別子です。digital trafficにおける差出人住所と宛先住所のように機能します。
Internet Protocolは、packetがlocal network、internet service provider、data center、global backbone networkを通って移動するために必要なaddress informationを与えます。
日常的に使われる主なversionは2つあります。古くから広く使われるIPv4と、はるかに多くのaddressを提供するために作られた新しいIPv6です。
IPv4 - 初期から使われる標準
IPv4はTCP/IP初期からinternetの中核を支えてきました。32-bit addressを使い、dotで区切った4つの10進数として書きます。
IPv4 format: X.X.X.X (each X is 0-255)
Examples:
192.168.1.1 -> Private address, often a home router
8.8.8.8 -> Public address, Google DNS
10.0.0.1 -> Private address, common in offices
172.217.14.206 -> Public address, a Google server
127.0.0.1 -> Loopback address, your own machine
Binary representation:
192.168.1.1 = 11000000.10101000.00000001.00000001
Each octet: 8 bits x 4 octets = 32 bits total
Total possible addresses: 2^32 = 4,294,967,296IPv4は約43億個のaddressを表せます。かつては十分に見えましたが、phone、laptop、server、virtual machine、router、IoT deviceによって急速に消費されました。この不足がprivate address、NAT、IPv6を重要にしています。
IPv4 Address Classes
IPv4 addressはもともとaddress classに分類されていました。現在のnetworkでは通常CIDRを使いますが、古いclassは背景知識として役立ちます。
| Class | Range | Default mask | 用途 |
|---|---|---|---|
| A | 1.0.0.0 - 126.255.255.255 | 255.0.0.0 | 大規模network |
| B | 128.0.0.0 - 191.255.255.255 | 255.255.0.0 | 中規模network |
| C | 192.0.0.0 - 223.255.255.255 | 255.255.255.0 | 小規模network |
| D | 224.0.0.0 - 239.255.255.255 | N/A | Multicast |
| E | 240.0.0.0 - 255.255.255.255 | N/A | 予約または実験用 |
IPv6 - 次世代のIP
IPv6は128-bit addressを使い、hexadecimalで表記します。IPv4 exhaustionを解決し、現代のnetworkをより拡張しやすくするために作られました。
IPv6 format: eight groups of hexadecimal digits
Full notation:
2001:0db8:85a3:0000:0000:8a2e:0370:7334
Compressed notation:
2001:db8:85a3::8a2e:370:7334
Examples:
::1 -> Loopback address
fe80::1 -> Link-local address
2606:4700:4700::1111 -> Cloudflare DNS
2001:4860:4860::8888 -> Google DNS
Address space:
128 bits = about 340 undecillion addresses- global connectivityに使えるaddress spaceが非常に大きい
- networkに参加するdeviceのauto-configurationがより簡潔
- routing効率のためpacket headerが単純化されている
- 重いNATに頼らずend-to-end addressingを支えやすい
- 現代的なnetwork security機能を支える仕組みがある
IPv4とIPv6の比較
| Feature | IPv4 | IPv6 |
|---|---|---|
| Address size | 32 bits | 128 bits |
| Address count | 約43億 | 約340 undecillion |
| Format | 192.168.1.1 | 2001:db8::1 |
| Notation | dot区切りのdecimal | colon区切りのhexadecimal |
| NAT usage | addressが不足しているため一般的 | addressが豊富なため必要性は低い |
| Adoption | 現在も広く利用されている | ISP、cloud、mobile networkで着実に普及中 |
Public IPとPrivate IP
Public IP addressはinternetから到達可能なaddressです。Private IP addressはlocal network内部で使われ、public internet上では直接routeされません。
| 種類 | 意味 | 例 |
|---|---|---|
| Public IP | ISP、cloud provider、hosting networkから割り当てられる | Web server、VPN gateway、home routerのWAN address |
| Private IP | local network内だけで使われる | 家庭のWi-Fi device、office laptop、printer、camera |
| Loopback IP | 同じdevice自身を指す | localhost testing用の127.0.0.1または::1 |
よく使われるprivate IPv4 ranges
| Range | Address span | 主な用途 |
|---|---|---|
| 10.0.0.0/8 | 10.0.0.0 - 10.255.255.255 | 大規模なcorporate networkやcloud network |
| 172.16.0.0/12 | 172.16.0.0 - 172.31.255.255 | 中規模internal network |
| 192.168.0.0/16 | 192.168.0.0 - 192.168.255.255 | 家庭やsmall office network |
Static IPとDynamic IP
IP addressにはstaticとdynamicがあります。違いはaddressの割り当て方法と、時間とともに変わるかどうかです。
| 種類 | 仕組み | 向いている用途 | 注意点 |
|---|---|---|---|
| Static IP | 手動割り当て、または予約されて同じaddressを維持する | server、VPN、remote access、DNS record | 通常は費用や管理負荷が増える |
| Dynamic IP | DHCPなどで自動的に割り当てられる | 家庭、phone、laptop、通常のbrowsing | 再接続やlease renewal後に変わることがある |
IP通信の仕組み
Webサイトを開くとき、deviceは名前へ直接dataを送るわけではありません。まず名前をIP addressへresolveし、その宛先へpacketを送ります。
1. You enter www.example.com in a browser
2. DNS resolves the name to an IP address such as 93.184.216.34
3. Your device creates packets with:
Source IP: your device or router public IP
Destination IP: 93.184.216.34
4. Routers forward the packets hop by hop across networks
5. The web server sends response packets back to your IP
6. Your router uses NAT to deliver the response to the correct deviceSubnetsとCIDR Notation
SubnetはIP networkを小さなrangeへ分割します。/24のようなCIDR notationは、addressのうち何bitがnetwork部分を示すかを表します。
Example network:
IP address: 192.168.1.100
Subnet mask: 255.255.255.0
CIDR notation: 192.168.1.0/24
Network address: 192.168.1.0
Broadcast: 192.168.1.255
Usable hosts: 192.168.1.1 - 192.168.1.254
Common CIDR blocks:
/8 -> 16,777,214 usable IPv4 hosts
/16 -> 65,534 usable IPv4 hosts
/24 -> 254 usable IPv4 hosts
/32 -> one exact IPv4 addressNAT - 複数deviceで1つのIPを共有する仕組み
NAT、つまりNetwork Address Translationは、多数のprivate deviceが1つのpublic IPv4 addressを共有できるようにします。public IPv4 addressが限られているため不可欠になりました。
Private network:
Laptop 192.168.1.20
Phone 192.168.1.21
Game console 192.168.1.22
Router private IP: 192.168.1.1
Router public IP: 73.42.115.200
To websites, all three devices can appear as:
73.42.115.200
The router tracks connections and forwards replies back
to the correct private device.NATは便利ですが、peer-to-peer connection、外部からのhosting、gaming、VoIP、remote accessを複雑にすることがあります。外部systemはport forwardingなどを使わない限りprivate deviceへ直接到達できないためです。
IP Geolocation - IPから分かること
IP addressからは、おおよそのnetwork locationやprovider detailsが分かることがあります。ただしIPだけで正確な住所を特定することは通常できません。
| Data point | 一般的な精度 | メモ |
|---|---|---|
| Country | 高い | 固定broadbandやmobile providerでは通常かなり正確 |
| Region or state | 中程度 | trafficが別regionから出ると外れることがある |
| City | 低から中程度 | 多くの場合おおよそで、ISPに依存する |
| ISP or organization | 高い | address allocation recordsから見えることが多い |
| Exact street address | IPだけでは取得不可 | ISP recordsとlegal processが必要 |
IP Addressを保護する方法
通常のinternet利用にはIP addressが必要ですが、public IPが公開する情報を減らすことはできます。
| 方法 | 役割 | 使う場面 |
|---|---|---|
| VPN | trafficをVPN providerのIP経由で送る | Webサイトやpublic Wi-Fi observerからの一般的なprivacy対策 |
| Tor | 複数のvolunteer relayを経由してtrafficを送る | 速度低下を受け入れて高いanonymityが必要な場合 |
| Proxy | 特定のappやbrowser trafficを別server経由で送る | testing、scraping control、location-specific check |
| Mobile data | home broadbandではなくcarrier networkのIPを使う | home network IPと素早く分けたい場合 |
| Firewall | 不要なinbound trafficをblockする | deviceやserverの保護 |
自分のIP Addressを確認する方法
Public IPはWebサイトから見えるaddressです。Private IPはdeviceがlocal network内で使うaddressです。
Find your public IP:
Browser:
Use a What Is My IP tool
Terminal:
curl ifconfig.me
curl ipinfo.io/ip
curl https://api.ipify.org
PowerShell:
(Invoke-WebRequest -Uri "https://api.ipify.org").ContentFind your private IP:
Windows:
ipconfig
macOS:
ifconfig
ipconfig getifaddr en0
Linux:
ip addr
hostname -I今すぐ自分のIP Addressを確認
無料のWhat Is My IP toolで、public IP address、おおよそのlocation、ISP、timezone、browser details、network informationをすぐに確認できます。
自分のIP Addressを確認参考資料
- RFC 791 - Internet Protocol
- RFC 8200 - Internet Protocol, Version 6 (IPv6)
- RFC 1918 - Address Allocation for Private Internets
- RFC 3022 - Traditional IP Network Address Translator
- Google IPv6 adoption statistics