Computer Science 🌋/Network Programming 🛰️
DHCP, Apr/3/2023
KB0129
2023. 4. 3. 09:54
How to assign an IP address to a host?
1. Manually: hard-coded by system admin in a file
- Windows: control-panel -> networking -> configuration -> TCP/IP -> properties.
- UNIX: /etc/rc.config
2. Automatically:
- DHCP: Dynamic Host Configuration Protocol
- DHCP is a plug and play protocol: a node can dynamically obtain an IP address when joining the network and release the IP address when leaving the network.
- Benefits: allow host to dynamically obtain its IP address from network server when it joins network.
- Reuse of address
- Supports for mobile users who want to join network for a short time.
- DHCP has a pool of available IP addresses. It assign the IP address to node, and return it into pool when a node leaves.
- Required IP addresses at each moment is less than total number of users.Each subnet has a DHCP-server, so any network has a DHCP server!
- DHCP client-server scenario
1. Broadcast: is there a DHCP server out there?
2. I'm a DHCP server! Here's an IP address you can use
3. OK, I wil take that IP address!
4. OK, you've got that IP address!
Step 3 and Step 4 are important.
Step 3:
- Connecting laptop needs its IP address, addr of first-hop router, addr of DNS server: use DHCP.
- DHCP request encapsulated in UDP, encapsulated in IP, encapsulated in 802.11 WLAN (WiFi).
- WLAN frame broadcast(dest: FFFFFFFFFFFFFF) on LAN, received at router running DHCP server.
- WLAN demuxed to IP, demuxed to UDP, demuxed to DHCP.
Step 4:
- DHCP server formulates DHCP ACK containing client's IP address, IP address of first-hop router for client, name & IP address of DNS server.
- Encapsulation of DHCP server, frame forwarded to client, demuxing up to DHCP at client.
- Client now knows its IP address, name and IP address of DNS server, IP address of its first-hop router.
There are 8 DHCP message types:
- Discover message (DHCPDiscover).
- Offer message (DHCPOffer).
- Request message (DHCPRequest).
- Decline message (DHCPDecline).
- Acknowledgement (DHCPAck).
- Negative Acknowledgment message (DHCPNak).
- Release message (DHCPRelease).
- Informational message (DHCPInform).