Dhcp自动分配ip地址

 

注明:首先我们用华为模拟器,然后虚拟机选择vm8 来操作dhcp自动获取的实验

 

 

二层交换机

<Huawei>u t m 关闭永不超时

Huawei>sys

Enter system view, return user view with Ctrl+Z.

[Huawei]vlan b

[Huawei]vlan batch 10 20 30

Info: This operation may take a few seconds. Please wait for a moment...done.

[Huawei]int e0/0/1

[Huawei-Ethernet0/0/1]p l a

[Huawei-Ethernet0/0/1]p d v 10

[Huawei-Ethernet0/0/1]int e0/0/2

[Huawei-Ethernet0/0/2]p l a

[Huawei-Ethernet0/0/2]p d v 10

[Huawei-Ethernet0/0/2]int e0/0/3

[Huawei-Ethernet0/0/3]p l a

 

[Huawei-Ethernet0/0/3]p d v 20

[Huawei-Ethernet0/0/3]int e0/0/4

[Huawei-Ethernet0/0/4]p l a

[Huawei-Ethernet0/0/4]p d v 30

[Huawei-Ethernet0/0/4]int e0/0/5

[Huawei-Ethernet0/0/5]p l a

[Huawei-Ethernet0/0/5]p d v 10

[Huawei-Ethernet0/0/5]int g0/0/1

[Huawei-GigabitEthernet0/0/1]p l t

[Huawei-GigabitEthernet0/0/1]p t a v a

 

三层交换机

 

<Huawei>u t m

Info: Current terminal monitor is off.

<Huawei>sys

Enter system view, return user view with Ctrl+Z.

[Huawei]int g0/0/1

[Huawei-GigabitEthernet0/0/1]p l t

[Huawei-GigabitEthernet0/0/1]p t a v a

[Huawei-GigabitEthernet0/0/1]undo sh

[Huawei]v b 10 20 30

Info: This operation may take a few seconds. Please wait for a moment...done.

[Huawei]int vlanif 10

[Huawei-Vlanif10]ip add 20.0.0.1 24

[Huawei-Vlanif10]int vlanif 20

[Huawei-Vlanif20]ip add 192.168.10.1 24

[Huawei-Vlanif20]int vlanif 30

[Huawei-Vlanif30]ip add 192.168.20.1 24

[Huawei-Vlanif30]q

[Huawei]dhcp enable   开启dhcp模式

Info: The operation may take a few seconds. Please wait for a moment.done.

[Huawei]ping 20.0.0.88  跟中继服务器ping一样是通的

  PING 20.0.0.88: 56  data bytes, press CTRL_C to break

    Reply from 20.0.0.88: bytes=56 Sequence=1 ttl=64 time=50 ms

    Reply from 20.0.0.88: bytes=56 Sequence=2 ttl=64 time=80 ms

    Reply from 20.0.0.88: bytes=56 Sequence=3 ttl=64 time=40 ms

    Reply from 20.0.0.88: bytes=56 Sequence=4 ttl=64 time=20 ms

    Reply from 20.0.0.88: bytes=56 Sequence=5 ttl=64 time=90 ms

 

[Huawei]int vlanif 10

[Huawei-Vlanif10]dhcp select relay 选择中继

[Huawei-Vlanif10]dhcp relay server-ip 20.0.0.88 中继ip地址是20.0.0.88

[Huawei-Vlanif10]int vlanif 20

[Huawei-Vlanif20]dhcp select relay

[Huawei-Vlanif20]dhcp relay server-ip 20.0.0.88

[Huawei-Vlanif20]int vlanif 30

[Huawei-Vlanif30]dhcp select relay

[Huawei-Vlanif30]dhcp relay server-ip 20.0.0.88

模拟器这边就配完了

那我们下一步就是在虚拟机上配置了

首先如果要想完成dhcp的配置,我们首先要按照rpm软件包

 

[root@localhost~]#rpm-ivh /mnt/Packages/dhcp-4.2.5-58.el7.centos.x86_64.rpm 软件包

然后在

[root@localhost ~]# vi /etc/dhcp/dhcpd.conf 里面进行配置

这边有几点需要大家注意,我在图中标注了四个箭头,前三个箭头是想让大家注意分配三个不同网段的地址池是需要另起一段重新配置的,而不是直接在上个地址池下面直接添加,最后一个箭头是给某个特定的mk地址配置一个指定的ip地址,mk地址间的间隔一定是:而不是- 否则会有报错,操作好之后就可以保存退出了

然后双击模拟器上的主机在基础配置里面选择DHCP应用,然后我们开始抓包

会有dhcp的四个报文

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐