实验01:配置DHCP服务器实验目标 公司要求将闲置的一台Linux 主机配置为DHCP服务器,以便为局域网内员工的办公用机提供自动分配IP地址的服务,以提高网络管理和维护的效率。需要满足的基本要求如下所述。 1.为192.168.10.0/24网段的客户机自动配置网络参数。 用来给客户机自动分配的IP地址范围是:192.168.10.50-192.168.10.100、 192.168.10.120-192.168.10.200。 客户机的默认网关地址设为192.168.10.254。 客户机所使用的DNS服务器设为192.168.10.253、202.106.0.20, 默认搜索域后缀为tarena.com。 将默认租约时间设为8小时,最大租约时间24小时 2.为打印服务器分配保留地址(Win7) 这台打印机每次开启电源后获得的IP地址都应该是192.168.10.8。 3.验证DHCP服务器的IP分配情况、客户机的租约信息
实验前提条件 1. 所有实验机在相同网络(vmnet8) 2. DHCP服务器有固定IP 实验步骤
一、环境准备 1. 设置服务器ip地址 [iyunv@localhost~]#vim/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 BOOTPROTO=none ONBOOT=yes HWADDR=00:0c:29:f6:76:4d IPADDR=192.168.10.253 NETMASK=255.255.255.0 [iyunv@localhost~]# vim /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=yes HOSTNAME=tarena.com GATEWAY=192.168.10.254 [iyunv@localhost~]# vim /etc/hosts 192.168.10.253 dhcpser.tarena.com dhcpser [iyunv@localhost~]# service network restart [iyunv@localhost~]# chkconfig network on 2. 安装 dhcp 软件包,确认装结果、模板配置文件 [iyunv@localhost~]# umount /dev/cdrom [iyunv@localhost~]# mount /dev/cdrom /media/ [iyunv@localhost~]# rpm -q dhcp [iyunv@localhost~]# cd /misc/cd/Server/ [iyunv@localhostServer]#rpm-ivhdhcp-3.0.5-31.el5_8.1.x86_64.rpm 3. 确认安装结果、模板配置文件 [iyunv@localhost~]# rpm -q dhcp dhcp-3.0.5-31.el5_8.1 4. 修改配置文件 [iyunv@localhost~]# vim /etc/dhcpd.conf :r/usr/share/doc/dhcp*/dhcpd.conf.sample ddns-update-styleinterim; subnet192.168.10.0 netmask 255.255.255.0 { option routers 192.168.10.254; option subnet-mask 255.255.255.0; option domain-name "tarena.com"; optiondomain-name-servers 192.168.10.253,202.106.0.20; range dynamic-bootp 192.168.10.50192.168.10.100; range dynamic-bootp 192.168.10.120192.168.10.200; default-lease-time 28800; max-lease-time 86400; host win7 { hardware ethernet00:0C:29:4A:C2:7B; fixed-address 192.168.10.8; } }}
5. 启动服务 [iyunv@localhost~]# service dhcpd restart 启动 dhcpd: [iyunv@localhost~]# chkconfig dhcpd on [iyunv@localhost~]# service dhcpd configtest Syntax: OK 一、在DHCP客户机上 1. 重启 network 服务后,查看是否成功获取到正确的IP地址 [iyunv@localhost~]#vim/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=dhcp HWADDR=00:0C:29:04:9E:82 ONBOOT=yes [iyunv@localhost~]# service network restart ...... 正在决定 eth0 的 IP 信息...完成。 2. 查看已获取的IP租约信息 [iyunv@localhost~]# ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:0C:29:04:9E:82 inet addr:192.168.10.200 Bcast:192.168.10.255 Mask:255.255.255.0 ...... 3. 修改客户机的MAC地址,验证是否可获得保留地址 [iyunv@localhost~]#vim/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=dhcp HWADDR=00:0C:29:04:9E:54 ONBOOT=yes [iyunv@localhost~]# ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:0C:29:04:9E:82 inet6 addr:fe80::20c:29ff:fe04:9e82/64 Scope:Link 4. Win7打印机上测试 在运行——cmd ipconfig /release释放ip ipconfig /renew 重新获取ip
故障现象:…… 出现[iyunv@localhost~]# service dhcpd configtest报错 [iyunv@localhost ~]# service dhcpd configtest ...... WARNING: Host declarations are global. They are not limited to the scope youdeclared them in. /etc/dhcpd.conf line 14: unexpected end of file ^ Configuration file errors encountered -- exiting ...... 解决办法:…… 检查[iyunv@localhost~]# vim /etc/dhcpd.conf的第14行左右
故障现象:…… 在确定服务机配置好的情况下客户机无法获取ip地址 解决办法:…… 检查vm桥接是否一致
|