nmcli

nmcliは、ネットワークの設定・変更をコマンドベースで行うコマンドです。
nmtuiは、テキスト形式のGUIで設定可能。

example of use

[root@centos7 ~]# nmcli

Ethernetデバイスの一覧を表示

[root@centos7 ~]# nmcli device
デバイス    タイプ    状態      接続
eth0        ethernet  接続済み  eth0

特定のインターフェースの詳細情報を表示(例:eth0)

[root@centos7 ~]# # nmcli device show eth0
GENERAL.デバイス:                       eth0
GENERAL.タイプ:                         ethernet
GENERAL.ハードウェアアドレス:           52:90:82:A2:F7:22
GENERAL.MTU:                            1500
GENERAL.状態:                           100 (接続済み)
GENERAL.接続:                           eth0
GENERAL.CON パス:                       /org/freedesktop/NetworkManager/ActiveConnection/0
WIRED-PROPERTIES.キャリア:              オン
IP4.アドレス[1]:                        192.168.1.11/24
IP4.ゲートウェイ:                       192.168.1.1
IP4.DNS[1]:                             192.168.1.1
IP6.アドレス[1]:                        fe80::5090:82ff:fea2:f722/64

EthernetデバイスのUUID情報を含めて表示

[root@centos7 ~]# nmcli connection
名前    UUID                                  タイプ          デバイス
eth0    6dbb9c72-2765-4573-b993-ad0a7c7ce8dd  802-3-ethernet  eth0

Ethernetデバイスの有効&無効化

[root@centos7 ~]# nmcli connection up eth0 ※有効化
[root@centos7 ~]# nmcli connection down eth0 ※無効化

より詳しい特定のインターフェースの詳細情報を表示(例:eth0)

[root@centos7 ~]# nmcli connection show eth0
connection.id:                          eth0
connection.uuid:                        6dbb9c72-2765-4573-b993-ad0a7c7ce8dd
connection.stable-id:                   --
connection.interface-name:              eth0
connection.type:                        802-3-ethernet
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
connection.timestamp:                   1493481992
connection.read-only:                   no
connection.permissions:
connection.zone:                        --
connection.master:                      --
connection.slave-type:                  --
connection.autoconnect-slaves:          -1 (default)
connection.secondaries:
connection.gateway-ping-timeout:        0
connection.metered:                     不明
connection.lldp:                        -1 (default)
802-3-ethernet.port:                    --
802-3-ethernet.speed:                   0
802-3-ethernet.duplex:                  --
802-3-ethernet.auto-negotiate:          yes
802-3-ethernet.mac-address:             --
802-3-ethernet.cloned-mac-address:      --
802-3-ethernet.generate-mac-address-mask:--
802-3-ethernet.mac-address-blacklist:
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:             1 (default)
802-3-ethernet.wake-on-lan-password:    --
ipv4.method:                            manual
ipv4.dns:                               192.168.100.1
ipv4.dns-search:                        domain.local
ipv4.dns-options:                       (デフォルト)
ipv4.dns-priority:                      0
ipv4.addresses:                         192.168.1.11/24
ipv4.gateway:                           192.168.1.1
ipv4.routes:
ipv4.route-metric:                      -1
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-timeout:                      0
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.dhcp-fqdn:                         --
ipv4.never-default:                     no
ipv4.may-fail:                          yes
ipv4.dad-timeout:                       -1 (default)
ipv6.method:                            ignore
ipv6.dns:
ipv6.dns-search:
ipv6.dns-options:                       (デフォルト)
ipv6.dns-priority:                      0
ipv6.addresses:
ipv6.gateway:                           --
ipv6.routes:
ipv6.route-metric:                      -1
ipv6.ignore-auto-routes:                no
ipv6.ignore-auto-dns:                   no
ipv6.never-default:                     no
ipv6.may-fail:                          yes
ipv6.ip6-privacy:                       -1 (不明)
ipv6.addr-gen-mode:                     stable-privacy
ipv6.dhcp-send-hostname:                yes
ipv6.dhcp-hostname:                     --
ipv6.token:                             --
GENERAL.名前:                           eth0
GENERAL.UUID:                           6dbb9c72-2765-4573-b993-ad0a7c7ce8dd
GENERAL.デバイス:                       eth0
GENERAL.状態:                           アクティベート済み
GENERAL.デフォルト:                     はい
GENERAL.デフォルト6:                    いいえ
GENERAL.VPN:                            いいえ
GENERAL.ゾーン:                         --
GENERAL.DBUS パス:                      /org/freedesktop/NetworkManager/ActiveConnection/0
GENERAL.CON パス:                       /org/freedesktop/NetworkManager/Settings/0
GENERAL.スペックオブジェクト:           /
GENERAL.マスターパス:                   --
IP4.アドレス[1]:                        192.168.1.11/24
IP4.ゲートウェイ:                       192.168.1.1
IP4.DNS[1]:                             192.168.1.117
IP6.アドレス[1]:                        fe80::5090:82ff:fea2:f722/64
IP6.ゲートウェイ:

IPv4アドレス固定化の設定

[root@centos7 ~]# nmcli c modify eth0 ipv4.addresses 192.168.1.110/24 

デフォルトゲートウェイの設定

[root@centos7 ~]# nmcli c modify eth0 ipv4.gateway 192.168.1.1

DNSの設定

[root@centos7 ~]# nmcli c modify eth0 ipv4.dns 192.168.1.1 

インターフェースを再起動後、設定を反映

[root@centos7 ~]# nmcli c down eth0; nmcli c up eth0 

IPv6無効化

「GRUB_CMDLINE_LINUX=”ipv6.disable=1…」を追加。
[root@centos7 ~]# vi /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
#GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos7/root rd.lvm.lv=centos7/swap rhgb quiet"
GRUB_CMDLINE_LINUX="ipv6.disable=1 rd.lvm.lv=centos7/root rd.lvm.lv=centos7/swap rhgb quiet" ※新規追加
GRUB_DISABLE_RECOVERY="true"

[root@centos7 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg 
[root@centos7 ~]# shutdown -r now