2008年4月19日土曜日

DHCPを参照せずにIPアドレスを固定する

Debian系のLinuxで、IPアドレスを固定する設定方法
sudo vi /etc/networ/interfaces
始めの設定は下のようになっている。

auto eth0

iface eth0 inet dhcp

これを編集して、

auto eth0

iface eth0 inet static

address 192.168.1.123(自分のアドレス)

netmask 255.255.255.0

network 192.168.1.0

broadcast 192.168.1.255

gateway 192.168.1.1(デフォルトゲートウェイ)

とする。ポイントはiface eth0 inetをきちんとstaticで宣言しておくこと。

最後にネットワークを再起動する。
sudo /etc/init.d/networking restart

ifconfigコマンドなどで確認すると良い。