1. IP Addressing: IPv4, Subnets, Public and Private IPs
1.6 Static vs Dynamic IP and DHCP
Ghari Wi-Fi la connect kelyavar tumhi IP type karta ka? Nahi na? To DHCP deto. Server la matra fix address lagto. Chala baghu farak.
| Feature | Static IP | Dynamic IP |
|---|---|---|
| Assigned by | Manually by an admin (or reserved) | Automatically by a DHCP server |
| Changes? | Never, unless changed manually | May change on reboot / lease expiry |
| Best for | Servers, DNS records, printers, VPN endpoints | Laptops, phones, home users |
| Cost | Often extra (ISPs charge) | Usually included |
| AWS equivalent | Elastic IP | Auto-assigned public IPv4 |
DHCP (Dynamic Host Configuration Protocol) hands out IP address, subnet mask, default gateway and DNS server in four steps: Discover → Offer → Request → Acknowledge (DORA).
Client (no IP yet) DHCP server (router)
| 1. DISCOVER (broadcast: "any DHCP server?") |
| ------------------------------------------------> |
| 2. OFFER ("take 192.168.1.23") |
| <------------------------------------------------ |
| 3. REQUEST ("I want 192.168.1.23") |
| ------------------------------------------------> |
| 4. ACK ("done, lease 24 h, gw .1, dns .1") |
| <------------------------------------------------ |
Why this matters for security
Because DHCP trusts the first answer, an attacker on the same LAN can run a rogue DHCP server and hand out their own machine as the gateway or DNS server – a classic man-in-the-middle setup. Switches defend with DHCP snooping. On the server side, anything that must be reachable or referenced in DNS needs a static address (on AWS, an Elastic IP).
Ravindra Bagale's Tip
Khup students EC2 cha auto-assigned public IP DNS madhe takatat, ratri instance stop kartat, aani sakali website band! Stop/start nantar public IP badalto. Jyala fix address lagto tyala Elastic IP dya – he Part 6 madhe practically karu. Lakshat theva.
Practice task
On Windows run ipconfig /all and find DHCP Enabled, Lease Obtained and DHCP Server. On Linux run ip route and note your default gateway.