Print

HCL模拟器S5820交换机DHCP配置案例

2019-12-09 发表

组网及说明

现有一台S5820交换机,连接两个不同的局域网,现要求两个不同的局域网通过DHCP自动获取IP地址后实现互联互通。

网络拓扑图如下:


配置步骤

(1)、将交换机的名字修改为SW1

(2)、在交换机分别创建VLAN 10VLAN 20

(3)VLAN 10IP设置为:192.168.10.1 255.255.255.0

(4)VLAN 20IP设置为:192.168.20.1 255.255.255.0

(5)、将F0/1端口划分到VLAN 10

(6)、将F0/2端口划分到VLAN 20

(7)、开启DHCP功能

(8)、分别创建两个地址池,分配子网、默认网关、DNS

(9)PC_2PC_3都能通过DHCP自动获取IP地址


配置关键点

将交换机的名字修改为SW1

system-view

[H3C]sysname SW1

 

在交换机分别创建VLAN 10VLAN 20

[SW1]vlan 10

[SW1-vlan10]quit

[SW1]vlan 20

[SW1-vlan20]quit

 

VLAN 10IP设置为:192.168.10.1 255.255.255.0

 

 

[SW1]int vlan 10

[SW1-Vlan-interface10]ip address 192.168.10.1 24

[SW1-Vlan-interface10]quit

 

VLAN 20IP设置为:192.168.20.1 255.255.255.0

[SW1]int vlan 20

[SW1-Vlan-interface20]ip address 192.168.20.1 24

[SW1-Vlan-interface20]quit

 

GI1/0/1端口划分到VLAN 10

[SW1]int gi 1/0/1

[SW1-GigabitEthernet1/0/1]port link-type access

[SW1-GigabitEthernet1/0/1]port access vlan 10

[SW1-GigabitEthernet1/0/1]quit

 

GI1/0/2端口划分到VLAN 20

[SW1]int gi 1/0/2

[SW1-GigabitEthernet1/0/2]port link-type access

[SW1-GigabitEthernet1/0/2]port access vlan 20

[SW1-GigabitEthernet1/0/2]quit

 

开启DHCP功能:

 

[SW1]dhcp enable

 

创建DHCP地址池,命名为VLAN10,分配网段、子网掩码、默认网关、DNS

[SW1]dhcp server ip-pool vlan10

[SW1-dhcp-pool-vlan10]network 192.168.10.0 mask 255.255.255.0

[SW1-dhcp-pool-vlan10]gateway-list 192.168.10.1

[SW1-dhcp-pool-vlan10]dns-list 114.114.114.114

[SW1-dhcp-pool-vlan10]quit

[SW1]

 

创建DHCP地址池,命名为VLAN20,分配网段、子网掩码、默认网关、DNS

[SW1]dhcp server ip-pool vlan20

[SW1-dhcp-pool-vlan20]network 192.168.20.0 mask 255.255.255.0

[SW1-dhcp-pool-vlan20]gateway-list 192.168.20.1

[SW1-dhcp-pool-vlan20]dns-list 114.114.114.114

[SW1-dhcp-pool-vlan20]quit

 

 

PC0PC1都能通过DHCP自动获取IP地址:



在交换机查看DHCP分配的情况:

[SW1]dis dhcp server ip-in-use

IP address       Client identifier/    Lease expiration      Type

                 Hardware address

192.168.10.2     0033-3661-612e-3339-  Dec 10 21:35:46 2019  Auto(C)

                 3463-2e30-3230-362d-

                 4745-302f-302f-31

192.168.20.2     0033-3661-612e-3430-  Dec 10 21:35:55 2019  Auto(C)

                 3135-2e30-3330-362d-

                 4745-302f-302f-31

[SW1]