Ubuntu 固定IPアドレスの設定方法

Ubuntu Server の場合

http://d.hatena.ne.jp/linux40/20071017/1192624156 を参考にした

UbuntuServerの場合、DHCPでipadressを取得するようになっているようなので、固定アドレス 192.168.0.41を設定してみる。

sudo vi /etc/network/interfaces

変更前

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

変更後

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.41
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.1.255
gateway 192.168.0.1
dns-nameservers 192.168.0.1

設定後、ネットワークの再起動を行う

sudo /etc/init.d/networking restart