NMCLI を使用したネットワーク接続の設定


1. NetworkManager 接続プロファイルをリストします。

[root@falcon21 ~]# nmcli connection show
NAME       UUID                   TYPE    EVICE
プロファイル 1  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   ethernet  enp2s0
lo         xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  loopback   lo

デフォルトでは、NetworkManager はホスト内の各 NIC のプロファイルを作成します。
この NIC を特定のネットワークにのみ接続する予定がある場合は、自動作成されたプロファイルを
調整してください。
この NIC をさまざまな設定のネットワークに接続する予定がある場合は、 ネットワークごとに個別の
プロファイルを作成してください。
————————–

2. 追加の接続プロファイルを作成する場合は、次のように実行します。

[root@falcon21 ~]# nmcli connection add con-name ifname type ethernet
接続 ‘ifname‘ (cd5d213d-726f-45a0-a8b1-d7c9652d9795) が正常に追加されました。

  既存のプロファイルを変更するには、この手順をスキップしてください。
————————–

3. オプション: 接続プロファイルの名前を変更します。
    プロファイル 1 を Internal-LAN に変更
[root@falcon21 ~]# nmcli connection modify プロファイル 1” connection.id “Internal-LAN

ホストに複数のプロファイルがある場合は、わかりやすい名前を付けると、プロファイルの目 的を識別しやすくなります。
————————–

4. 接続プロファイルの現在の設定を表示します。
     デスクトップ ネットワーク設定で、ipv4 を固定、ipv6 を自動に指定

[root@falcon21 ~]# nmcli connection show Internal-LAN
connection.id: Internal-LAN
connection.uuid: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
connection.stable-id: —
connection.type: 802-3-ethernet
connection.interface-name: enp2s0

connection.wait-device-timeout: -1
connection.wait-activation-delay: -1
802-3-ethernet.port: —
802-3-ethernet.speed: 0

802-3-ethernet.wake-on-lan-password: —
802-3-ethernet.accept-all-mac-addresses:-1 (default)
ipv4.method: manual
ipv4.dns: 192.168.10.1
ipv4.dns-search: —
ipv4.dns-options: —
ipv4.dns-priority: 0
ipv4.addresses: 192.168.10.3/24
ipv4.gateway: 192.168.10.1
ipv4.routes: —

ipv4.dhcp-send-hostname: -1 (default)
ipv4.dhcp-hostname: —
ipv4.dhcp-fqdn: —

ipv4.shared-dhcp-lease-time: 0 (default)
ipv6.method: auto
ipv6.dns: —
ipv6.dns-search: —
ipv6.dns-options: —
ipv6.dns-priority: 0
ipv6.token: —
proxy.method: none
proxy.browser-only: いいえ
proxy.pac-url: —
proxy.pac-script: —
GENERAL.NAME: Internal-LAN
GENERAL.UUID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GENERAL.DEVICES: enp2s0
GENERAL.IP-IFACE: enp2s0
GENERAL.STATE: アクティベート済み
GENERAL.DEFAULT: はい

ipv6 を自動に指定すると、DNS サーバー構築でエラーとなるので、デスクトップ ネットワーク設定で 「無効」に指定

[root@falcon21 ~]# nmcli connection show Internal-LAN
connection.id: Internal-LAN
connection.uuid: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
connection.stable-id: --
connection.type: 802-3-ethernet

802-3-ethernet.mtu: 自動
802-3-ethernet.s390-subchannels: --
802-3-ethernet.s390-nettype: --
802-3-ethernet.s390-options: --
802-3-ethernet.wake-on-lan: default
802-3-ethernet.wake-on-lan-password: --
802-3-ethernet.accept-all-mac-addresses:-1 (default)
ipv4.method: manual
ipv4.dns: 192.168.10.1
ipv4.dns-search: falcon21.space
ipv4.dns-options: --
ipv4.dns-priority: 0
ipv4.addresses: 192.168.10.3/24
ipv4.gateway: 192.168.10.1
ipv4.routes: --
ipv4.route-metric: -1

IP4.ADDRESS[1]: 192.168.10.3/24
IP4.GATEWAY: 192.168.10.1
IP4.ROUTE[1]: dst = 0.0.0.0/0, nh = 192.168.10.1, mt = 100
IP4.ROUTE[2]: dst = 192.168.10.0/24, nh = 0.0.0.0, mt = 100
IP4.DNS[1]: 192.168.10.1
IP4.SEARCHES[1]: falcon21.space

IP6.GATEWAY: --

————————–

5. IPv4 を設定します。   IPv4 を固定設定にしたので、これはスキップ

DHCP を使用するには、次のように実行します。
[root@falcon21 ~]# nmcli connection modify Internal-LAN ipv4.method auto

ipv4.method がすでに auto (デフォルト) に設定されている場合は、この手順をスキップし てください。

———

静的 IPv4 アドレス、ネットワークマスク、デフォルトゲートウェイ、DNS サーバー、および検索ドメインを設定するには、次のように実行

[root@falcon21 ~]# nmcli connection modify Internal-LAN ipv4.method manual ipv4.addresses 192.168.10.3/24 ipv4.gateway 192.168.10.1 ipv4.dns 192.168.10.1 ipv4.dns-search falcon21.space


—————————



6. IPv6 設定を行います。IPv6は無効設定にしたので、スキップ

ステートレスアドレス自動設定 (SLAAC) を使用するには、次のように実行

[root@falcon21 ~]# nmcli connection modify Internal-LAN ipv6.method auto

ipv6.method がすでに auto (デフォルト) に設定されている場合は、この手順をスキップしてください。


———-

静的 IPv6 アドレス、ネットワークマスク、デフォルトゲートウェイ、DNS サーバー、お よび検索ドメインを設定するには、次のように実

[root@falcon21 ~]# nmcli connection modify Internal-LAN ipv6.method manual ipv6.addresses 2001:db8:1::fffe/64 ipv6.gateway 2001:db8:1::fffe ipv6.dns 2001:db8:1::ffbb ipv6.dns-search falcon21.space


——————–


7. プロファイルの他の設定をカスタマイズするには、次のコマンドを使用

nmcli connection modify connection-name setting value

値はスペースまたはセミコロンで引用符で囲みます。


——————–


8. プロファイルをアクティブ化

[root@falcon21 ~]# nmcli connection up Internal-LAN
接続が正常にアクティベートされました
(D-Bus アクティブパス: /org/freedesktop/NetworkManager/ActiveConnection/3)

————————-

[root@falcon21 ~]# reboot