0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【2023年9月版】nmcliメモ

Posted at

nmcli メモ

接続の設定等

接続状態の表示

nmcli connection / nmcli c

$ nmcli c
NAME    UUID                                  TYPE      DEVICE 
ens224  807d4e2c-f4da-35e5-81c8-e797aa4812b8  ethernet  ens224 
ens192  e59c7155-cb67-3d26-a760-8c6f9c9bf974  ethernet  ens192 
lo      bdb0572e-6702-4f48-9645-edde7a57ed06  loopback  lo     

切断

nmcli connection down / nmcli c d

$ nmcli c down ens192
Connection 'ens192' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
$ nmcli c
NAME    UUID                                  TYPE      DEVICE 
ens224  807d4e2c-f4da-35e5-81c8-e797aa4812b8  ethernet  ens224 
lo      bdb0572e-6702-4f48-9645-edde7a57ed06  loopback  lo     
ens192  e59c7155-cb67-3d26-a760-8c6f9c9bf974  ethernet  --     

接続

nmcli connecton up / nmcli c u

$ nmcli c up ens192
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
$ nmcli c
NAME    UUID                                  TYPE      DEVICE 
ens224  807d4e2c-f4da-35e5-81c8-e797aa4812b8  ethernet  ens224 
lo      bdb0572e-6702-4f48-9645-edde7a57ed06  loopback  lo     
ens192  e59c7155-cb67-3d26-a760-8c6f9c9bf974  ethernet  ens192 

IPアドレスの変更

nmcli connection modify / nmcli c m

$ nmcli c m ens192 ipv4.addresses 10.0.0.100/24

接続状態の詳細表示

ページャーで表示される

$ nmcli c sh ens192
connection.id:                          ens192
connection.uuid:                        e59c7155-cb67-3d26-a760-8c6f9c9bf974
connection.stable-id:                   --
connection.type:                        802-3-ethernet
connection.interface-name:              ens192
  :
  :
ipv4.method:                            manual
ipv4.dns:                               8.8.8.8,1.1.1.1
ipv4.dns-search:                        --
ipv4.dns-options:                       --
ipv4.dns-priority:                      0
ipv4.addresses:                         192.168.0.100/24
ipv4.gateway:                           192.168.0.254
ipv4.routes:                            --
  :
  :
IP4.ADDRESS[1]:                         192.168.0.100/24
IP4.GATEWAY:                            192.168.0.254
IP4.ROUTE[1]:                           dst = 192.168.0.0/24, nh = 0.0.0.0, mt = 101
IP4.ROUTE[2]:                           dst = 0.0.0.0/0, nh = 192.168.0.254, mt = 101
IP4.DNS[1]:                             8.8.8.8
IP4.DNS[2]:                             1.1.1.1
  :
  :

削除してしまった接続の再作成

nmcli d でデバイス名は参照できる
または、削除してしまった名前を使う
再作成できるが、UUID や firewalld のゾーンが変わっていることがあるので注意

$ nmcli c delete ens192
Connection 'ens192' (e59c7155-cb67-3d26-a760-8c6f9c9bf974) successfully deleted.
$ nmcli c
NAME    UUID                                  TYPE      DEVICE 
ens224  807d4e2c-f4da-35e5-81c8-e797aa4812b8  ethernet  ens224 
lo      bdb0572e-6702-4f48-9645-edde7a57ed06  loopback  lo     
$ nmcli d
DEVICE  TYPE      STATE                   CONNECTION 
ens224  ethernet  connected               ens224     
lo      loopback  connected (externally)  lo         
ens192  ethernet  disconnected            --     
$ nmcli connection add type ethernet con-name ens192 ifname ens192
Connection 'ens192' (d5a043f4-11e1-49df-b649-c30621c30791) successfully added.
$ nmcli connection modify ens192 ipv4.addresses "192.168.0.100/24" ipv4.method manual
$ connection up ens192
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/10)
$ nmcli c
NAME    UUID                                  TYPE      DEVICE 
ens224  807d4e2c-f4da-35e5-81c8-e797aa4812b8  ethernet  ens224 
ens192  d5a043f4-11e1-49df-b649-c30621c30791  ethernet  ens192 
lo      58ed4623-1f77-485a-9033-92ba771d53f7  loopback  lo     

接続設定の編集

nmcli connection reload / nmcli c r

/etc/NetworkManager/system-connections 配下のファイルを修正する
接続設定を再読込する

$ ls /etc/NetworkManager/system-connections/
ens192.nmconnection  ens224.nmconnection
$ cat /etc/NetworkManager/system-connections/ens224.nmconnection 
[connection]
id=ens192
uuid=d5a043f4-11e1-49df-b649-c30621c30791
type=ethernet
autoconnect-priority=-999
interface-name=ens192
timestamp=1693484400
zone=external

[ethernet]

[ipv4]
address1=192.168.0.100/24,192.168.0.254
dns=8.8.8.8;1.1.1.1;
method=manual

[ipv6]
addr-gen-mode=eui64
method=disabled

[proxy]
$ vim /etc/NetworkManager/system-connections/ens224.nmconnection
$ nmcli c r ens192
$ nmcli c d ens192 && sudo nmcli c u ens192

デバイスの管理等

デバイス状態の表示

nmcli device / nmcli d

$ nmcli d
DEVICE  TYPE      STATE                   CONNECTION 
ens224  ethernet  connected               ens224     
ens192  ethernet  connected               ens192     
lo      loopback  connected (externally)  lo       

デバイス状態の詳細の表示

nmcli device show / nmcli d sh

$ nmcli d sh ens192
GENERAL.DEVICE:                         ens192
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:0C:29:12:DD:2F
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     ens192
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/5
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         192.168.0.100/24
IP4.GATEWAY:                            --
IP4.ROUTE[1]:                           dst = 192.168.0.254/24, nh = 0.0.0.0, mt = 100
IP6.GATEWAY:                            --

ホスト名の設定等

nmcli general / nmcli g

ホスト名取得

nmcli general hostname / nmcli g h

ホスト名設定

nmcli general hostname / nmcli g h

接続の有効化、無効化等

nmcli networking / nmcli n

WiFi, WWANの設定等

nmcli radio / nmcli r

nmcli agent / nmcli a

NetworkManager関連

nmcli monitor / nmcli m

ネットワークデバイス名

  • オンボードデバイス

eno1, eno2

  • PCIExpress

ens1, ens2

  • ハードウェアその他

ens2s1, ens2s2

  • MAC

enx78e3298a2c2

  • 従来

eth0, eth1

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?