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 genkeyVPN / トンネリング で wg genkey を実務運用で使う
$ wg genkey | tee privatekey | wg pubkey > publickeywg showVPN / トンネリング で wg show を実務運用で使う
$ sudo wg showwg-quick upVPN / トンネリング で wg-quick up を実務運用で使う
$ sudo wg-quick up wg0wg-quick downVPN / トンネリング で wg-quick down を実務運用で使う
$ sudo wg-quick down wg0wg set peerVPN / トンネリング で wg set peer を実務運用で使う
$ sudo wg set wg0 peer AbCd... allowed-ips 10.10.10.2/32wg set listen-portVPN / トンネリング で wg set listen-port を実務運用で使う
$ sudo wg set wg0 listen-port 51820wg syncconfVPN / トンネリング で wg syncconf を実務運用で使う
$ sudo wg syncconf wg0 <(wg-quick strip wg0)WireGuard InterfaceVPN / トンネリング で WireGuard Interface を実務運用で使う
[Interface]
Address = 10.10.10.1/24
PrivateKey = <privatekey>
ListenPort = 51820WireGuard PeerVPN / トンネリング で WireGuard Peer を実務運用で使う
[Peer]
PublicKey = <peer-publickey>
AllowedIPs = 10.10.10.2/32
Endpoint = 203.0.113.10:51820AllowedIPs routeVPN / トンネリング で AllowedIPs route を実務運用で使う
AllowedIPs = 10.0.0.0/8, 192.168.0.0/16PersistentKeepaliveVPN / トンネリング で PersistentKeepalive を実務運用で使う
PersistentKeepalive = 25Roaming peerVPN / トンネリング で Roaming peer を実務運用で使う
$ sudo wg show wg0 endpointsipsec statusVPN / トンネリング で ipsec status を実務運用で使う
$ sudo ipsec statusipsec restartVPN / トンネリング で ipsec restart を実務運用で使う
$ sudo ipsec restartipsec upVPN / トンネリング で ipsec up を実務運用で使う
$ sudo ipsec up site-to-siteipsec downVPN / トンネリング で ipsec down を実務運用で使う
$ sudo ipsec down site-to-siteswanctl --list-sasVPN / トンネリング で swanctl --list-sas を実務運用で使う
$ sudo swanctl --list-sasswanctl --initiateVPN / トンネリング で swanctl --initiate を実務運用で使う
$ sudo swanctl --initiate --child net-netswanctl --terminateVPN / トンネリング で swanctl --terminate を実務運用で使う
$ sudo swanctl --terminate --ike site-to-siteipsec.conf conn pskVPN / トンネリング で ipsec.conf conn psk を実務運用で使う
conn site-to-site
keyexchange=ikev2
authby=psk
left=203.0.113.10
right=198.51.100.10
auto=startipsec.secrets pskVPN / トンネリング で ipsec.secrets psk を実務運用で使う
203.0.113.10 198.51.100.10 : PSK "S3cretKey"ipsec.conf certVPN / トンネリング で ipsec.conf cert を実務運用で使う
conn cert-vpn
keyexchange=ikev2
leftcert=gwCert.pem
rightauth=pubkey
auto=addjournalctl strongswanVPN / トンネリング で journalctl strongswan を実務運用で使う
$ journalctl -u strongswan -ftcpdump ike espVPN / トンネリング で tcpdump ike esp を実務運用で使う
$ sudo tcpdump -ni eth0 "udp port 500 or udp port 4500 or proto 50"easy-rsa init-pkiVPN / トンネリング で easy-rsa init-pki を実務運用で使う
$ ./easyrsa init-pkieasy-rsa build-caVPN / トンネリング で easy-rsa build-ca を実務運用で使う
$ ./easyrsa build-caeasy-rsa build-server-fullVPN / トンネリング で easy-rsa build-server-full を実務運用で使う
$ ./easyrsa build-server-full server nopasseasy-rsa build-client-fullVPN / トンネリング で easy-rsa build-client-full を実務運用で使う
$ ./easyrsa build-client-full client1 nopassopenvpn server configVPN / トンネリング で openvpn server config を実務運用で使う
port 1194
proto udp
dev tun
server 10.8.0.0 255.255.255.0openvpn client configVPN / トンネリング で openvpn client config を実務運用で使う
client
dev tun
proto udp
remote vpn.example.com 1194openvpn --configVPN / トンネリング で openvpn --config を実務運用で使う
$ sudo openvpn --config /etc/openvpn/server.confopenvpn --statusVPN / トンネリング で openvpn --status を実務運用で使う
$ sudo openvpn --status /run/openvpn/status.log 10openvpn mute replayVPN / トンネリング で openvpn mute replay を実務運用で使う
$ sudo openvpn --config client.ovpn --mute-replay-warningssystemctl openvpnVPN / トンネリング で systemctl openvpn を実務運用で使う
$ sudo systemctl restart openvpn-server@servertun vs tapVPN / トンネリング で tun vs tap を実務運用で使う
dev tun は L3 ルーティング、dev tap は L2 ブリッジ用途で使う| Command | Description | Example | Copy |
|---|---|---|---|
wg genkey | VPN / トンネリング で wg genkey を実務運用で使う | $ wg genkey | tee privatekey | wg pubkey > publickey | |
wg show | VPN / トンネリング で wg show を実務運用で使う | $ sudo wg show | |
wg-quick up | VPN / トンネリング で wg-quick up を実務運用で使う | $ sudo wg-quick up wg0 | |
wg-quick down | VPN / トンネリング で wg-quick down を実務運用で使う | $ sudo wg-quick down wg0 | |
wg set peer | VPN / トンネリング で wg set peer を実務運用で使う | $ sudo wg set wg0 peer AbCd... allowed-ips 10.10.10.2/32 | |
wg set listen-port | VPN / トンネリング で wg set listen-port を実務運用で使う | $ sudo wg set wg0 listen-port 51820 | |
wg syncconf | VPN / トンネリング で wg syncconf を実務運用で使う | $ sudo wg syncconf wg0 <(wg-quick strip wg0) | |
WireGuard Interface | VPN / トンネリング で WireGuard Interface を実務運用で使う | [Interface]
Address = 10.10.10.1/24
PrivateKey = <privatekey>
ListenPort = 51820 | |
WireGuard Peer | VPN / トンネリング で WireGuard Peer を実務運用で使う | [Peer]
PublicKey = <peer-publickey>
AllowedIPs = 10.10.10.2/32
Endpoint = 203.0.113.10:51820 | |
AllowedIPs route | VPN / トンネリング で AllowedIPs route を実務運用で使う | AllowedIPs = 10.0.0.0/8, 192.168.0.0/16 | |
PersistentKeepalive | VPN / トンネリング で PersistentKeepalive を実務運用で使う | PersistentKeepalive = 25 | |
Roaming peer | VPN / トンネリング で Roaming peer を実務運用で使う | $ sudo wg show wg0 endpoints | |
ipsec status | VPN / トンネリング で ipsec status を実務運用で使う | $ sudo ipsec status | |
ipsec restart | VPN / トンネリング で ipsec restart を実務運用で使う | $ sudo ipsec restart | |
ipsec up | VPN / トンネリング で ipsec up を実務運用で使う | $ sudo ipsec up site-to-site | |
ipsec down | VPN / トンネリング で ipsec down を実務運用で使う | $ sudo ipsec down site-to-site | |
swanctl --list-sas | VPN / トンネリング で swanctl --list-sas を実務運用で使う | $ sudo swanctl --list-sas | |
swanctl --initiate | VPN / トンネリング で swanctl --initiate を実務運用で使う | $ sudo swanctl --initiate --child net-net | |
swanctl --terminate | VPN / トンネリング で swanctl --terminate を実務運用で使う | $ sudo swanctl --terminate --ike site-to-site | |
ipsec.conf conn psk | VPN / トンネリング で ipsec.conf conn psk を実務運用で使う | 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 を実務運用で使う | 203.0.113.10 198.51.100.10 : PSK "S3cretKey" | |
ipsec.conf cert | VPN / トンネリング で ipsec.conf cert を実務運用で使う | conn cert-vpn
keyexchange=ikev2
leftcert=gwCert.pem
rightauth=pubkey
auto=add | |
journalctl strongswan | VPN / トンネリング で journalctl strongswan を実務運用で使う | $ journalctl -u strongswan -f | |
tcpdump ike esp | VPN / トンネリング で tcpdump ike esp を実務運用で使う | $ sudo tcpdump -ni eth0 "udp port 500 or udp port 4500 or proto 50" | |
easy-rsa init-pki | VPN / トンネリング で easy-rsa init-pki を実務運用で使う | $ ./easyrsa init-pki | |
easy-rsa build-ca | VPN / トンネリング で easy-rsa build-ca を実務運用で使う | $ ./easyrsa build-ca | |
easy-rsa build-server-full | VPN / トンネリング で easy-rsa build-server-full を実務運用で使う | $ ./easyrsa build-server-full server nopass | |
easy-rsa build-client-full | VPN / トンネリング で easy-rsa build-client-full を実務運用で使う | $ ./easyrsa build-client-full client1 nopass | |
openvpn server config | VPN / トンネリング で openvpn server config を実務運用で使う | port 1194
proto udp
dev tun
server 10.8.0.0 255.255.255.0 | |
openvpn client config | VPN / トンネリング で openvpn client config を実務運用で使う | client
dev tun
proto udp
remote vpn.example.com 1194 | |
openvpn --config | VPN / トンネリング で openvpn --config を実務運用で使う | $ sudo openvpn --config /etc/openvpn/server.conf | |
openvpn --status | VPN / トンネリング で openvpn --status を実務運用で使う | $ sudo openvpn --status /run/openvpn/status.log 10 | |
openvpn mute replay | VPN / トンネリング で openvpn mute replay を実務運用で使う | $ sudo openvpn --config client.ovpn --mute-replay-warnings | |
systemctl openvpn | VPN / トンネリング で systemctl openvpn を実務運用で使う | $ sudo systemctl restart openvpn-server@server | |
tun vs tap | VPN / トンネリング で tun vs tap を実務運用で使う | dev tun は L3 ルーティング、dev tap は L2 ブリッジ用途で使う |