这里分享一下如何在eNSP模拟器中实现DHCP自动分配IP,首先我们建一拓扑图,如下所示:
图上显示的1、2、3为交换机端口,PC1和PC2同一个vlan 10,PC3为vlan 30,现在开始,代码如下:
<HUAWEI>sys
[HUAWEI]sysname Switch
[Switch]dhcp enable
[Switch]vlan 10
[Switch]vlan 30
[Switch]int vlan 10
[Switch-Vlanif10]ip add 192.168.10.1 24
[Switch-Vlanif10]dhcp select interface
[Switch-Vlanif10]dhcp server dns-list 192.168.10.254
[Switch-Vlanif10]dhcp server excluded-ip-address 192.168.10.254
[Switch]int g0/0/1
[Switch-GigabitEthernet0/0/1]port hybrid pvid vlan 10
[Switch-GigabitEthernet0/0/1]port hybrid untagged vlan 10
[Switch]int g0/0/2
[Switch-GigabitEthernet0/0/2]port hybrid pvid vlan 10
[Switch-GigabitEthernet0/0/2]port hybrid untagged vlan 10
[Switch]int vlan 30
[Switch-Vlanif30]ip add 192.168.30.1 24
[Switch-Vlanif30]dhcp select interface
[Switch-Vlanif30]dhcp server dns-list 192.168.30.254
[Switch-Vlanif30]dhcp server excluded-ip-address 192.168.30.254
[Switch]int g0/0/3
[Switch-GigabitEthernet0/0/3]port hybrid pvid vlan 30
[Switch-GigabitEthernet0/0/3]port hybrid untagged vlan 30
<Switch>sa
按以上设置完成后,现在来测试下,我们在PC1上双击打开命令输入ipconfig,如下图显示说明成功:
说明:配置那里一定要先DHCP这项,否则是获取不到IP的,如下设置即可
讨论数量:0