Ubuntu 24.04 serverでは、ネットワーク管理ツールとしてnetplanがデフォルトとなっており、ネットワークを管理するためにyamlファイルを編集する必要があります。
個人的には、GUIライクに設定できるnmtui(NetworkManager)
が使いたいので、ネットワーク管理ツールをNetwork Managerに移行する手順を記録しておきます。
移行方法
1. yamlファイルの編集
以下のファイルを管理者権限で開きます。
sudo nano /etc/netplan/50-cloud-init.yaml
デフォルトでは、こんな感じになっているはずです(あくまで一例です)
/etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
enp1s0:
dhcp4: true
version: 2
これを、以下のように書き換えます。
/etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
version: 2
renderer: NetworkManager
書き換え終わったら保存して終了してください。
2. 設定の適用
設定ファイルを編集しただけでは、netplan
の設定は書き換わりません。
以下のコマンドを入力して設定を反映してください。
sudo netplan apply
SSH接続等でリモート接続して作業している場合は、ネットワーク接続が失われてターミナルがフリーズすることがあります。
この場合は、一度ウィンドウを閉じて再度SSH接続し直してください。
以上で終了です。お疲れ様でした。