文章目录

  • DHCP中继原理
  • DHCP中继实验

DHCP中继原理

  • 当企业的内部网络规模较大时,通常被划分为多个不同的子网,网络内配置了VLAN,VLAN能隔离广播,而DHCP协议使用广播

  • DHCP服务器在VLAN 100中,就 只有VLAN 100内的客户机能从在此获取地址

DHCP中继实验

实验环境:

一台win 10 一台win 7 一台centos 7

首先配置clould

拓扑图如图所示

首先配置二层交换机SW2

<sw2>undo terminal monitor             ##关闭信息提示
Info: Current terminal monitor is off.
[sw2]vlan batch 10 20 100              ##批量添加vlan 10 20 100
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw2]dis this                         ##查看一下
#
sysname sw2
#
vlan batch 10 20 100
[sw2]int e0/0/2                        ##进入端口e0/0/2
[sw2-Ethernet0/0/2]port link-type access ##配置access接口
[sw2-Ethernet0/0/2]port de
[sw2-Ethernet0/0/2]port default vlan 10  ##划分vlan 10
[sw2-Ethernet0/0/2]int e0/0/3         ##进入e0/0/3接口
[sw2-Ethernet0/0/3]p l a              ##配置access口
[sw2-Ethernet0/0/3]p d v 20
[sw2-Ethernet0/0/3]int e0/0/4        ###进入e0/0/4接口
[sw2-Ethernet0/0/4]p l a
[sw2-Ethernet0/0/4]p d v 100
[sw2-Ethernet0/0/4]dis this           ##查看一下
interface Ethernet0/0/4port link-type accessport default vlan 100
[sw2-Ethernet0/0/4]int e0/0/1
[sw2-Ethernet0/0/1]p l t              ##trunk端口设置
[sw2-Ethernet0/0/1]p t a v a
[sw2-Ethernet0/0/1]un sh
Info: Interface Ethernet0/0/1 is not shutdown.
[sw2-Ethernet0/0/1]dis this
#
interface Ethernet0/0/1port link-type trunkport trunk allow-pass vlan 2 to 4094
配置三层交换机SW1
[sw1]vlan batch 10 20 100              ##批量添加vlan 10 20 100
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link t
[sw1-GigabitEthernet0/0/1]p t a v a
[sw1-GigabitEthernet0/0/1]un sh
sw1-GigabitEthernet0/0/1]dis this
#
interface GigabitEthernet0/0/1port link-type trunkport trunk allow-pass vlan 2 to 4094
配置三层交换
[sw1]int vlan 10
[sw1-Vlanif10]
[sw1-Vlanif10]ip add 192.168.10.1 24
[sw1-Vlanif10]int vlan 20
[sw1-Vlanif20]ip add 192.168.20.1 24
[sw1-Vlanif20]int vlan 100
[sw1-Vlanif100]ip add 192.168.100.1 24
[sw1-Vlanif100]q
##配置DHCP中继
[sw1]dhcp enable              ##开启dhcp功能
[sw1]int vlan 10
[sw1-Vlanif10]dhcp select relay      ##开启中继功能
[sw1-Vlanif10]dhcp relay server-ip 192.168.100.100   ##指向中继地址
[sw1]int vlan 20
[sw1-Vlanif20]dhcp select relay
[sw1-Vlanif20]dhcp relay server-ip 192.168.100.100
[sw1]int vlan 100
[sw1-Vlanif100]dhcp select relay      ##开启中继功能
[sw1-Vlanif100]dhcp relay server-ip 192.168.100.100##指向中继地址

安装dhcp

[root@localhost ~]# yum -y install dhcp*
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.163.com* extras: mirrors.nju.edu.cn* updates: mirrors.nju.edu.cn
base                                                            | 3.6 kB  00:00:00
extras                                                          | 2.9 kB  00:00:00
updates                                                         | 2.9 kB  00:00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 dhcp.x86_64.12.4.2.5-79.el7.centos 将被 安装
--> 正在处理依赖关系 libisc-export.so.169()(64bit),它被软件包 12:dhcp-4.2.5-79.el7.centos.x86_64 需要
--> 正在处理依赖关系 libdns-export.so.1102()(64bit),它被软件包 12:dhcp-4.2.5-79.el7.c
[root@localhost ~]# rpm -q dhcp       ##查看是否安装dhcp
dhcp-4.2.5-79.el7.centos.x86_64

设置linux网络

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
####配置网卡信息
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=86503bd2-47b6-4518-8a5f-63e4de03d11e
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.100.100
PREFIX=24
GATEWAY=192.168.100.1
:wq         ##保存退出[root@localhost ~]# systemctl restart network     ##重启网卡
[root@localhost ~]# ifconfig            ##查看网卡信息   可以看到已经配置好了
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500inet 192.168.100.100  netmask 255.255.255.0  broadcast 192.168.100.255inet6 fe80::fce1:77f:7a9:b103  prefixlen 64  scopeid 0x20<link>ether 00:0c:29:84:c1:e3  txqueuelen 1000  (Ethernet)RX packets 4869  bytes 6317526 (6.0 MiB)RX errors 0  dropped 0  overruns 0  frame 0TX packets 1544  bytes 119634 (116.8 KiB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536inet 127.0.0.1  netmask 255.0.0.0inet6 ::1  prefixlen 128  scopeid 0x10<host>loop  txqueuelen 1000  (Local Loopback)RX packets 216  bytes 21150 (20.6 KiB)RX errors 0  dropped 0  overruns 0  frame 0TX packets 216  bytes 21150 (20.6 KiB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255ether 52:54:00:95:60:04  txqueuelen 1000  (Ethernet)RX packets 0  bytes 0 (0.0 B)RX errors 0  dropped 0  overruns 0  frame 0TX packets 0  bytes 0 (0.0 B)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@localhost ~]# ping 192.168.100.1         ##ping一下网关看一下连接
PING 192.168.100.1 (192.168.100.1) 56(84) bytes of data.
64 bytes from 192.168.100.1: icmp_seq=1 ttl=128 time=1.93 ms
64 bytes from 192.168.100.1: icmp_seq=2 ttl=128 time=0.434 ms
64 bytes from 192.168.100.1: icmp_seq=3 ttl=128 time=0.693 ms
[root@localhost etc]# cd dhcp         ##进入到dhcp目录
[root@localhost dhcp]# ls             ##查看列表
dhclient.d  dhclient-exit-hooks.d  dhcpd6.conf  dhcpd.conf  scripts
[root@localhost dhcp]# cat dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.example
#   see dhcpd.conf(5) man page
#
##复制上面的路径把“*”去掉改为- tab补全会有4.25版本
[root@localhost dhcp]# cp /usr/share/doc/dhcp
-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp:是否覆盖"/etc/dhcp/dhcpd.conf"? yes
[root@localhost dhcp]# vim /etc/dhcp/dhcpd.conf   ##编辑dhcp.conf
# option definitions common to all supported networks...7 option domain-name "example.org";8 option domain-name-servers 8.8.8.8:;         ##配置DNS9 10 default-lease-time 600;11 max-lease-time 7200;12 13 # Use this to enble / disable dynamic dns updates globally.14 #ddns-update-style none;15 16 # If this DHCP server is the official DHCP server for the local17 # network, the authoritative directive should be uncommented.18 #authoritative;19 20 # Use this to send dhcp log messages to a different log file (you also21 # have to hack syslog.conf to complete the redirection).22 log-facility local7;23 24 # No service will be given on this subnet, but declaring it helps the 25 # DHCP server to understand the network topology.26 27 subnet 192.168.10.0 netmask 255.255.255.0 {   28   range 192.168.10.128 192.168.10.200;29   option routers 192.168.10.1;30   option domain-name-servers 8.8.8.8;31 }32 33 subnet 192.168.20.0 netmask 255.255.255.0 {34   range 192.168.20.128 192.168.20.200;35   option routers 192.168.20.1;36   option domain-name-servers 8.8.8.8;37 }38 subnet 192.168.100.0 netmask 255.255.255.0 {39   range 192.168.100.128 192.168.100.200;40   option routers 192.168.100.1;41   option domain-name-servers 8.8.8.8;42 }43 # This is a very basic subnet declaration.44 45 subnet 10.254.239.0 netmask 255.255.255.224 {46   range 10.254.239.10 10.254.239.20;47   option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;48 }

[root@localhost dhcp]# setenforce 0                   ##关闭防火墙
[root@localhost dhcp]# iptables -F                    ##清空防火墙
[root@localhost dhcp]# systemctl restart dhcpd        ##重启DHCP服务

验证一下

PC>ipconfig /renewIP ConfigurationLink local IPv6 address...........: fe80::350f:e8de:f309:7058%4
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.10.128
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.10.1
Physical address..................: 54-89-98-44-21-4C
DNS server........................: 8.8.8.8PC>
已经分配到dhcp的地址

DHCP中继原理及配置实操相关推荐

  1. 三坐标测头标定原理和标准球实操

    测头标定 三坐标测量机测头标定是测量过程中非常重要的一个环节,在标定过程中产生的误差将影响最终的测量结果,特别是标定不同位置.角度和长度的测头时,标定结果的准确性显得尤其重要.因为在后续的测量过程中如 ...

  2. DHCP Snooping原理和配置

    DHCP Snooping原理和配置 基本原理 配置 一.基本原理 DHCP Snooping 功能: 使能该技术可以防止非法用户攻击,使得客户端可以从合法的服务器获取IP. 过程:使能了DHCP S ...

  3. 大数据项目之电商数仓、日志采集Flume配置概述、日志采集Flume配置实操

    文章目录 4. 用户行为数据采集模块 4.3 日志采集Flume 4.3.2 日志采集Flume配置概述 4.3.2.1 TailDirSource 4.3.2.2 KafkaChannel 4.3. ...

  4. 【网络工程】6、防火墙介绍及配置实操

    接上篇<5.路由器介绍及配置实操> 之前我们讲解了网络设备路由器的介绍,以及完成了路由器的相关配置实操.本篇我们来讲解防火墙的基础知识以及相应的实操案例. 一.什么是防火墙? 防火墙是一个 ...

  5. DHCP和DHCP中继功能与配置

    DHCP和DHCP中继 DHCP DHCP主要用途 使用DHCP的好处 DHCP的典型应用模式 DHCP采用的传输协议 DHCP的IP地址自动获取工作原理 DHCP中继 应用场景 工作原理 DHCP配 ...

  6. DHCP中继原理解析

    DHCP中继 当企业的内部网络规模较大时,通常被划分为多个不同的子网,网络内配置了VLAN,VLAN能隔离广播,而DHCP协议使用广播.DHCP服务器在哪个vlan中,就只有在相同vlan内的客户机能 ...

  7. 华为交换全局配置dhcp中继_交换机配置DHCP中继

    华为S2700/S3700/S5700/S9300二三层交换机配置DHCP中继 DHCP中继 DHCP Relay即DHCP中继,它是为解决服务器和客户端不在同一个网段而提出来的,它提供了对DHCP广 ...

  8. 华为路由器isis配置实例_华为-ISIS路由协议(原理+配置实操)

    文章目录 一.ISIS概述 1.1 简述IS-IS动态路由协议 1.2 华为IS-IS的路由种类和功能 1.3 邻居关系的建立 1.4 NSAP地址 1.5 IS-IS状态协议 1.6 IS-IS配置 ...

  9. DHCP 服务原理与配置

    目录 1. DHCP 简介 2. DHCP 的好处 3. DHCP 的分配方式 4. DHCP 租约过程和续租 4.1 租约过程简述 4.2 租约过程详细解释 (1) 客户端进行 IP 请求 (2) ...

最新文章

  1. 2.monotouch 控件的使用
  2. 对采用rsync+inotify数据同步方式进行健康检测
  3. CreateDirectory GetCurrentDirectory 和SetCurrentDirectory
  4. python整数逆序输出_利用Python实现倒序任意整数
  5. Render errors:One or more layouts are missing the layout_width or layout_height attributes
  6. 1058. A+B in Hogwarts (20)
  7. LeetCode 435 无重叠区间
  8. 如何使用KingShard构建MySQL集群
  9. iOS连续上传多张图片
  10. c语言实现一个编译器生成语法树,运用JavaScript构造C语言子集的编译器
  11. 《单词的减法》state1~state17(第一遍学习记录)
  12. 2021年上半年数据库系统工程师下午真题及答案解析
  13. OV5640的初始化
  14. 对Python【返回函数与闭包】的一点思考
  15. 什么是大数据和大数据平台?
  16. 江苏大学计算机学院姚奕如,小博传递 || 江苏大学第一届计算机文化节成功举办!...
  17. python国际象棋ai程序_只需五步!手把手教你搭建国际象棋AI机器人
  18. Dev-C++安装OpenCV
  19. capslock键英语怎么读_Caps Lock怎么读
  20. U盘启动盘怎么制作?

热门文章

  1. 直播推荐、搜索中的召回、相关性、多目标精排 - 相关性篇
  2. 如何用深度强化学习自动炒股
  3. 冲压用钢板的边角料管理
  4. apollo 路面检测分析
  5. 这份Java八股文堪称offer收割机
  6. 超好理解的哈夫曼树(最优二叉树)与例题
  7. 【论文笔记】SAFER: A Structure-free Approach for Certified Robustness to Adversarial Word Substitutions
  8. Java编写五子棋小游戏
  9. tqdm的多行显示与单行显示
  10. zabbix -server启动报错 Cannot bind socket to “/var/run/zabbix/zabbix_server_alerter.sock