给服务器配置了IP地址
[root@L-server ~]# uname -a
Linux L-server 2.6.32 #2 SMP Sat Sep 13 14:48:15 CST 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@L-server ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:8D:BE:D4
inet addr:192.168.100.11 Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe8d:bed4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:353 errors:0 dropped:0 overruns:0 frame:0
TX packets:332 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:32661 (31.8 KiB) TX bytes:41858 (40.8 KiB)
查看了下dhcp软件包,没有安装
[root@L-server ~]#
[root@L-server ~]# rpm -q dhcp
package dhcp is not installed
[root@L-server ~]#
先配下yum库吧,方便以后实验用
[root@L-server ~]# rpm -q dhcp
package dhcp is not installed
[root@L-server ~]#
[root@L-server ~]# cat /etc/yum.repos.d/server.repo
[rhel5]
name=Red Hat Enterprise Linux 5
baseurl=file:///media/Server
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@L-server ~]# mount /dev/cdrom /media/
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@L-server ~]#
[root@L-server ~]# mount | tail -1
/dev/sr0 on /media type iso9660 (ro)
[root@L-server ~]#
[root@L-server ~]# tail -1 /etc/fstab
/dev/cdrom /media ext3 defaults 0 0
[root@L-server ~]#
挂载成功并设置了开机自动挂载
[root@L-server ~]# yum -y install dhcp
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel5 | 1.5 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:3.0.5-31.el5_8.1 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
dhcp x86_64 12:3.0.5-31.el5_8.1 rhel5 890 k
Transaction Summary
================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)
Total download size: 890 k
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : dhcp 1/1
Installed:
dhcp.x86_64 12:3.0.5-31.el5_8.1
Complete!
[root@L-server ~]#
dhcp安装完成,接下来该配置服务喽
配置完成,给另一台作为客户端的服务器预留了IP地址
[root@L-server ~]# cat /etc/dhcpd.conf
ddns-update-style interim;
subnet 192.168.100.0 netmask 255.255.255.0 {
option routers 192.168.100.254;
option subnet-mask 255.255.255.0;
option domain-name "freedom.com";
option domain-name-servers 8.8.8.8,9.9.9.9;
range dynamic-bootp 192.168.100.20 192.168.100.50;
default-lease-time 21600;
max-lease-time 43200;
host ns {
hardware ethernet 00:0C:29:B3:C1:B8;
fixed-address 192.168.100.21;
}
}
[root@L-server ~]#
[root@L-server ~]# /etc/init.d/dhcpd configtest
Syntax: OK
[root@L-server ~]#
重启服务
[root@L-server ~]# /etc/init.d/dhcpd start
启动 dhcpd: [确定]
[root@L-server ~]# chkconfig dhcpd on
[root@L-server ~]#
[root@L-server ~]# netstat -tulnp | grep dhcpd
udp 0 0 0.0.0.0:67 0.0.0.0:* 4763/dhcpd
[root@L-server ~]#