我的RHEL5.5是默認,然後選中所有軟體安裝的,這樣當再安裝軟體時就不會報軟體依賴性錯誤了.當然這樣也有一個好處,就是dhcp默認安裝了.現在就來配置一下默認安裝的dhcp伺服器.
首先,我們第一步還是來搜索下系統是否安裝了dhcp:
rpm -qa | grep dhcp
顯示結果:
[root@localhost ~]# rpm -qa | grep dhcp
dhcp-3.0.5-23.el5
sblim-cmpi-dhcp-devel-1.0-40.el5
dhcpv6-client-1.0.10-18.el5
dhcpv6-1.0.10-18.el5
sblim-cmpi-dhcp-1.0-40.el5
顯然dhcp已經安裝成功了,版本是dhcp-3.0.5-23.el5
第二步,查看一下dhcp相關文件都保存在文件系統的哪個位置:
rpm -ql dhcp
顯示結果:
[root@localhost ~]# rpm -ql dhcp
/etc/dhcpd.conf
/etc/rc.d/init.d/dhcpd
/etc/rc.d/init.d/dhcrelay
/etc/sysconfig/dhcpd
/etc/sysconfig/dhcrelay
/usr/bin/omshell
/usr/sbin/dhcpd
/usr/sbin/dhcrelay
/usr/share/doc/dhcp-3.0.5
/usr/share/doc/dhcp-3.0.5/IANA-arp-parameters
/usr/share/doc/dhcp-3.0.5/README
/usr/share/doc/dhcp-3.0.5/RELNOTES
/usr/share/doc/dhcp-3.0.5/api protocol
/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample
/usr/share/doc/dhcp-3.0.5/draft-ietf-dhc-authentication-14.txt
/usr/share/doc/dhcp-3.0.5/draft-ietf-dhc-dhcp-dns-12.txt
/usr/share/doc/dhcp-3.0.5/draft-ietf-dhc-failover-07.txt
/usr/share/doc/dhcp-3.0.5/ja_JP.eucJP
/usr/share/doc/dhcp-3.0.5/ja_JP.eucJP/dhclient-script.8
/usr/share/doc/dhcp-3.0.5/ja_JP.eucJP/dhclient.8
/usr/share/doc/dhcp-3.0.5/ja_JP.eucJP/dhclient.conf.5
/usr/share/doc/dhcp-3.0.5/ja_JP.eucJP/dhclient.leases.5
/usr/share/doc/dhcp-3.0.5/ja_JP.eucJP/dhcp-eval.5
結果中用紅線標出的是比較重要的文件路徑.
默認情況下,dhcp伺服器是無法啟動成功的.
[root@localhost ~]# /etc/rc.d/init.d/dhcpd start
啟動 dhcpd:[失敗]
原因有兩個,第一個是dhcp安裝完成時,/etc/dhcpd.conf這個文件是空的,沒有內容的.解決辦法是把/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample拷貝覆蓋/etc/dhcpd.conf.
[root@localhost ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
cp:是否覆蓋“/etc/dhcpd.conf”? y
另外一個原因是需要修改拷貝過來的/etc/dhcpd.conf文件.
源文件內容為:
[root@localhost ~]# vi /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.1.1;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 192.168.0.128 192.168.0.254;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
"/etc/dhcpd.conf" 31L, 852C
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.1.1;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 192.168.0.128 192.168.0.254;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
修改後的文件內容是:
[root@localhost ~]# vi /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.1.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.1.1;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 192.168.1.128 192.168.1.254;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 00:0c:29:13:9e:21;
fixed-address 192.168.1.200;
}
}
修改時,主要注意這樣幾點:
我的RHEL5.5的eth0的IP地址配置是這樣的:
[root@localhost ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:13:9E:21
inet addr:192.168.1.200 Bcast:192.168.1.255 Mask:255.255.255.0
然後就可以正常啟動DHCP服務了.
[root@localhost ~]# /etc/rc.d/init.d/dhcpd restart
啟動 dhcpd:[確定]
本文出自 「求學路」 博客,請務必保留此出處http://zbliangc.blog.51cto.com/655801/475940
[火星人 ] Linux下DHCP伺服器基本配置已經有404次圍觀