RHEL8 Unit network.service not found時のnmcliコマンドでネットワーク設定と再起動

Unit network.service not found時のnmcliコマンドでネットワーク設定と再起動に関する情報です。

 

久しぶりにRHEL8を操作していたら、以下のようなメッセージがでました。

 

> systemctl restart network
Failed to restart network.service: Unit network.service not found.

 

ということで、参考になるのがこちら

3.2. nmcli を使用した静的イーサネット接続の設定 Red Hat Enterprise Linux 8 | Red Hat Customer Portal

 

===

手順

Ethernet 接続の NetworkManager 接続プロファイルを新たに追加します。

# nmcli connection add con-name Example-Connection ifname enp7s0 type ethernet
以下の手順は、作成した Example-Connection 接続プロファイルを変更します。

 

IPv4 アドレスを設定します。

# nmcli connection modify Example-Connection ipv4.addresses 192.0.2.1/24

 

IPv6 アドレスを設定します。

# nmcli connection modify Example-Connection ipv6.addresses 2001:db8:1::1/64

 

IPv4 および IPv6 接続メソッドを manual に設定します。

# nmcli connection modify Example-Connection ipv4.method manual
# nmcli connection modify Example-Connection ipv6.method manual

 

IPv4 および IPv6デフォルトゲートウェイを設定します。

# nmcli connection modify Example-Connection ipv4.gateway 192.0.2.254
# nmcli connection modify Example-Connection ipv6.gateway 2001:db8:1::fffe

 

IPv4 および IPv6 DNS サーバーアドレスを設定します。

# nmcli connection modify Example-Connection ipv4.dns "192.0.2.200"
# nmcli connection modify Example-Connection ipv6.dns "2001:db8:1::ffbb"

 

複数の DNS サーバーを設定するには、空白で区切って引用符で囲みます。

IPv4 および IPv6 接続の DNS 検索ドメインを設定します。

# nmcli connection modify Example-Connection ipv4.dns-search example.com
# nmcli connection modify Example-Connection ipv6.dns-search example.com

 

接続プロファイルをアクティベートします。

# nmcli connection up Example-Connection
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/Ac

===

 

普段、nmtuiを使っていますが、コマンドで設定したい場合に便利です。

 

そして、再起動ですが、上記にもありますが、以下の情報がよくでてきます。

 

# nmcli connection up Example-Connection
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/Ac

 

例えば、

 

> nmcli con up ens192

 

networkサービスがない場合は、以下も利用できるとう情報もありました。

 

sudo nmcli networking off
sudo nmcli networking on

 

ご参考まで

 

Amazonギフト券 チャージタイプ(直接アカウントに残高追加)