DHCP配置
1.1、 實驗環境準備(機器設置,網絡設置)
1.2、 服務器上需配置固定IP
[root@localhost~]#cat /etc/sysconfig/network-scripts/接口
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
HWADDR=00:0c:29:c2:46:af
IPADDR=192.168.100.1
NETMASK=255.255.255.0
[root@localhost ~]# service network restart
[root@localhost ~]# chkconfig network on
[root@localhost ~]# ifconfig etho
2.1、DHCP的安裝
[root@localhost ~]# rpm -q dhcp
package dhcp is not installed
放入5.9iso
[root@localhost ~]# cd /misc/cd/Server/
[root@localhost Server]# ls dhc
[root@localhostServer]#rpm–ivhdhcp-3.0.5-31.el5_8.1.x86_64.rpm warning: dhcp-3.0.5-31.el5_8.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
package dhcp-3.0.5-31.el5_8.1.x86_64 is already installed
2.2、DHCP的配置
[root@localhost ~]# cat /etc/dhcpd.conf
ddns-update-style interim; //全局
subnet 192.168.100.0 netmask 255.255.255.0 {
option routers 192.168.100.55; //網關
option subnet-mask 255.255.255.0; //子網掩碼
option domain-name "tarena.com"; //搜索域名
optiondomain-name-servers 202.106.0.20,192.168.100.251; //DNS
range dynamic-bootp 192.168.100.128 192.168.100.131; //IP範圍
range dynamic-bootp 192.168.100.10 192.168.100.55;
default-lease-time 21600;
max-lease-time 623200;
host p2 {//給指定pc分配固定IP
hardware ethernet 00:0C:29:A9:62:CC;
fixed-address 192.168.100.88;
}
host p1 {
hardware ethernet 00:0C:29:68:0E:F2;
fixed-address 192.168.100.89;
}
}
2.3、DHCP的啓動
[root@localhost ~]# rpm -ql dhcp | grep init.d//獨立服務
/etc/rc.d/init.d/dhcpd
/etc/rc.d/init.d/dhcrelay
[root@localhost ~]# /etc/init.d/dhcpd status//查看狀態
dhcpd 已停
[root@localhost ~]# service dhcpd start
啓動 dhcpd: [確定]
[root@localhost ~]# chkconfig dhcpd on//自啓
2.4、client上查看自動獲取的地址
client1:[root@localhost ~]# ifconfig eth0//查看IP
eth0 Link encap:Ethernet HWaddr 00:0C:29:68:0E:F2
inetaddr:192.168.100.89Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe68:ef2/64 Scope:Link
[root@localhost ~]# cat /etc/resolv.conf //查看DNS
; generated by /sbin/dhclient-script
search tarena.com
nameserver 202.106.0.20
nameserver 192.168.100.251
client2:ipconfig /all(window)