InfraLab
VPN-TUNNELING35 cmd

VPN / トンネリング (WireGuard / IPsec / OpenVPN) チート集

WireGuard、strongSwan IPsec、OpenVPN の鍵生成、最小設定、起動停止、SA 確認、AllowedIPs、IKEv2 PSK/cert、easy-rsa、tun/tap の使い分けをまとめたチート集。

更新日
2026-05-29
参照範囲
公式ドキュメント / man page / 主要ベンダーCLI
対象実装
主要 Linux / BSD / ネットワーク機器 CLI の一般的な実装
免責
OS とバージョン差分は実環境で確認してください。

このチートシートの使いどころ

VPN / トンネリング (WireGuard / IPsec / OpenVPN) チート集は、WireGuard、strongSwan IPsec、OpenVPN の鍵生成、最小設定、起動停止、SA 確認、AllowedIPs、IKEv2 PSK/cert、easy-rsa、tun/tap の使い分けをまとめたチート集。 対象は公式ドキュメント、man page、主要ベンダー CLI で確認できる現行の一般的な実装です。カテゴリはWireGuard、IPsec (strongSwan)、OpenVPNを中心に、35件のコマンドや値を用途別に引けます。障害調査、設定変更前の確認、作業メモ作成で、WireGuard、IPsec、strongSwan、OpenVPN、VPNに関連する操作を短時間で探すために使います。

35 / 35

wg genkey

VPN / トンネリング で wg genkey を実務運用で使う

Example
$ wg genkey | tee privatekey | wg pubkey > publickey
wg show

VPN / トンネリング で wg show を実務運用で使う

Example
$ sudo wg show
wg-quick up

VPN / トンネリング で wg-quick up を実務運用で使う

Example
$ sudo wg-quick up wg0
wg-quick down

VPN / トンネリング で wg-quick down を実務運用で使う

Example
$ sudo wg-quick down wg0
wg set peer

VPN / トンネリング で wg set peer を実務運用で使う

Example
$ sudo wg set wg0 peer AbCd... allowed-ips 10.10.10.2/32
wg set listen-port

VPN / トンネリング で wg set listen-port を実務運用で使う

Example
$ sudo wg set wg0 listen-port 51820
wg syncconf

VPN / トンネリング で wg syncconf を実務運用で使う

Example
$ sudo wg syncconf wg0 <(wg-quick strip wg0)
WireGuard Interface

VPN / トンネリング で WireGuard Interface を実務運用で使う

Example
[Interface] Address = 10.10.10.1/24 PrivateKey = <privatekey> ListenPort = 51820
WireGuard Peer

VPN / トンネリング で WireGuard Peer を実務運用で使う

Example
[Peer] PublicKey = <peer-publickey> AllowedIPs = 10.10.10.2/32 Endpoint = 203.0.113.10:51820
AllowedIPs route

VPN / トンネリング で AllowedIPs route を実務運用で使う

Example
AllowedIPs = 10.0.0.0/8, 192.168.0.0/16
PersistentKeepalive

VPN / トンネリング で PersistentKeepalive を実務運用で使う

Example
PersistentKeepalive = 25
Roaming peer

VPN / トンネリング で Roaming peer を実務運用で使う

Example
$ sudo wg show wg0 endpoints
ipsec status

VPN / トンネリング で ipsec status を実務運用で使う

Example
$ sudo ipsec status
ipsec restart

VPN / トンネリング で ipsec restart を実務運用で使う

Example
$ sudo ipsec restart
ipsec up

VPN / トンネリング で ipsec up を実務運用で使う

Example
$ sudo ipsec up site-to-site
ipsec down

VPN / トンネリング で ipsec down を実務運用で使う

Example
$ sudo ipsec down site-to-site
swanctl --list-sas

VPN / トンネリング で swanctl --list-sas を実務運用で使う

Example
$ sudo swanctl --list-sas
swanctl --initiate

VPN / トンネリング で swanctl --initiate を実務運用で使う

Example
$ sudo swanctl --initiate --child net-net
swanctl --terminate

VPN / トンネリング で swanctl --terminate を実務運用で使う

Example
$ sudo swanctl --terminate --ike site-to-site
ipsec.conf conn psk

VPN / トンネリング で ipsec.conf conn psk を実務運用で使う

Example
conn site-to-site keyexchange=ikev2 authby=psk left=203.0.113.10 right=198.51.100.10 auto=start
ipsec.secrets psk

VPN / トンネリング で ipsec.secrets psk を実務運用で使う

Example
203.0.113.10 198.51.100.10 : PSK "S3cretKey"
ipsec.conf cert

VPN / トンネリング で ipsec.conf cert を実務運用で使う

Example
conn cert-vpn keyexchange=ikev2 leftcert=gwCert.pem rightauth=pubkey auto=add
journalctl strongswan

VPN / トンネリング で journalctl strongswan を実務運用で使う

Example
$ journalctl -u strongswan -f
tcpdump ike esp

VPN / トンネリング で tcpdump ike esp を実務運用で使う

Example
$ sudo tcpdump -ni eth0 "udp port 500 or udp port 4500 or proto 50"
easy-rsa init-pki

VPN / トンネリング で easy-rsa init-pki を実務運用で使う

Example
$ ./easyrsa init-pki
easy-rsa build-ca

VPN / トンネリング で easy-rsa build-ca を実務運用で使う

Example
$ ./easyrsa build-ca
easy-rsa build-server-full

VPN / トンネリング で easy-rsa build-server-full を実務運用で使う

Example
$ ./easyrsa build-server-full server nopass
easy-rsa build-client-full

VPN / トンネリング で easy-rsa build-client-full を実務運用で使う

Example
$ ./easyrsa build-client-full client1 nopass
openvpn server config

VPN / トンネリング で openvpn server config を実務運用で使う

Example
port 1194 proto udp dev tun server 10.8.0.0 255.255.255.0
openvpn client config

VPN / トンネリング で openvpn client config を実務運用で使う

Example
client dev tun proto udp remote vpn.example.com 1194
openvpn --config

VPN / トンネリング で openvpn --config を実務運用で使う

Example
$ sudo openvpn --config /etc/openvpn/server.conf
openvpn --status

VPN / トンネリング で openvpn --status を実務運用で使う

Example
$ sudo openvpn --status /run/openvpn/status.log 10
openvpn mute replay

VPN / トンネリング で openvpn mute replay を実務運用で使う

Example
$ sudo openvpn --config client.ovpn --mute-replay-warnings
systemctl openvpn

VPN / トンネリング で systemctl openvpn を実務運用で使う

Example
$ sudo systemctl restart openvpn-server@server
tun vs tap

VPN / トンネリング で tun vs tap を実務運用で使う

Example
dev tun は L3 ルーティング、dev tap は L2 ブリッジ用途で使う
対応ツール
Related