• Top
  • What's New
  • Command
  • Basic
  • Server
  • Security
  • Conf
  • tools
  • etc
  • blog
  • Link
  • サイトについて
  • Mail
INDEX /  ユーザ関連 /  ネットワーク関連 / 
最終更新日 2005/05/23  

ネットワーク関連設定ファイル


ネットワーク関連の設定ファイル
/etc/hosts
/etc/host.conf
/etc/nsswitch.conf
/etc/resolv.conf
/etc/sysconfig/network
/etc/sysconfig/network-scripsts/ifcfg-eth0

ユーザ関連の設定ファイル

GNU/Linuxシステムにおける設定ファイルのほとんどは、「/etc」以下に配置されています。
ネットワーク関連の設定ファイルも「/etc」以下に配置されます。ネットワークの設定やホスト名を記述したファイルなどがあります。

ファイル 説明
/etc/hostsIPアドレスとホスト名の対応表
/etc/host.conf名前を解決する時の優先順
/etc/nsswitch.conf名前を解決する時の優先順(NIS+も指定可能)
/etc/resolv.confDNSサーバ・ドメインの指定
/etc/sysconfig/networkホスト名やデフォルトゲートウェイの指定
/etc/sysconfig/network-scripsts/ifcfg-eth0NICデバイスの指定

ページトップへTop

/etc/hosts

hostファイルは、IPアドレスとホスト名の対応表が記述されています。
初期状態は、ループバックアドレス(127.0.0,1)と、ホスト名やlocalhostとの対比が記述されています。
hostファイルに対応表を記述し、そのファイルを全ホストに配置すれば、ホスト名でアクセスすることが可能です。

hostsファイルの書式

hostファイルは、一行につき1IPアドレスと複数のホスト名を指定することができます。
複数のホスト名を記述する場合は、スペースでホスト名を区切ります。

1: 127.0.0.1               host1 localhost.localdomain localhost

  1. IPアドレス           ホスト名 ホスト+ドメイン名 ローカルホスト
ページトップへTop

/etc/host.conf

host.confファイルは、名前解決の際の優先順が記述されているファイルです。
しかし、現在の名前解決の優先順は、「/etc/nsswitch.conf」が使用されています。

host.confの書式

"order"で名前解決の順番を決めます。左から順に評価されます。,(カンマ)区切りで指定します。

1: order hosts,bind
  1. "order"→優先順を指定。"hosts,bind"→hostsファイル、DNSサーバの順で名前の解決を試みる。
ページトップへTop

/etc/nsswitch.conf

nsswitch.confファイルは、名前解決の際の優先順が記述されているファイルです。
「host.conf」を同じ役割になりますが、NIS+の設定(指定)もできるようになってます。

nsswitch.confファイル(sample)
#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Legal entries are:
#
#       nisplus or nis+         Use NIS+ (NIS version 3)
#       nis or yp               Use NIS (NIS version 2), also called YP
#       dns                     Use DNS (Domain Name Service)
#       files                   Use the local files
#       db                      Use the local database (.db) files
#       compat                  Use NIS on compat mode
#       hesiod                  Use Hesiod for user lookups
#       [NOTFOUND=return]       Stop searching if not found so far
#

# To use db, put the "db" in front of "files" for entries you want to be
# looked up first in the databases
#
# Example:
#passwd:    db files nisplus nis
#shadow:    db files nisplus nis
#group:     db files nisplus nis

passwd:     files
shadow:     files
group:      files

#hosts:     db files nisplus nis dns
hosts:      files dns

# Example - obey only what nisplus tells us...
#services:   nisplus [NOTFOUND=return] files
#networks:   nisplus [NOTFOUND=return] files
#protocols:  nisplus [NOTFOUND=return] files
#rpc:        nisplus [NOTFOUND=return] files
#ethers:     nisplus [NOTFOUND=return] files
#netmasks:   nisplus [NOTFOUND=return] files

bootparams: nisplus [NOTFOUND=return] files

ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files

netgroup:   files

publickey:  nisplus

automount:  files
aliases:    files nisplus


/etc/nsswitch.confの書式

途中の「hosts:」から始まる箇所が、名前解決の優先順の指定になります。

1: hosts:      files dns

  1. "hosts"→名前解決の優先順を指定。"files"→hostsファイル、"dns"→DNSサーバ
ページトップへTop

/etc/resolv.conf

resolv.confファイルは、名前解決に利用するDNSサーバの指定やドメインの指定を行います。

resolv.confの書式

nameserverのパラメータの後に、スペースを入れてDNSサーバを指定します。
1: nameserver xxx.xxx.xx.x

  1. "namesever"→DNSサーバを指定
ページトップへTop

/etc/sysconfig/network

networkファイルは、ネットワーク機能を使用するかしないの指定や、ホスト名・ゲートウェイなどを指定するファイルです。

/etc/sysconfig/networkの書式

"HOSTNAME"などは大文字で記述します。また、"="の間にスペースを入れてはいけません。連続で記述します。
これは、"HOSTNAME"などを変数として扱っているためです。「変数=値」という書式になっています。

1: NETWORKING=yes
2: HOSTNAME=host1
3: GATEWAY=172.16.0.1

  1. ネットワーク機能の有・無の指定
  2. ホストネームの指定
  3. デフォルトゲートウェイの指定
ページトップへTop

/etc/sysconfig/network-scripsts/ifcfg-eth0

「/etc/sysconfig/network-scripsts/」ディレクトリには、ネットワークデバイスの設定ファイルが配置されています。
一枚目のNICは「ifcfg-eth0」、2枚目は「ifcfg-eth1」3枚目は「ifcfg-eth2」という名前の付け方になります。

/etc/sysconfig/network-scripsts/ifcfg-eth0の書式

"IPADDR"などは大文字で記述します。また、"="の間にスペースを入れてはいけません。連続で記述します。
これは、"IPADDR"などを変数として扱っているためです。「変数=値」という書式になっています。

1: DEVICE=eth1
2: BOOTPROTO=static
3: BROADCAST=192.168.0.255
4: HWADDR=00:40:26:5C:79:59 
5: IPADDR=192.16.0.100
6: NETMASK=255.255.255.0
7: NETWORK=192.168.0.0
8: ONBOOT=yes
9: TYPE=Ethernet


  1. デバイスの指定
  2. 固定IPアドレス又はDHCPの指定。(固定は"static"又は"none"。DHCPは"dhcp"と記述)
  3. ブロードキャストアドレスの指定
  4. MACアドレスの指定
  5. IPアドレスの指定
  6. サブネットマスクの指定
  7. ネットワークアドレスの指定
  8. 起動時にネットワークデバイスを有効にするかどうかの指定("yes"は有効。"no"は無効)
  9. ネットワークのタイプを指定
ページトップへTop

 
Copyright (c) 2005 Mukuan All Rights Reserved.