vpn-setup – skill DevOps & Hạ tầng cho agent AI
Cấu hình WireGuard, OpenVPN và VPN đám mây. Triển khai truy cập từ xa an toàn và kết nối site-to-site. Dùng khi thiết lập đường hầm mạng an toàn.
Cài skill vpn-setup bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/vpn-setup-d5e7d.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /vpn-setup – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/vpn-setup-d5e7d.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $vpn-setup – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/vpn-setup-d5e7d.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /vpn-setup – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/vpn-setup-d5e7d.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /vpn-setup – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
VPN Setup
Configure secure VPN tunnels for remote access and site connectivity.
When to Use This Skill
Use this skill when:
- Setting up secure remote access for employees or contractors
- Connecting on-premises networks to cloud environments (site-to-site)
- Encrypting traffic between data centers or regions
- Implementing a mesh VPN for distributed infrastructure
- Providing secure access to internal services without exposing them publicly
Confirm routing/subnet overlap, client reachability, management fallback and maintenance scope before changing tunnels/firewalls. Full-tunnel IPv4 does not provide IPv6 or DNS leak protection automatically. The WireGuard server DNS line does not push DNS to peers: configure an actual reachable resolver in each client. Peer script is illustrative and needs serialized allocation, symlink-safe storage, per-peer PSKs and rollback before production. QR codes contain private keys: never log or share them publicly. Protect CA keys offline and prefer passphrase protection; nopass examples are not a production CA policy.
Prerequisites
- Linux server with a public IP for VPN endpoint
- Root/sudo access on the VPN server
- Firewall rules allowing VPN traffic (UDP 51820 for WireGuard, UDP 1194 for OpenVPN)
- DNS configured for VPN hostname (optional but recommended)
- Understanding of IP subnetting and routing
WireGuard
Server Setup
# Install WireGuard (Ubuntu/Debian)
apt update && apt install -y wireguard
# Generate server keys
umask 077
wg genkey | tee /etc/wireguard/server_private.key | wg pubkey > /etc/wireguard/server_public.key
chmod 600 /etc/wireguard/server_private.key
# Generate pre-shared key (optional, adds post-quantum resistance)
wg genpsk > /etc/wireguard/psk.key
chmod 600 /etc/wireguard/psk.keyServer Configuration
# /etc/wireguard/wg0.conf
[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = <server-private-key>
# Enable IP forwarding and NAT on startup
PostUp = sysctl -w net.ipv4.ip_forward=1
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT
PostUp = iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
# DNS for clients
DNS = 10.0.0.1
# Peer: Alice (laptop)
[Peer]
PublicKey = <alice-public-key>
PresharedKey = <preshared-key>
AllowedIPs = 10.0.0.2/32
# Peer: Bob (mobile)
[Peer]
PublicKey = <bob-public-key>
PresharedKey = <preshared-key>
AllowedIPs = 10.0.0.3/32
# Peer: Office network (site-to-site)
[Peer]
PublicKey = <office-public-key>
PresharedKey = <preshared-key>
AllowedIPs = 10.0.0.4/32, 192.168.1.0/24
Endpoint = office.example.com:51820
PersistentKeepalive = 25Client Configuration
# Client config: alice.conf
[Interface]
Address = 10.0.0.2/24
PrivateKey = <alice-private-key>
DNS = 10.0.0.1
[Peer]
PublicKey = <server-public-key>
PresharedKey = <preshared-key>
Endpoint = vpn.example.com:51820
AllowedIPs = 0.0.0.0/0
# IPv6 requires separately configured tunnel addressing/forwarding and leak tests.
PersistentKeepalive = 25Split Tunneling Configuration
# Client config with split tunnel (only route internal traffic through VPN)
[Interface]
Address = 10.0.0.2/24
PrivateKey = <alice-private-key>
# No DNS override for split tunnel
[Peer]
PublicKey = <server-public-key>
PresharedKey = <preshared-key>
Endpoint = vpn.example.com:51820
# Only route specific subnets through VPN
AllowedIPs = 10.0.0.0/24, 172.16.0.0/16, 192.168.1.0/24
PersistentKeepalive = 25WireGuard Management Commands
# Start/stop interface
wg-quick up wg0
wg-quick down wg0
# Enable on boot
systemctl enable wg-quick@wg0
# Show connection status
wg show
wg show wg0
# Add a new peer dynamically
wg set wg0 peer <new-public-key> allowed-ips 10.0.0.5/32
# Remove a peer
wg set wg0 peer <public-key> remove
# Show transfer statistics
wg show wg0 transfer
# Generate QR code for mobile clients
apt install -y qrencode
qrencode -t ansiutf8 < alice-mobile.confPeer Management Script
#!/bin/bash
# wg-add-peer.sh - Add a new WireGuard peer
set -euo pipefail
umask 077
PEER_NAME="${1:?Usage: $0 <peer-name>}"
[[ "$PEER_NAME" =~ ^[a-z0-9]+(-[a-z0-9]+)*$ ]] || exit 1
SERVER_CONF="/etc/wireguard/wg0.conf"
CLIENTS_DIR="/etc/wireguard/clients"
SERVER_PUBKEY=$(cat /etc/wireguard/server_public.key)
SERVER_ENDPOINT="vpn.example.com:51820"
PSK=$(cat /etc/wireguard/psk.key)
# Find next available IP
LAST_IP=$(grep -oP 'AllowedIPs = 10\.0\.0\.\K[0-9]+' "$SERVER_CONF" | sort -n | tail -1)
NEXT_IP=$((LAST_IP + 1))
[[ "$NEXT_IP" -ge 2 && "$NEXT_IP" -le 254 ]] || { echo "Address pool exhausted"; exit 1; }
mkdir -p "$CLIENTS_DIR"
[[ ! -e "$CLIENTS_DIR/${PEER_NAME}.conf" ]] || { echo "Peer exists"; exit 1; }
# Generate client keys
wg genkey | tee "$CLIENTS_DIR/${PEER_NAME}_private.key" | wg pubkey > "$CLIENTS_DIR/${PEER_NAME}_public.key"
chmod 600 "$CLIENTS_DIR/${PEER_NAME}_private.key"
CLIENT_PRIVKEY=$(cat "$CLIENTS_DIR/${PEER_NAME}_private.key")
CLIENT_PUBKEY=$(cat "$CLIENTS_DIR/${PEER_NAME}_public.key")
# Add peer to server config
cat >> "$SERVER_CONF" << EOF
# Peer: ${PEER_NAME}
[Peer]
PublicKey = ${CLIENT_PUBKEY}
PresharedKey = ${PSK}
AllowedIPs = 10.0.0.${NEXT_IP}/32
EOF
# Generate client config
cat > "$CLIENTS_DIR/${PEER_NAME}.conf" << EOF
[Interface]
Address = 10.0.0.${NEXT_IP}/24
PrivateKey = ${CLIENT_PRIVKEY}
DNS = 10.0.0.1
[Peer]
PublicKey = ${SERVER_PUBKEY}
PresharedKey = ${PSK}
Endpoint = ${SERVER_ENDPOINT}
AllowedIPs = 0.0.0.0/0
# IPv6 requires separately configured tunnel addressing/forwarding and leak tests.
PersistentKeepalive = 25
EOF
# Reload WireGuard
wg syncconf wg0 <(wg-quick strip wg0)
echo "Peer ${PEER_NAME} added with IP 10.0.0.${NEXT_IP}"
echo "Client config: ${CLIENTS_DIR}/${PEER_NAME}.conf"OpenVPN
Server Setup
# Install OpenVPN and Easy-RSA
apt install -y openvpn easy-rsa
# Initialize PKI
make-cadir /etc/openvpn/easy-rsa
cd /etc/openvpn/easy-rsa
./easyrsa init-pki
./easyrsa build-ca nopass
./easyrsa gen-req server nopass
./easyrsa sign-req server server
./easyrsa gen-dh
openvpn --genkey secret /etc/openvpn/ta.key
# Generate client certificate
./easyrsa gen-req client1 nopass
./easyrsa sign-req client client1Server Configuration
# /etc/openvpn/server.conf
port 1194
proto udp
dev tun
ca /etc/openvpn/easy-rsa/pki/ca.crt
cert /etc/openvpn/easy-rsa/pki/issued/server.crt
key /etc/openvpn/easy-rsa/pki/private/server.key
dh /etc/openvpn/easy-rsa/pki/dh.pem
tls-auth /etc/openvpn/ta.key 0
server 10.8.0.0 255.255.255.0
# Route client traffic through VPN
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
# Split tunnel: push specific routes instead
# push "route 172.16.0.0 255.255.0.0"
# push "route 192.168.1.0 255.255.255.0"
keepalive 10 120
# Cipher and auth
cipher AES-256-GCM
auth SHA256
data-ciphers AES-256-GCM:AES-128-GCM:CHACHA20-POLY1305
# Hardening
tls-version-min 1.2
tls-cipher TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384
user nobody
group nogroup
persist-key
persist-tun
# Logging
status /var/log/openvpn/status.log
log-append /var/log/openvpn/openvpn.log
verb 3
# Max clients
max-clients 100
# Omit client-to-client; enforce peer isolation with verified firewall policy.Client Configuration
# client1.ovpn
client
dev tun
proto udp
remote vpn.example.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client1.crt
key client1.key
tls-auth ta.key 1
cipher AES-256-GCM
auth SHA256
verb 3Tailscale (Managed WireGuard)
# Install Tailscale
tmpdir="$(mktemp -d)"
curl -fsSL https://tailscale.com/install.sh -o "$tmpdir/install.sh"
cat "$tmpdir/install.sh" # inspect complete script before executing
sh "$tmpdir/install.sh"
rm -rf "$tmpdir"
# Authenticate and connect
tailscale up
# Advertise subnet routes (act as a gateway)
tailscale up --advertise-routes=192.168.1.0/24,172.16.0.0/16
# Enable as exit node (route all traffic)
tailscale up --advertise-exit-node
# Use an exit node
tailscale up --exit-node=<exit-node-ip>
# Check status
tailscale status
# Access control: tailscale ACL policy (in admin console)
# Example ACL policy
cat << 'EOF'
{
"acls": [
{"action": "accept", "src": ["group:engineering"], "dst": ["tag:servers:*"]},
{"action": "accept", "src": ["group:devops"], "dst": ["*:*"]},
{"action": "accept", "src": ["tag:monitoring"], "dst": ["tag:servers:9100"]}
],
"tagOwners": {
"tag:servers": ["group:devops"],
"tag:monitoring": ["group:devops"]
},
"groups": {
"group:engineering": ["[email protected]", "[email protected]"],
"group:devops": ["[email protected]"]
}
}
EOF
# Enable MagicDNS and set DNS
tailscale up --accept-dns
# SSH via Tailscale (no SSH keys needed)
tailscale up --sshAWS Site-to-Site VPN
# Create Virtual Private Gateway
VGW_ID=$(aws ec2 create-vpn-ga… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- windows-server – Quản trị hệ thống Windows Server. Quản lý IIS, Active Directory và tự động hóa bằng…
- actual-setup – Thiết lập suy luận Actual Computer (actual.inc) trong Hermes.
- asn-infrastructure-mapping – Lập bản đồ hạ tầng IP của tổ chức qua ASN, CIDR, mở rộng TLD và reverse DNS.
- cloudflare-deploy – Triển khai ứng dụng và hạ tầng lên Cloudflare bằng Workers, Pages và các dịch vụ nền…
- aegisops-ai – Rào chắn tự động cho DevSecOps & FinOps. Hướng dẫn rà soát bản vá kernel Linux, thay đổi…
- cloud-iam-deep – Khai thác lỗ hổng trên cloud GCP/AWS/Azure -- Cloud Functions, Firestore, Cloud Run, S3…
- backtesting-frameworks – Xây dựng hệ thống backtest vững chắc cho chiến lược giao dịch, xử lý đúng look-ahead…
- docker-privesc – Thoát khỏi container Docker để giành quyền root trên host qua 5 kỹ thuật.