Ubuntuのネットワーク設定
$ sudo vi /etc/network/interfaces
DHCPの場合
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp
固定IPの場合
auto lo
iface lo inet loopback
 
auto eth0
iface eth0 inet static
  address 192.168.1.1
  netmask 255.255.255.0
  gateway 192.168.1.254
  dns-nameservers 192.168.1.10 192.168.1.11 192.168.1.254
  dns-search fireball.local
設定反映。
$ sudo ifdown eth0 && sudo ifup eth0
NIC に複数IPを設定
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
    address 192.168.1.1
    netmask 255.255.255.0
    gateway 192.168.1.254
    dns-nameservers 192.168.1.254
auto eth0:0
iface eth0:0 inet static
    address 192.168.2.1
    netmask 255.255.255.0
複数NICの設定
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
    address 192.168.1.1
    netmask 255.255.255.0
    gateway 192.168.1.254
    dns-nameservers 192.168.1.254
auto eth1
iface eth1 inet static
    address 192.168.2.1
    netmask 255.255.255.0
    post-up /sbin/ip route del default dev eth1
トラブルシューティング
digコマンドで名前解決できるが、pingコマンドではunknown hostと言われる。
$ dig blue-dc.fireball.local
; <<>> DiG 9.9.3-rpz2+rl.13214.22-P2-Ubuntu-1:9.9.3.dfsg.P2-4ubuntu1 <<>> blue-dc.fireball.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35008
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;blue-dc.fireball.local.		IN	A
;; ANSWER SECTION:
blue-dc.fireball.local.	900	IN	A	192.168.1.10
;; Query time: 0 msec
;; SERVER: 192.168.1.10#53(192.168.1.10)
;; WHEN: Thu Nov 07 13:45:23 JST 2013
;; MSG SIZE  rcvd: 56
$ ping blue-dc.fireball.local ping: unknown host blue-dc.fireball.local
nsswitch.confを修正して名前解決まわりをシンプル設定にする。
$ sudo vi /etc/nsswitch.conf
#hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 hosts: files dns
 非ログインユーザー
 非ログインユーザー