Using APIPA i.e. Automatic Private IP Addressing, DHCP clients can automatically self-configure an IP address and subnet mask when a DHCP server isn't available. When a DHCP client boots up, it first looks for a DHCP server in order to obtain an IP address and subnet mask. If the client is unable to find the information, it uses APIPA to automatically configure itself with an IP address from a range that has been reserved especially for Microsoft.
If a network client fails to get an IP address using DHCP, it can discover an address on its own using APIPA.To get an IPv4 address, the client will select an address at random in the range 169.254.1.0 to 169.254.254.255 (inclusive), with a netmask of 255.255.0.0. The client will then send an ARP packet asking for the MAC address that corresponds to the randomly-generated IPv4 address. If any other machine is using that address, the client will generate another random address and try again.
The APIPA service also checks regularly for the presence of a DHCP server (every five minutes, according to Microsoft). If it detects a DHCP server on the network, APIPA stops, and the DHCP server replaces the APIPA networking addresses with dynamically assigned addresses.