用华为模拟器ENSP构造校园网(第一天)配置网络简易DHCP的中继

接下来就是进入正题:就是配置代码:

  1. 先是配置DHCP,这个主要是为了将各个交换机与路由器之间实现互通:

开始配置:

这个交换机与路由器是很多的所以在配置DHCP的时候要使用中继,或者可以直接在三层交换机之间配置DHCP,这个直接配置只能在小型的网络中,所以大多数要采用中继服务:
代码呈现:所以我们开始配置DHCP中继:

先拿一个小的拓扑图演示一下DHCP中继:

  1. 图为:
  2. 用华为模拟器ENSP构造校园网(第一天)配置网络简易DHCP的中继_第1张图片

 代码如下:

1、先配置中间的三层交换机:

sys(进入配置模式)
[Huawei]sys sw1(改名)
[sw1]vlan batch 10 20 100(建立vlan)
[sw1]dhcp enable (开启DHCP模式)
[sw1]int GigabitEthernet 0/0/3(进入接口3)
[sw1-GigabitEthernet0/0/3]port link-type access (将接口变成连接模式)
[sw1-GigabitEthernet0/0/3]port default vlan 100(允许通过vlan100)
[sw1-GigabitEthernet0/0/3]q
[sw1]int g	
[sw1]int GigabitEthernet 0/0/4
[sw1-GigabitEthernet0/0/4]port link-type access 
[sw1-GigabitEthernet0/0/4]port default vlan 100
[sw1-GigabitEthernet0/0/4]q
[sw1]int g	
[sw1]int GigabitEthernet 0/0/2
[sw1-GigabitEthernet0/0/2]port link-type access 
[sw1-GigabitEthernet0/0/2]port default vlan 20
[sw1-GigabitEthernet0/0/2]q
[sw1]int g	
[sw1]int GigabitEthernet 0/0/1
	
[sw1-GigabitEthernet0/0/1]port link-type access 
[sw1-GigabitEthernet0/0/1]port default vlan 10
[sw1-GigabitEthernet0/0/1]q
[sw1]int	
[sw1]interface vlan	
[sw1]interface Vlanif 10
[sw1-Vlanif10]ip address 192.168.10.254 24(配置vlan IP做服务器的网关)
[sw1]int Vlanif 100
[sw1-Vlanif100]ip ad 192.168.100.254 24
[sw1-Vlanif100]q
[sw1]int Vlanif 20
[sw1-Vlanif20]ip ad 192.168.20.254 24
[sw1-Vlanif20]q
[sw1]
[sw1]int Vlanif 100
[sw1-Vlanif100]dhcp select relay (进入中继模式配置)
[sw1-Vlanif100]dhcp relay server-ip 192.168.10.253(输入服务器的IP,这个IP与服务器的出端口的IP是一样的)
[sw1-Vlanif100]
[sw1]int Vlanif 20	
[sw1-Vlanif20]dhcp select relay 
[sw1-Vlanif20]dhcp relay server-ip 192.168.10.253
[sw1-Vlanif20]display this 
#(配置的最终结果)
interface Vlanif20
 ip address 192.168.20.254 255.255.255.0
 dhcp select relay
 dhcp relay server-ip 192.168.10.253

现在配置路由器的服务器:代码如下:

sys(进入配置模式)
[Huawei]sys R1(改名)	
[R1]dhcp enable (开启DHCP模式)
[R1]int GigabitEthernet 0/0/0(进入接口1)
[R1-GigabitEthernet0/0/0]ip ad 192.168.10.253 24(配置接口IP)
[R1-GigabitEthernet0/0/0]q
[R1]ip pool vlanl00(建立vlan100地址池)
[R1-ip-pool-vlanl00]network 192.168.100.0 mask 24(设置地址段)	
[R1-ip-pool-vlanl00]gateway-list 192.168.100.254(设置网关)
[R1-ip-pool-vlanl00]dns-list 114.114.114.114(设置DNS)
[R1-ip-pool-vlanl00]display this (显示出最终配置)
[V200R003C00]
#
ip pool vlanl00
 gateway-list 192.168.100.254 
 network 192.168.100.0 mask 255.255.255.0 
 dns-list 114.114.114.114 
#
return
[R1-ip-pool-vlanl00]excluded-ip-address 192.168.100.100 192.168.100.200(排除网段)
[R1-ip-pool-vlanl00]q
[R1]ip pool vlan20(设置vlan20地址池)
[R1-ip-pool-vlan20]network 192.168.20.0 mask 24
[R1-ip-pool-vlan20]gateway-list 192.168.20.254
[R1-ip-pool-vlan20]dns-list 114.114.114.114
[R1-ip-pool-vlan20]excluded-ip-address 192.168.20.100 192.168.20.200
[R1-ip-pool-vlan20]lease day 24(配置时间)
[R1-ip-pool-vlan20]q
[R1]int g	
[R1]int GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]dhcp select global (将DHCP配置到全局)
[R1-GigabitEthernet0/0/0]q
[R1]ip route-static 0.0.0.0 0.0.0.0 192.168.10.254(配置默认路由)为了路由的通畅)

如果有啥不懂的可以留言来交流一下

你可能感兴趣的:(ENSP,华为,网络,网络协议,命令模式,源代码管理)