步驟一:給DHCP服務器配置靜態ipwindows
[root@localhost ~]# ifconfig eth0 //查看eth0網卡的配置信息服務器
eth0 Link encap:Ethernet HWaddr 00:0C:29:0C:C3:1F 網絡
inet addr:192.168.1.33 Bcast:192.168.1.255 Mask:255.255.255.0less
inet6 addr: fe80::20c:29ff:fe0c:c31f/64 Scope:Linkdom
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1ide
RX packets:2519 errors:0 dropped:0 overruns:0 frame:0測試
TX packets:2644 errors:0 dropped:0 overruns:0 carrier:0ui
collisions:0 txqueuelen:1000 this
RX bytes:1806182 (1.7 MiB) TX bytes:1671573 (1.5 MiB)url
Interrupt:18 Base address:0x2000
[root@localhost ~]# route -n // 查看路由表條目
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
步驟二:
根據要求安裝DHCP服務器所需軟件包
[root@localhost ~]# rpm -q dhcp // 查看dhcp包是否安裝,下面顯示未安裝
package dhcp is not installed
[root@localhost ~]# mkdir /ww //創建一個文件夾
[root@localhost ~]# mount /dev/cdrom /ww //將系統鏡像掛載到/ww目錄下
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# rpm -ivh /ww/Packages/dhcp-4.1.1-34.P1.el6.x86_64.rpm //安裝dhcp
warning: /ww/Packages/dhcp-4.1.1-34.P1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:dhcp ########################################### [100%]
[root@localhost ~]#
步驟三:
產生DHCP服務器配置文件
[root@localhost ~]# cp /usr//share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf cp:是否覆蓋「/etc/dhcp/dhcpd.conf"?y
步驟四:配置/etc/dhcp/dhcpd.conf配置文件
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers 8.8.8.8, 4.4.4.4; //指定dns服務器地址
default-lease-time 600;
max-lease-time 7200;
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 192.168.1.0 netmask 255.255.255.0 {
}
# This is a very basic subnet declaration.
subnet 192.168.1.0 netmask 255.255.255.0 { //聲明網址地址
range 192.168.1.10 192.168.1.100; //設置地址池
option routers 192.168.1.1; //設置默認網關
}
# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.
subnet 10.254.239.32 netmask 255.255.255.224 {
range dynamic-bootp 10.254.239.40 10.254.239.60;
option broadcast-address 10.254.239.31;
option routers rtr-239-32-1.example.org;
}
# A slightly different configuration for an internal subnet.
subnet 10.5.5.0 netmask 255.255.255.224 {
range 10.5.5.26 10.5.5.30;
option domain-name-servers ns1.internal.example.org;
option domain-name "internal.example.org";
option routers 10.5.5.1;
option broadcast-address 10.5.5.31;
default-lease-time 600;
max-lease-time 7200;
}
# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.
host passacaglia {
hardware ethernet 0:0:c0:5d:bd:95;
filename "vmunix.passacaglia";
server-name "toccata.fugue.com";
}
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
host fantasia {
hardware ethernet 08:00:07:26:c0:a5;
fixed-address fantasia.fugue.com;
}
# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.
class "foo" {
match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
}
shared-network 224-29 {
subnet 10.17.224.0 netmask 255.255.255.0 {
option routers rtr-224.example.org;
}
subnet 10.0.29.0 netmask 255.255.255.0 {
option routers rtr-29.example.org;
}
pool {
allow members of "foo";
range 10.17.224.10 10.17.224.250;
}
pool {
deny members of "foo";
range 10.0.29.10 10.0.29.230;
}
}
步驟五:啓動DHCP服務器
[root@localhost ~]# service dhcpd start
啓動 dhcpd: [肯定]
步驟六:測試
開一臺windows7和dhcp同一網絡下,自動獲取ip
打開/etc/dhcp/dhcpd.conf 修改第五行host後面的參數 綁定win7的mac 給win7指定的ip
重啓dhcp服務 service dhcpd restart
查看win7 的網絡鏈接詳細信息