Vlan – dhcp failed. apipa is being used

dhcpvlan

I'm testing a network and I use the vlan among 20 vlan but in this packet tracer I just use 10 Vlan on my network,

In this case, I use the DHCP server on my multilayer switch, not on my router.

so on the port on multilayer swith to switch layer 2 I use:

switchport trunk encapsulation dot1q
switchport mode trunk

for the DHCP server on multilayer switch I use:

ip dhcp pool vlan1
network 192.168.0.0 255.255.255.0
default-router 192.168.0.1

and the same for other vlan.

I have add the vlan and the IP address like on the picture

enter image description here

but when I config on the all switch layer 2,

on fa0/1 who connected to multilayerswitch I use:

switchport mode trunk

and port fa0/2-3 who connected to PC I use:

switchport mode access
switchport access vlan <VLANID>
! VLANID == VLAN for respective switch

But there's some thing weird,

On VLAN 1 and 2 it's almost connected and get the dhcp ip success but on the other PC I cannot get the DHCP IP it's remarks "dhcp failed. apipa is being used"

please help,

Best Answer

Friend use configuration as below as you should have be sound basic knowledge

on router

Lab-R1> ena

Lab-R1# config t

Lab-R1(config)# ip dhcp pool myLAN

Lab-R1(dhcp-config)# network 192.168.0.0 255.255.255.0

Lab-R1(dhcp-config)# domain-name mydomain.lan

Lab-R1(dhcp-config)# default-router 192.168.0.1

Lab-R1(dhcp-config)# dns-server 192.168.0.2

Lab-R1(dhcp-config)# exit

Lab-R1(config)# ip dhcp excluded-address 192.168.0.1 192.168.0.120

at L2 sw

create vlan as 1 to 20 everyone have ip address with in same range as specified in router with each vlan have four ip address

int vlan 1
ip address  192.168.0.5 255.255.255.0

int vlan 2
ip address  192.168.0.10 255.255.255.0

.
..
..
.
.

int vlan 20 ip address  192.168.0.100 255.255.255.0

it's working