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; 定义DNS的IP,DNS本机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 http://www.isc.org/sw/dhcp/
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/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23168012/viewspace-1048844/