华为路由器DHCP,为交换机划分不同网段实验


实验目的:通过DHCP,为交换机划分不同VLAN

拓扑结构

路由器配置,代码如下:



<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1
[R1]dhcp enable 
Info: The operation may take a few seconds. Please wait for a moment.done.
[R1]ip pool VLAN10       #创建名为Vlan10的全局地址池
[R1-ip-pool-VLAN10]NET	
[R1-ip-pool-VLAN10]network 192.168.10.0 mask 24
[R1-ip-pool-VLAN10]gat	
[R1-ip-pool-VLAN10]gateway-list 192.168.10.254
[R1-ip-pool-VLAN10]dns	
[R1-ip-pool-VLAN10]dns-list 8.8.8.8
[R1-ip-pool-VLAN10]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 8.8.8.8
[R1-ip-pool-VLAN20]q

[R1]int g0/0/0.10          #创建.10子接口
[R1-GigabitEthernet0/0/0.10]dot	
[R1-GigabitEthernet0/0/0.10]dot1q termination vid 10
[R1-GigabitEthernet0/0/0.10]arp br	
[R1-GigabitEthernet0/0/0.10]arp broadcast enable 
[R1-GigabitEthernet0/0/0.10]ip add 192.168.10.254 24
[R1-GigabitEthernet0/0/0.10]dhcp select g	
[R1-GigabitEthernet0/0/0.10]dhcp select global 
[R1-GigabitEthernet0/0/0.10]q

[R1]int g0/0/0.20          #创建.20子接口  
[R1-GigabitEthernet0/0/0.20]dot1q ter	
[R1-GigabitEthernet0/0/0.20]dot1q termination v	
[R1-GigabitEthernet0/0/0.20]dot1q termination vid 20
[R1-GigabitEthernet0/0/0.20]arp br	
[R1-GigabitEthernet0/0/0.20]arp broadcast e	
[R1-GigabitEthernet0/0/0.20]arp broadcast enable 
[R1-GigabitEthernet0/0/0.20]ip add 192.168.20.254 24
[R1-GigabitEthernet0/0/0.20]dhcp select global 
[R1-GigabitEthernet0/0/0.20]q
[R1]

交换机配置如下:

<Huawei>sys 
[Huawei]sys sw1
[sw1]vlan	
[sw1]vlan b	
[sw1]vlan batch 10 20      #创建 10 20两个Vlan

[sw1]dhcp e	
[sw1]dhcp enable           #开启DHCP

[sw1]int g0/0/10           #连接路由器接口配置Trunk ,并将 Vlan 10 20 放行
[sw1-GigabitEthernet0/0/10]port link-t	
[sw1-GigabitEthernet0/0/10]port link-type trunk 
[sw1-GigabitEthernet0/0/10]port all	
[sw1-GigabitEthernet0/0/10]port trunk allow-pass vlan 10 20
[sw1-GigabitEthernet0/0/10]q

[sw1]int g0/0/1            #将g0/0/1口配置access,并加到vlan 10
[sw1-GigabitEthernet0/0/1]port li	
[sw1-GigabitEthernet0/0/1]port link-t	
[sw1-GigabitEthernet0/0/1]port link-type a	
[sw1-GigabitEthernet0/0/1]port link-type access 
[sw1-GigabitEthernet0/0/1]port default v	
[sw1-GigabitEthernet0/0/1]port default vlan 10
 
[sw1]int g0/0/2            #将g0/0/2口配置access,并加到vlan 20
[sw1-GigabitEthernet0/0/2]port link-t	
[sw1-GigabitEthernet0/0/2]port link-type access 
[sw1-GigabitEthernet0/0/2]port de	
[sw1-GigabitEthernet0/0/2]port default v	
[sw1-GigabitEthernet0/0/2]port default vlan 20
[sw1-GigabitEthernet0/0/2]q

 查看IP获取结果:

PC1:

 PC2:

 

分别获取了分配的网段,完成!

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值