Linux常见服务器 |
您所在的位置:网站首页 › linux中dhcp服务器启动不了的原因 › Linux常见服务器 |
一.基础知识:
1.DHCP简介:
DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)通常被应用在大型的局域网络环境中,主要作用是集中的管理、分配IP地址,使网络环境中的主机动态的获得IP地址、Gateway地址、DNS服务器地址等信息,并能够提升地址的使用率。
2.DHCP服务器简介:
DHCP服务器指的是由服务器控制一段IP地址范围,客户端登录服务器时就可以自动获得服务器分配的IP地址和子网掩码。
二.DHCP服务器的相关配置:
今天我们就来做一个DHCP服务器: 4.进行配置: (1)开启dhcp服务 systemctl start dhcpd(2)更改配置文件 cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.confvim /etc/dhcp/dhcpd.conf 更改以下部分: 7 option domain-name "server.com"; ##域名:参见/etc/resolv.conf 8 option domain-name-servers 172.25.10.254; ##指定dns服务器,多台用逗号隔开。 30 subnet 172.25.10.0 netmask 255.255.255.0 { ##指定子网络及子网掩码 31 range 172.25.10.10 172.25.10.20; ##指定IP范围 32 option routers 172.25.10.254; ##指定默认网关 33 } 34#### 删除27,28行,34行及以后下面是在dns.test.com上所做的配置: (1)网络参数设置: 编辑/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=dhcp ###关键部位为dhcp ONBOOT=yes(2)重启网络: systemctl restart network ###在本次试验,我遇到了如下问题:执行该命令报错,无法通过DHCP服务器获得ip,解决思路为:DHCP通常是用于局域网内的一个通信协议,它主要通过客户端发送广播数据包给整个物理网段内的所有主机,若局域网内有DHCP服务器时,才会响应客户端的ip参数要求。所以DHCP服务器与客户端应该在同一个物理网段内。整个DHCP数据包在服务器与客户端间的交互情况如下图(1): ###所以我猜测是防火墙阻止了数据包的传送 ###我采取的解决方法是: 两台虚拟机均执行命令: firewall-cmd --permanent --add-service=dhcp firewall-cmd --reload 查看dhcp是否通行: firewall-cmd --list-all 重启虚拟机后问题解决。
测试机通过DHCP服务器获得ip: cat /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 192.168.0.199; 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. # This is a very basic subnet declaration. subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.10 192.168.0.20; option routers 192.168.0.199; }本文术语性简介来自百度百科,理论部分摘自亲爱的鸟哥,部分参照博文DHCP详解,在此一并表示感谢! |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |