解析ツール
ネットワークトラブルを下位層から順に切り分けるための実用ツール集。 ping / traceroute / dig / curl / tcpdump / Wireshark / netstat / ss / nmap など。
切り分けの順序
- L1: ケーブル・電源・リンク(
ip link) - L2: ARP(
arp -a) - L3: 疎通(
ping)と経路(traceroute) - L4: ポート疎通(
nc/nmap) - L7: HTTP(
curl -v)と DNS(dig) - 細かい中身を見たい時はパケットキャプチャ(
tcpdump/ Wireshark)
ping
ICMP Echo で疎通と RTT を測る。
ping example.com
ping -c 5 8.8.8.8
ping6 -c 5 2001:4860:4860::8888
# パケットサイズ
ping -s 1472 example.com # MTU 試験
# 連続
ping -i 0.2 host # 200ms 間隔(root)
ICMP がブロックされている環境では返ってこないことがある。「ping 落ちる = 死んでる」とは限らない。
traceroute / tracepath / mtr
宛先までの経路を 1 ホップずつ表示。TTL を 1, 2, 3... と増やしながら ICMP Time Exceeded を集める仕組み。
# 基本
traceroute example.com
traceroute6 example.com
tracert example.com # Windows
# UDP / TCP / ICMP
traceroute -T -p 443 example.com # TCP 443 宛
traceroute -I example.com # ICMP
# 動的・統計
mtr example.com # 連続して loss / 遅延を表示
中間ルータが ICMP を返さない区間は「* * *」になるが、最終目的地が応答すれば到達は OK。
dig / nslookup / host
DNS 解決の確認。
dig example.com
dig example.com AAAA
dig example.com MX
dig +short example.com # 短く
dig +trace example.com # ルートから
dig @1.1.1.1 example.com # サーバ指定
dig -x 8.8.8.8 # 逆引き
nslookup example.com
host example.com
curl
HTTP / HTTPS のほぼなんでもデバッグできる万能ツール。
# 詳細表示
curl -v https://example.com
# ヘッダだけ
curl -I https://example.com
# 経路まで詳しく
curl -vvv https://example.com
# 時間を計測
curl -w "\n%{time_namelookup} %{time_connect} %{time_appconnect} %{time_starttransfer} %{time_total}\n" -o /dev/null -s https://example.com
# HTTP/2, HTTP/3
curl --http2 https://example.com
curl --http3 https://example.com
# JSON POST
curl -X POST https://api.example.com/x \
-H "Content-Type: application/json" \
-d '{"name":"yui"}'
# Cookie 保存
curl -c cookies.txt -b cookies.txt https://example.com
# 証明書検証スキップ(開発用)
curl -k https://localhost
# プロキシ経由
curl -x http://proxy:8080 https://example.com
nc(netcat)
TCP / UDP の汎用ツール。「動くソケット」のスイス・アーミーナイフ。
# ポート疎通
nc -zv example.com 443
nc -uzv 8.8.8.8 53 # UDP
# 簡易サーバ
nc -l 9000 # 9000 で待ち受け
echo "hello" | nc localhost 9000
# 簡易チャット
# サーバ: nc -l 9000
# クライアント: nc server 9000
# ファイル転送
nc -l 9000 > out.bin # 受信側
nc server 9000 < in.bin # 送信側
nmap
ポートスキャナ。許可された対象に対してのみ使用すること。
# 基本スキャン
nmap example.com
# 全ポート
nmap -p- example.com
# UDP(時間かかる)
nmap -sU -p 53 example.com
# サービス / バージョン検出
nmap -sV example.com
# OS 推測
sudo nmap -O example.com
# サブネット全体
nmap 192.168.1.0/24
ss / netstat
OS のソケット状態を表示。ss は Linux でnetstatより高速。
# Linux
ss -tnlp # TCP 待ち受け + プロセス
ss -tn # TCP 接続中
ss -un # UDP
ss -s # サマリ
# 古典版 (Linux / macOS / Windows)
netstat -tnlp
netstat -an | grep 443
netstat -rn # ルーティングテーブル
# macOS
lsof -i :3000
lsof -i -n -P
tcpdump
パケットキャプチャの定番。CLI で取り、必要なら Wireshark で開く。
# 基本
sudo tcpdump -i en0
# ホスト指定
sudo tcpdump -i any host 8.8.8.8
# ポート指定
sudo tcpdump -i any port 443
# 中身も見る
sudo tcpdump -i any -A port 80
# pcap に保存(Wireshark で開く)
sudo tcpdump -i any -w /tmp/dump.pcap port 443
# pcap を読む
tcpdump -r /tmp/dump.pcap
# 詳細表示
sudo tcpdump -i any -v -nn port 443
BPF フィルタ
host 192.168.1.1
src 1.2.3.4 and dst port 443
tcp[tcpflags] & (tcp-syn) != 0 ← SYN だけ
not arp and not icmp
Wireshark
GUI のパケット解析ツール。tcpdump で取った pcap をリッチに表示・分析。
- プロトコル階層を可視化(Ethernet → IP → TCP → HTTP)
- 「Follow TCP Stream」で会話を一気に読む
- 表示フィルタ:
http、tcp.port == 443、ip.addr == 1.2.3.4 - TLS は秘密鍵があれば復号できる(
SSLKEYLOGFILEで取得) - HTTP/2 / HTTP/3 / WebSocket / DNS / TLS をすべて読み込める
iperf3 / nuttcp
スループット測定。
# サーバ
iperf3 -s
# クライアント (TCP)
iperf3 -c server -t 30
# UDP(帯域指定)
iperf3 -c server -u -b 100M
# 並列
iperf3 -c server -P 4
ethtool / mii-tool(Linux)
sudo ethtool eth0 # リンク速度・全二重
sudo ethtool -S eth0 # 統計
sudo ethtool -i eth0 # ドライバ情報
sudo ethtool -K eth0 tso off # オフロード制御
ip / ifconfig
# Linux 推奨
ip a # アドレス
ip link # NIC
ip route # ルーティング
ip neigh # ARP/NDP
ip -s link # 統計
# 古典
ifconfig
arp -a
route -n
nslookup の代替: doggo / dog
Rust / Go 製のモダンな DNS ツール。色付き出力で読みやすい。
HTTPie
curl の人間にやさしい代替。
http GET https://api.example.com/users
http POST https://api.example.com/users name=yui
http --headers https://example.com
Speedtest CLI
speedtest # Ookla 公式
speedtest-cli # Python 製の派生
ブラウザ DevTools
- Network タブ: リクエスト一覧、ヘッダ、タイミング、サイズ
- Throttling: 3G / 遅い 4G を再現
- Disable cache
- Block request URL: 特定 URL を遮断してテスト
- HAR ファイル: 再現可能な形式で保存
- chrome://net-internals/ で詳細
OS 別の便利コマンド
macOS
networksetup -listallhardwareports
networksetup -getdnsservers Wi-Fi
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
scutil --dns # DNS 設定詳細
scutil --proxy # プロキシ
airport -I # /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
Windows
ipconfig /all
ipconfig /flushdns
nslookup example.com
tracert example.com
netstat -ano
Get-NetAdapter
Get-NetTCPConnection
Test-NetConnection example.com -Port 443
Linux
resolvectl status
resolvectl flush-caches
ss -tnlp
ip a
ip route
tc qdisc # トラフィック制御
nft list ruleset # 現代的な FW (旧 iptables)
パフォーマンス計測
- Lighthouse — Web パフォーマンス監査
- WebPageTest — 詳細なウォーターフォール
- k6 / wrk / hey — ロードテスト
- vegeta — Go 製、シンプル
- JMeter — 老舗
定型: 「繋がらない」を切り分ける
1. ip a → IP は取れているか
2. ip route → デフォルトゲートウェイは
3. ping ゲートウェイ → 自 LAN 内疎通
4. ping 8.8.8.8 → 外向き L3 疎通
5. ping example.com→ DNS が機能しているか
6. dig example.com → DNS の中身
7. curl -v https://example.com → HTTPS まで通るか
8. tcpdump で SYN が出ているか確認
セキュリティテスト
許可された対象に対してのみ。
- nmap — ポート / サービス検査
- OWASP ZAP / Burp Suite — Web アプリ検査
- sslyze / testssl.sh — TLS 設定検査
- nuclei — テンプレベースの脆弱性検査
オンラインツール
- SSL Labs — TLS 評価
- securityheaders.com
- crt.sh — 証明書透明性ログ
- bgp.he.net — AS / BGP 情報
- DNS Checker — 各国の DNS 結果
- Shodan — インターネット全体のサーバ検索(許可ある対象のみ)
ping / dig / curl / ss / tcpdump の 5 つだけでも実戦の 80% は片付く。 普段から触っておくと、いざ障害のとき頭が真っ白にならない。