A-A+

Linux下搭建dhcp服务的实验

2017年09月19日 站长资讯 暂无评论

实验前提:

1.所有试验机在相同网络。

2.DHCP服务器有固定ip地址。

实验步骤:

配置ip

[root@localhost Server]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.4.5
HWADDR=00:0c:29:62:2b:78
[root@localhost Server]# cat /etc/resolv.conf
; generated by /sbin/dhclient-script
nameserver 202.106.0.20
nameserver 192.168.4.5
search dhcpser.tarena.com

2.安装软件包

[root@localhost Server]# yum -y install dhcp-3.0.5-31.el5_8.1.x86_64.rpm

3.修改配置文件

[root@localhost Server]# cat /etc/dhcpd.conf
ddns-update-style none;
subnet 192.168.4.0 netmask 255.255.255.0 {
option routers 192.168.4.5;
option subnet-mask 255.255.255.0;
option domain-name "tarena.com";
option domain-name-servers 192.168.1.1;
option time-offset -18000;
range 192.168.4.100 192.168.4.200;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.1.1;
filename "pxelinux.0";
}

4. 启动服务

[root@dhcpser ~]# rpm -ql dhcp | grep init.d
/etc/rc.d/init.d/dhcpd
/etc/rc.d/init.d/dhcrelay
[root@dhcpser ~]# service dhcpd restart
[root@dhcpser ~]# chkconfig dhcpd on

注:如果启动失败,可以检测主配置文件语法

[root@dhcpser ~]# service dhcpd configtest

5. 验证

Linux:

# dhclient -d eth0临时获取
# dhclient -r eth0释放

Windows:

cmd>ipconfig /release释放ip
cmd>ipconfig /renew重新获取ip

标签:

给我留言