大佬教程收集整理的这篇文章主要介绍了CentOS 7 配置DHCP中继代理服务,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
DHCP服务器只作用于局域网同一网段内,客户端是通过广播消息来获得DHCP服务器响应后才能得到IP地址的,但广播消息不能跨越子网,那么如何让客户端获取到DHCP服务器提供的IP地址呢?这就是DHCP中继服务器的功能了
添加一块网卡
192.168.94.11 ens33(NAT) 192.168.29.29(VMnet2)
[[email protected] ~]# ifconfig ens33: flags=4163<UP,BroaDCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.94.11 netmask 255.255.255.0 broadcast 192.168.94.255 inet6 fe80::20c:29ff:fe54:3372 prefixlen 64 scopEID 0x20<link> ether 00:0c:29:54:33:72 txqueuelen 1000 (Ethernet) RX packets 9733 bytes 11834218 (11.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3320 bytes 436871 (426.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens37: flags=4163<UP,MULTICAST> mtu 1500 inet 192.168.29.29 netmask 255.255.255.0 broadcast 192.168.29.255 inet6 fe80::20c:29ff:fe54:337c prefixlen 64 scopEID 0x20<link> ether 00:0c:29:54:33:7c txqueuelen 1000 (Ethernet) RX packets 122 bytes 13196 (12.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 82 bytes 12760 (12.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopEID 0x10<host> loop txqueuelen 1000 (Local LoopBACk) RX packets 9 bytes 1149 (1.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 9 bytes 1149 (1.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[[email protected] ~]# yum install dhcp -y [[email protected] ~]# vim /etc/dhcp/dhcpd.conf option domain-name-servers 202.106.0.20,8.8.8.8; subnet 192.168.94.0 netmask 255.255.255.0 { range 192.168.94.100 192.168.94.254; option routers 192.168.94.11; } subnet 192.168.29.0 netmask 255.255.255.0 { range 192.168.29.100 192.168.29.254; option routers 192.168.29.29; }
启动DHCP服务,并检查状态
[[email protected] ~]# systemctl start dhcpd [[email protected] ~]# systemctl status dhcpd ● dhcpd.service - DHCPv4 Server Daemon Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; disabled; vendor preset: disabled) Active: active (running) since 二 2018-08-21 13:58:25 CST; 1min 31s ago Docs: @H_811_32@man:dhcpd(8) @H_811_32@man:dhcpd.conf(5) Main PID: 3421 (dhcpd) Status: "Dispatching packets..." CGroup: /system.slice/dhcpd.service └─3421 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --n... 8月 21 13:58:25 DaMoWang dhcpd[3421]: All rights reserved. 8月 21 13:58:25 DaMoWang dhcpd[3421]: For info,please visit https://www.isc.org/softw...cp/ 8月 21 13:58:25 DaMoWang dhcpd[3421]: Not searching LDAP since ldap-server,ldap-port ...ile 8月 21 13:58:25 DaMoWang dhcpd[3421]: Wrote 0 leases to leases file. 8月 21 13:58:25 DaMoWang dhcpd[3421]: Listening on LPF/ens37/00:0c:29:54:33:7c/192.168.../24 8月 21 13:58:25 DaMoWang dhcpd[3421]: Sending on LPF/ens37/00:0c:29:54:33:7c/192.168.../24 8月 21 13:58:25 DaMoWang dhcpd[3421]: Listening on LPF/ens33/00:0c:29:54:33:72/192.168.../24 8月 21 13:58:25 DaMoWang dhcpd[3421]: Sending on LPF/ens33/00:0c:29:54:33:72/192.168.../24 8月 21 13:58:25 DaMoWang dhcpd[3421]: Sending on Socket/fallBACk/fallBACk-net 8月 21 13:58:25 DaMoWang systemd[1]: Started DHCPv4 Server Daemon. Hint: Some lines were ellipsized,use -l to show in full.
配置DHCP中继服务器
# 开启路由转发功能 [[email protected] ~]# vim /etc/sysctl.conf # 添加 net.ipv4.ip_forWARD=1 [[email protected] ~]# sysctl -p net.ipv4.ip_forWARD = 1 [[email protected] ~]# vim /etc/sysconfig/dhcrelay INTERFACES=ens33 # DHCP服务器网卡名称 DHCPSERVERS="192.168.94.11" # DHCP服务器IP [[email protected] ~]# dhcrelay 192.168.94.11 # 启动DHCP中继代理服务 Dropped all unnecessary capabilities. Internet Systems Consortium DHCP Relay Agent 4.2.5 Copyright 2004-2013 Internet Systems Consortium. All rights reserved. For info,please visit https://www.isc.org/software/dhcp/ Listening on LPF/ens37/00:0c:29:54:33:7c Sending on LPF/ens37/00:0c:29:54:33:7c Listening on LPF/ens33/00:0c:29:54:33:72 Sending on LPF/ens33/00:0c:29:54:33:72 Sending on Socket/fallBACk
用另一台虚拟机测试
网卡先用VMnet2
网段 IP 掩码 DNS都和DHCP服务器分配的一致
NAT
分配的IP等信息也一致
DHCP中继服务配置完成
以上是大佬教程为你收集整理的CentOS 7 配置DHCP中继代理服务全部内容,希望文章能够帮你解决CentOS 7 配置DHCP中继代理服务所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。