Advertisement

Responsive Advertisement

Recent in Technology

DHCP & NAT

DHCP

This is an abbreviation for Dynamic Host Configuration Protocol. The Dynamic IP addresses mentioned earlier are assigned by DHCP. DHCP can assign IP Addresses dynamically. This means that the IP received on one connection will not be the same on the next connection; it changes.

Devices within a Local Area Network (LAN) can use a Private IP address to communicate with each other. The Public Address is the same for all devices in that network. Why are they the same? Because they all exit through a single router/gateway provided by the ISP (Internet Service Provider). Therefore, all devices connected to that router have the same Public IP. Only their Private IPs are different.

When we connect to a network (e.g., a WiFi network), we have to send a request for an IP Address to the DHCP Server. When the DHCP Server receives that request, it sends a DHCP Offer back as a response. The DHCP Offer includes information such as the IP Address, subnet mask, default gateway, DNS server, and lease duration. (Lease duration refers to the period of time for which the received IP address can be used).

The DHCP Offer can be one or more than one at the same time. When this happens, the device that made the request selects one of the offers and sends another DHCP request to the corresponding server. This stage signifies that the device has accepted the offer. When the DHCP server receives this request, it sends back a DHCPACK (DHCP Acknowledgement) response and grants permission to use the connection with the assigned IP. The connecting device then uses the information received in the DHCPACK to reconfigure its network settings. Only then can it enter and use the network with its assigned ip.

We don't get to see these processes step-by-step. That's why we don't know that so many actions have to be performed. All we see is that we plug in a network cable to a computer and can use the internet within seconds. Or, we select the WiFi we want to connect to, type in the password, and can start using the WiFi. This is all we get to see.

NAT

NAT is an abbreviation for Network Address Translation. The NAT Protocol translates an Internal private IP address into an External public IP address. (This allows it to be part of the international network, not just the local network).

Private IP addresses used within a LAN cannot be used to connect to the internet. One of the reasons is that those private IP addresses exist in every LAN (they are not unique).

To make it easy to understand, let's take a home WiFi network as an example. Let's say you have a WiFi network at home, and two computers are connected to it. When I open example.com from one computer, it must open on the computer I'm using, not the other one. (Viewing a web page means our browser sends a Get request, and the browser displays the Response that comes back from the Web server).

The response that comes back from the Web Server needs to know exactly which computer's request it is a response to. Only then will the web page I opened not be sent as a response to the other computer.

NAT is what makes this process work smoothly. When our computer sends a request to connect to the internet, NAT devices receive it and log it in a Table. It then changes the machine's IP in that log to the router's external IP address. When a response comes back from the server, NAT checks it against the original requests in its table and forwards the response back to the Local IP of the device that made the request.

Post a Comment

0 Comments