LoginSignup
57
58

More than 5 years have passed since last update.

CentOS 7.1.1503ではnmcliでIPアドレスを固定する方法が変更された

Posted at

CentOS 7.0.1406 (NetworkManager 0.9.9.1)ではnmcliを使ってNICに固定IPアドレスを設定するには次のようなコマンドを実行した。

# nmcli connection modify enp0s8 ipv4.method manual ipv4.addresses "10.0.2.250/24 10.0.2.1" ipv4.dns 8.8.8.8

この後、「systemctl restart network.service」などで反映される。

しかし、CentOS 7.1.1503 (NetworkManager 1.0.0)では同じnmcliコマンドを実行するとエラーになる。

# nmcli connection modify enp0s8 ipv4.method manual ipv4.addresses "10.0.2.250/24 10.0.2.1" ipv4.dns 8.8.8.8

Error: failed to modify ipv4.addresses: invalid prefix '24 10.0.2.1'; <1-32> allowed.

結局のところ、従来なかった「ipv4.gateway」プロパティが増えているので以下のようにすればよい。

# nmcli connection modify enp0s8 ipv4.method manual ipv4.addresses 10.0.2.250/24 ipv4.gateway 10.0.2.1 ipv4.dns 8.8.8.8

まあ、この指定の仕方のほうがすっきりしてると思うけどね。

57
58
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
57
58