さくらのクラウドで netplan の警告を消す

2026-11-13 with Claude Code linux

さくらが作る 01-netcfg.yaml は権限が 644 で、gateway4 を使っているため、netplan apply で警告が出ます。

** (configure:6532): WARNING **: 07:17:18.475: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

** (process:6530): WARNING **: 07:17:18.864: Permissions for /etc/netplan/01-netcfg.yaml are too open. Netplan configuration should NOT be accessible by others.

** (process:6530): WARNING **: 07:17:18.865: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

** (process:6530): WARNING **: 07:17:19.366: Permissions for /etc/netplan/01-netcfg.yaml are too open. Netplan configuration should NOT be accessible by others.

** (process:6530): WARNING **: 07:17:19.367: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

動作には影響しませんが、次のように直します。eth0 なので、書き間違えると SSH で入れなくなります。 netplan try で確かめ、Enter を押さなければ 120 秒で元に戻ります。

chmod 600 /etc/netplan/01-netcfg.yaml
cp -p /etc/netplan/01-netcfg.yaml ~/01-netcfg.yaml.orig
sed -i 's/^      gateway4: \(.*\)$/      routes:\n        - to: default\n          via: \1/' /etc/netplan/01-netcfg.yaml
cat /etc/netplan/01-netcfg.yaml
netplan try