If you connect directly to your modem how does the IP address get assigned?
Solution 1:
The automatic assignment of IP addresses happens via a standard known as the Dynamic Host Configuration Protocol.
When a computer connects to the network, the DHCP client, generally a component of the operating system sends out a DHCP request and recieves an offer from a DHCP server. The offer generally contains:
- An IP Address
- A subnet mask for that IP address
- A gateway that should be used for off-network requests (like those going via the internet)
- One or more DNS server addresses so the computer knows where to send DNS requests.
Connecting to a Router
When you plug your computer into a router or associate your wireless adapter with an access point, the computer will usually receive a DHCP response directly from the router, which may itself have requested an IP from the ISP for the interface the modem uses. it will then route traffic from the computer via it's interface connected to the modem where appropriate.
Connecting to a Modem
When you connect your computer to a modem, the DHCP request generated by the computer may be handled directly by the modem itself if the modem is running a DHCP server.
Static Address Assignment
If the modem is not running a DHCP server, you may have to staticly configure the client device's IP address, subnet mask, default gateway and DNS servers. If this is the case, the correct values will be giiven to subscribers, or entered by a service technician when the service is setup.
Side note: This answer deals with addresses for end-user devices. Your modem also has an interface to the ISPs network, the address for this interface may also be configured by a DHCP server on the provider's network, however this depends how the provider chooses to configure their network.
Solution 2:
Your PC has software (DHCP client) that can request IP settings to be assigned to it by the ISP the same way the router does.
Solution 3:
In my experience, your modem is normally a DHCP client and a DHCP server, but they dont have to be either.
IF your modem is a DHCP client, then when you connect it to your upstream network (IE. Plug the modem into cable of the DSL Line) and power it on IT will ask for an address on that interface. The ISP will then respond with an address for the modem. Alternatively it might be a static assignment, where it turns on, sets the address that the cable tech probably set up, and begins communicating. Another alternative is that there may be some sort of login system combined in with either of these two options. This takes care of upstream traffic (modem to ISP)
IF your modem is a DHCP server (has been my experience as of late, then your device that plugs into the Modem will be asking for an address (similar to the modem asking the ISP above). Whatever device you plug in most likely has DHCP already turned on. If it is turned on already (whether router or computer) it is going to ask for an address. Alternatively, you may have been instructed to Set a manual address. In this case, the modem will most likely be expecting communication on this address and ignoring any other attempts. BONUS: The modem could potentially also act as a DHCP helper and forward your routers DHCP request to a place where it will get the REAL public IP that refers to your internet conection. 1
If you have a router doing DHCP for your home network as well (most common), then all of your other devices are going to be asking your router for an address as well.
Example Scenario: Power failure just ended. Everything starts back up. Modem asks ISP for its address, and gets one. Router asks Modem for address and gets one. (Maybe the public address!) Your Desktop computer finished booting and asks the router for an address, and the router gives it one. Now if the desktop asks for Google.com the router gets the request, the router forwards to the modem, the modem forwards to the ISP and the ISP forwards to the Internet, where it comes back down the other side to Google and Google responds. All of this happens in Usually Less than 20ms (~1/50th) of a second.
The Internet is incredible.
So, for a short answer, assuming you dont have DHCP turned off in your computer, it wont matter plugging into the modem directly or plugging your router into the modem and the computer into the router. But, using the router often does another process called NAT that allows you to have multiple devices behind your single internet connection, so routers are still usually recommended