diff options
| author | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-06-30 22:33:23 +0900 |
|---|---|---|
| committer | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-06-30 22:33:23 +0900 |
| commit | dd15de090cc70454f5039f8a1a9bb1d98358435b (patch) | |
| tree | bc3f1f130823f2ebe9c1db8a985d23bbfc68e406 /vpn | |
| parent | 58f7917662ff92a3712289acccff8310c8f1baff (diff) | |
Fix VPN entrypoint: handle sysctl read-only in host network mode
network_mode: host では /proc/sys への書き込みが制限されるため、
sysctl の失敗を無視してホスト側の設定値を確認するよう変更。
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'vpn')
| -rw-r--r-- | vpn/entrypoint.sh | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/vpn/entrypoint.sh b/vpn/entrypoint.sh index 4efe500..00e3131 100644 --- a/vpn/entrypoint.sh +++ b/vpn/entrypoint.sh @@ -1,9 +1,13 @@ #!/bin/sh set -e -# IP フォワーディング有効化 -sysctl -w net.ipv4.ip_forward=1 -sysctl -w net.ipv6.conf.all.forwarding=1 +# IP フォワーディング有効化(network_mode: host では書き込み不可の場合があるのでエラー無視) +sysctl -w net.ipv4.ip_forward=1 2>/dev/null || true +sysctl -w net.ipv6.conf.all.forwarding=1 2>/dev/null || true +if [ "$(cat /proc/sys/net/ipv4/ip_forward)" != "1" ]; then + echo "ERROR: IP forwarding が無効。ホスト側で sysctl -w net.ipv4.ip_forward=1 を実行してください" + exit 1 +fi # VPN クライアントのトラフィックを MASQUERADE IFACE=$(ip route show default | awk '/default/ {print $5}' | head -1) |
