Answer: An IP address is assigned to a computer by a Dynamic Host Configuration Protocol (DHCP) server, or manually by an administrator in static configurations.
Dynamic Host Configuration Protocol (DHCP)
Most commonly, a DHCP server automatically assigns an IP address to a computer within a network. The DHCP server, which can be a router or a dedicated server, allocates an available IP address from a pool of IPs for a specified duration, known as a lease time.
Static Configuration
Alternatively, an IP address can be manually assigned by a network administrator. This method is often used for servers or network devices that require a consistent IP address. The administrator selects an IP address within the network’s address range and configures the device with this static IP.
Conclusion
IP addresses are assigned either dynamically by a DHCP server, providing ease of management and scalability for large networks, or manually through static configuration for devices needing fixed IP addresses.