Rocky Linux 8 のIPアドレス変更

Rocky Linux 8以降では nmcli コマンドを使用してインターフェースの gateway や dns を変更する。

# 権限昇格
sudo su

# 現状確認
nmcli connection show
ip route show default

# IPアドレス変更
nmcli connection modify "System eth0" ipv4.addresses 10.20.0.11
nmcli connection modify "System eth0" ipv4.method manual

# ゲートウェイとDNSも変更
nmcli connection modify "System eth0" ipv4.gateway 10.20.0.254
nmcli connection modify "System eth0" ipv4.dns "10.20.0.254"
nmcli connection up "System eth0"

# 動作確認
ip route show default
ping 8.8.8.8
ping google.com

ゲートウェイが変わる場合は設定ファイルの /etc/resolv.conf も変更する


; Created by cloud-init automatically, do not edit.
;

nameserver 10.10.0.254  <=== 変更

コメント

タイトルとURLをコピーしました