CentOSをネットワーク経由でインストールする日記(tftp、dhcpの設定)
- April 10th, 2009
- Posted in 個人的ないろいろ
- Write comment

さて、前回までのあらすじはこちらね。
では次にネットワーク元サーバーの設定をします。まずはネットワークブートまで行いましょう。具体的にはtftpとdhcpをインストールしていきます。
■ IPアドレスの確認、ターミナルでアクセス
ここからはTeraTerm(なんでもいいですが)で作業したいのでまずはIPアドレスを調べます。

↑ rootでログインし、ifconfigでIPアドレスを確認します。今回は「192.168.0.17」ですね。

↑ Teratermからアクセスします。

↑ rootでログイン。はげしく微妙ですが、ネットワークインストール用だからまぁ良しとしましょう。
さてここからはコマンド叩いていきますよ。
yum -y install tftp-server dhcp
↑ まずはtftp、DHCPをインストールします。
vi /etc/xinetd.d/tftp
↑ tftpを有効化するために設定ファイルを編集します。
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
↑ disableの項を「yes」から「no」へ変更。
cd /tftpboot/
↑ こちらへ移動。
cp /usr/lib/syslinux/pxelinux.0 .
↑ pxelinux.0をコピーします。最後の「.」を忘れずにね。ちなみにsyslinuxがない場合は「yum -y install syslinux」しましょう。
mkdir centos53_64 cd centos53_64 wget http://ftp.riken.jp/Linux/centos/5.2/os/x86_64/images/pxeboot/initrd.img wget http://ftp.riken.jp/Linux/centos/5.2/os/x86_64/images/pxeboot/vmlinuz
↑ 次にインストール用のイメージを/tftpboot/centos53_64/にダウンロードします。
mkdir pxelinux.cfg cd pxelinux.cfg vi default
↑ 起動用の設定ファイルをつくりますよ。
default centos53_64 prompt 1 timeout 15 label centos53_64 kernel centos53_64/vmlinuz append load initrd=centos53_64/initrd.img noipv6 devfs=nomount
↑ こんな感じで作成して保存。
[root@localhost ~]# ls -R /tftpboot/ /tftpboot/: centos53_64 pxelinux.0 pxelinux.cfg /tftpboot/centos53_64: initrd.img vmlinuz /tftpboot/pxelinux.cfg: default
↑ ちなみにこの時点のファイル構成はこんな感じね。
service xinetd start
↑ tftpはxinetd上で動作するらしいのでここで起動しておきましょう。
vi /etc/dhcpd.conf
↑ 次にdhcpの設定ファイルを編集しますよ。
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option domain-name "dev.local";
option domain-name-servers 192.168.0.1;
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.0.80 192.168.0.99;
default-lease-time 21600;
max-lease-time 43200;
filename "pxelinux.0";
next-server 192.168.0.17;
}
↑ まぁ、こんな感じで。
ここで気をつけるべき点は2つほど。
- サブネットマスクはインストール元サーバーのIPとあわせること。インストール元サーバーのIPが「192.168.1.17」とかだったら上の設定中の「192.168.0.x」は「192.168.1.x」に書き直すこと。
- 最後の「next-server」の値はインストール元サーバーのIPを指定すること。
service dhcpd start
↑ ここらでdhcpを起動しておきましょう。
service iptables stop setenforce 0
↑ 最後にFirewallとSElinuxを無効にします。ポートを空けたりするのも面倒なのでざっくりこれで。インストール用なのでOKでしょう。
インストール元サーバーの設定はこんな感じですかね。次は実際につないでテストしてみます。


No comments yet.