VPN-TUNNELING35 cmd
VPN / トンネリング (WireGuard / IPsec / OpenVPN) チート集
WireGuard、strongSwan IPsec、OpenVPN の鍵生成、最小設定、起動停止、SA 確認、AllowedIPs、IKEv2 PSK/cert、easy-rsa、tun/tap の使い分けをまとめたチート集。
- 更新日
- 2026-05-14
- 参照範囲
- 公式ドキュメント / man page / 主要ベンダーCLI
- 対象実装
- 主要 Linux / BSD / ネットワーク機器 CLI の一般的な実装
- 免責
- OS とバージョン差分は実環境で確認してください。
35 / 35
| 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 ブリッジ用途で使う |