-------陈功磊 2009-5-31
(说明:系统镜像:[红帽企业.Linux.5].rhel-5.2-server-i386-dvd.iso)
1、挂载镜像
[root@linux01 ~]# ls -al /media
total 16
drwxr-xr-x 2 root root 4096 Oct 11 2006 .
drwxr-xr-x 24 root root 4096 May 31 19:57 ..
[root@linux01 ~]# mkdir /media/cdrom
[root@linux01 ~]# ls -al /media
total 24
drwxr-xr-x 3 root root 4096 May 31 20:11 .
drwxr-xr-x 24 root root 4096 May 31 19:57 ..
drwxr-xr-x 2 root root 4096 May 31 20:11 cdrom
[root@linux01 ~]# mount -t iso9660 /dev/cdrom /media/cdrom # 挂载镜像
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@linux01 ~]#
2、安装DHCP软件包
[root@linux01 ~]# cd /media/cdrom/Server # 进入rmp软件包文件夹
[root@linux01 Server]# ls -l dhcp*
-rw-r--r-- 243 root root 895219 Apr 16 2008 dhcp-3.0.5-13.el5.i386.rpm
-rw-r--r-- 263 root root 133868 Apr 16 2008 dhcp-devel-3.0.5-13.el5.i386.rpm
-rw-r--r-- 91 root root 194686 Apr 26 2008 dhcpv6-1.0.10-4.el5.i386.rpm
-rw-r--r-- 91 root root 122618 Apr 26 2008 dhcpv6-client-1.0.10-4.el5.i386.rpm
[root@linux01 Server]# rpm -ivh dhcp-3.0.5-13.el5.i386.rpm # i安装 v 详细输出 h进度
warning: dhcp-3.0.5-13.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:dhcp ########################################### [100%]
[root@linux01 Server]#
[root@linux01 Server]# rpm -qa | grep dhcp # 查看与dhcp相关的安装软件
dhcpv6-client-1.0.10-4.el5
dhcp-3.0.5-13.el5
[root@linux01 Server]#
3、配置/etc/dhcpd.conf文件
[root@linux01 ~]# vi /etc/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
#
ddns-update-style interim; # dhcpd启动的必须项
default-lease-time 21600; # 默认租约时间(sec)(6小时)
max-lease-time 43200; # 最大租约时间(sec)(12小时)
option domain-name "benet.com.cn"; # 主机所在域名,可选项
option domain-name-servers 222.172.200.68,202.203.144.33; # DNS域名服务器的ip,可选项
subnet 192.168.7.0 netmask 255.255.255.0 {
range 192.168.7.50 192.168.7.250;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.7.255;
option routers 192.168.7.1;
host linux01{      # 静态ip
hardware ethernet 00:0C:29:BE:87:75;
fixed-address 192.168.7.2;
}
}
~
~
"/etc/dhcpd.conf" 15L, 383C written
[root@linux01 ~]# service dhcpd restart
Shutting down dhcpd: [ OK ]
Starting dhcpd: [ OK ]
[root@linux01 ~]#
4、查看DHCP本机网络情况
[root@linux01 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 # 网卡信息
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.7.255
HWADDR=00:0C:29:BE:87:75
IPADDR=192.168.7.2
NETMASK=255.255.255.0
NETWORK=192.168.7.0
ONBOOT=yes
~
~
[root@linux01 ~]#
[root@linux01 network-scripts]# vi /etc/sysconfig/network # 主机名和网关信息
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=linux01
GATEWAY=192.168.7.1~
~
[root@linux01 ~]#
[root@linux01 etc]# cat hosts # 本机信息
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 linux01 localhost.localdomain localhost # 主机名 主机名.域名 主机别名
::1 localhost6.localdomain6 localhost6
[root@linux01 etc]#
[root@linux01 etc]# cat hosts # 域名解析服务信息
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 linux01 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
[root@linux01 etc]#
说明:在linux安装时有配置好以上项目时,在下面路径下也有这些信息及配置
[root@linux02 ~]# cd /etc/sysconfig/networking/profiles/default
[root@linux02 default]# ls
hosts ifcfg-eth0 network resolv.conf
[root@linux02 default]#
5、客户端获取ip
Linux客户端
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 # 客户端网络配置
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=dhcp # 使用dhcp自动获取
HWADDR=00:0C:29:CD:40:C8
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
[root@localhost ~]#
[root@linux01 ~]# /etc/init.d/network restart # 重启网络
客户端Xp系统ip地址自动获取验证
clip_image002
6、DHCP相关命令
[root@linux01 ~]# rpm -qa dhcpd # 查询当前系统安装的dhcp包
[root@linux01 ~]# rpm -qa dhcp*
dhcpv6-client-1.0.10-4.el5
dhcp-3.0.5-13.el5
[root@linux01 ~]#
[root@linux01 ~]# service dhcpd status # 查看当前dhcp服务状态
dhcpd (pid 12946) is running...
[root@linux01 ~]#
[root@linux01 ~]# service dhcpd start/stop/restart # 开启/停止/重启dhcp服务
[root@linux01 ~]# chkconfig --list | grep dhcpd # 查看dhcpd的服务在不同模式下的状
dhcpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@linux01 ~]# chkconfig --level 35 dhcpd on # 配置dhcpd服务在35系统模式下为自动随机开启
[root@linux01 ~]#
本文出自 “Gonglei Chen” 博客,转载请与作者联系!