Ubuntu
UbuntuServer

Ubuntuでネットワーク設定の変更をする

More than 3 years have passed since last update.

従来の方法(RHEL系, Ubuntu 13以前)

/etc/network/interface を書き換えて、

sudo service networking restart

でOKのはず。そういうものとして覚えている人も多いでしょう。ところが、Ubuntu 14ではこれが動かない。

# /var/log/upstart/networking.log

Stopping or restarting the networking job is not supported.
Use ifdown & ifup to reconfigure desired interface.

こんなエラーメッセージになります。もちろん、再起動すれば良いのだが、なんとか再起動しないでやりたい。これではまったのでメモ。

Ubuntu Desktopの場合

sudo service network-manager restart

とすれば全部勝手にやってくれるらしい。

Ubuntu Serverの場合

先ほど示したエラーメッセージの通りで、

sudo ifdown eth0 && sudo ifup eth0

で基本的にはOK。

ただし、DHCPからstaticに変更した場合、dhclientのプロセスが消えないで残ってしまい、こいつが勝手に設定を書き換えてしまう。そこで、

sudo kill `cat /run/dhclient.eth0.pid`
sudo rm /run/dhclient.eth0.pid

でdhclientのプロセスを消す作業が必要です。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away