NetworkManagerの永続設定と通信の切り分け1 / 3
接続profileと稼働中のinterface
NetworkManagerはconnection profileにaddressやDNSなどを保存し、deviceへ適用する。device名とprofile名は一致するとは限らない。次の例はens3用の固定IPv4 profileを作り、適用する。管理に使っているinterfaceの変更は接続も切り得る。
nmcli device status
nmcli connection show
nmcli connection add type ethernet ifname ens3 con-name office ipv4.method manual ipv4.addresses 192.0.2.10/24 ipv4.gateway 192.0.2.1 ipv4.dns 192.0.2.53
nmcli connection up office
nmcli connection show office
既存のoffice profileでDNSの指定を変更する例である。
nmcli connection modify office ipv4.dns 192.0.2.54
保存した値と現在のdeviceへの適用状態は別に調べる。DHCPでaddressを得る基本の指定はipv4.method autoである。
Wi-FiのSSIDなどを一覧にする指定である。
nmcli device wifi list
認証情報を対話入力し、OfficeNetへ接続する例である。
nmcli --ask device wifi connect OfficeNet
SSIDだけで暗号方式や正しいnetworkを決めない。無線のradio、認証、association、address取得の段階を分ける。
host名をdesk01へ設定する例である。
hostnamectl set-hostname desk01
DNS serverへA recordを登録する操作ではない。/etc/hostnameはlocal名、/etc/hostsはlocalのaddress対応を扱う。
systemd-networkdは別のnetwork管理方式で、.network fileなどへMatchとNetworkの設定を置く。同じinterfaceを複数の管理daemonで競合して変更しない。ifup/ifdownの操作と保存先はdistributionの設定方式に従う。