DHCP 動態主機設定協議

sgy618發表於2011-04-19

DHCP 動態主機設定協議

[@more@]

dhcp:

功能:

給其它主機分配網路引數: IP/DNS/GW

C/S

67 / 68

工作原理:

配置過程:

DHCP伺服器

1、擁有固定IP

2、定義將租出去的IP地址範圍

1、安裝實現DHCP協議的程式包

]# ls /mnt/Server/dhcp-3.0.5-23.el5.i386.rpm

]# mount -o loop rhel5u5.iso /mnt/

]# yum -y install dhcp

2、根據需要修改配置檔案

]# vim /etc/dhcpd.conf

]# ls /usr/share/doc/dhcp*/dhcpd.conf.sample

]# cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf

cp:是否覆蓋“/etc/dhcpd.conf? y

[root@localhost ftp]# cat /etc/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

宣告子網,要求必須與當前網路卡ip在一個網段

subnet 192.168.1.0 netmask 255.255.255.0 {

option routers 192.168.1.254; 定義閘道器,客戶端獲得DHCP提供的服務後,客戶的網路卡閘道器與之相同

option subnet-mask 255.255.255.0;

option domain-name-servers 202.106.0.45,202.206.0.20; 定義DNSIPDNS本機IP地址

option time-offset -18000; # Eastern Standard Time

option ntp-servers 192.168.1.254; 定義時間伺服器IP

range dynamic-bootp 192.168.1.1 192.168.1.253;定義要分配給客戶端的IP地址範圍

default-lease-time 21600; 定義租約最小時間為6小時

max-lease-time 43200; 定義最大租約時間為12小時

# we want the nameserver to appear at a fixed address

host host1 { 給相應MAC的主機分配固定IP

hardware ethernet 00:e0:4c:41:95:c5;

fixed-address 192.168.1.110;

}

host host2 {

hardware ethernet 00:e0:4c:cf:01:7b;

fixed-address 192.168.1.120;

}

}

3、啟動服務

]# service dhcpd restart

如果失敗,tail /var/log/messages

4、找客戶端測試

[root@localhost ftp]# dhclient eth0

Internet Systems Consortium DHCP Client V3.0.5-RedHat

Copyright 2004-2006 Internet Systems Consortium.

All rights reserved.

For info, please visit

Listening on LPF/eth0/00:ee:ee:00:0a:76

Sending on LPF/eth0/00:ee:ee:00:0a:76

Sending on Socket/fallback

DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7

DHCPOFFER from 192.168.1.254

DHCPREQUEST on eth0 to 255.255.255.255 port 67

DHCPACK from 192.168.1.254

bound to 192.168.1.248 -- renewal in 9620 seconds.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23168012/viewspace-1048844/,如需轉載,請註明出處,否則將追究法律責任。

相關文章