10

Is the router always broadcasting "I'm here" (say, every period of time) and the computer listens or the router listens and once the computer broadcasts "is there a router here?" It responds? It sounds like a silly question but I can't find an answer. Although I do know that when the computer already knows of the existence of the router it makes the first request for an IP address.

9

Looking at your question it looks like you're confusing DHCP and routing.

To be clear, they both accomplish different tasks and really have nothing to do with each other. DHCP is a way to dynamically assign IPs to clients. Routing allows you to get from one network to another.

To answer your question.. There are really two ways in which your computer will know there is a router on the network. Either because you have manually assigned an IP address/subnet mask with a default gateway (default gateway being the router), or because the computer has been set to request an IP via DHCP and within the DHCP offer it received from the server it contained a default gateway for the client to use.

The client will not attempt any communication with a router until it has an IP address and default gateway configured (again manually or via dhcp). The computer will then look at its own IP address and subnet mask to determine if the IP address it is trying to communicate with is on its local network. If it is then it will attempt to send the data straight to the device and if it is not then it will look at its configured default gateway (router) and send it there. The router will then send the traffic to the destination because it has a route, or to another router that might know where the destination network exists.

  • I notice that the ARP assumes x.x.x.1 when it first comes up (via wireshark). How does it officially "ask" for the router? What if the router isn't on x.x.x.1? What ARP does it broadcast, or is .1 reserved? – PeterT Sep 9 at 2:47
2

With IPv4, a computer doesn't really know about a router. A host will have a configured gateway, to which it will send any traffic destined for a different network. The gateway is probably a router, but not necessarily. The gateway is either manually configured, or assigned via DHCP. The host doesn't have a configured gateway until one is either manually or dynamically assigned. That means that it cannot communicate to a different network until one is assigned.

On the other hand, IPv6 has added ND (Neighbor Discovery), and part of ND includes RAs (Router Advertisements). Routers can be configured to advertise their existence, and the local network prefix. This allows IPv6 hosts to configure themselves without DHCP, although there is a version of DHCP for IPv6.

  • The IP gateway is, by definition, a router. – Ron Royston Jul 16 '16 at 2:43
  • No, not necessarily. Under almost all circumstances it is, but there are some oddball cases where the gateway could be something else, not necessarily sending the traffic to a different network the way a router would. – Ron Maupin Jul 16 '16 at 2:46
1

Modern Ethernet controllers have link state detection. They can detect when a link is established to their Ethernet port.

The situation is a bit different for IPv4 and IPv6. First the IPv4 scenario.

When the Ethernet cable is plugged in the OS detects this through link state detection. If the interface is configured for DHCP then the client will send out a DHCP request. In a typical home/small buisness network the router will run a DHCP server which will assign the client an IP address and also tell the client what subnet mask, default gateway and DNS servers to use. In a larger network the router and the DHCP server may be on different devices.

If no DHCP server is found the client may keep trying and/or it may assign a local IP using "automatic private IP addressing".

IPv6 is a little more complicated. Unlike IPv4 nodes IPv6 nodes always have a link local address which they assign themselves. For Internet access they will need a global scope address and related settings. There are three main posibilities for IPv6 autoconfiguration.

  1. RAs only. The router sends out advertisements telling clients what prefixes are on the link and what networks the router offers routes to (including a default gateway if applicable). The advertisements are sent to all IPv6 nodes on the link (this is technically classed as a multicast but practically its the closest thing IPv6 has to a broadcast) and inform the clients of the prefix they should be using and the addresses of routers. Clients can send out a request to prompt a RA to be sent sooner than the router would have sent it. Clients construct their own IPv6 addresses based on the prefix. Older systems used a single address based on their MAC address, more modern systems with privacy extensions will use multiple short-lived addresses. Unfortunately RAs do not provide DNS server configuration, so on their own they are inadequate for autoconfiguration of IPv6 only clients.
  2. RAs with stateless DHCPv6. Here addressing is handled by RAs as above but DNS server details (and possiblly other less important configuration) is handed out by a DHCP server in response to a client request.
  3. Stateful DHCPv6, this works much like DHCP for IPv4.
0

When your PC is turned on, it uses the DHCP protocol to request an IP-address and network settings. Every time a packet is then sent from the computer it will send it to the default gateway of the router. The router is not consistently pinging out 'hello im here' more like the host will direct traffic when it needs to. - Hope this clarifies it.

  • Before requesting IP. How does my computer know that there is a router around? That was my question – Zach P Jul 15 '16 at 9:13
  • It doesn't - thats why it sends the DHCP request as you boot the PC. If there is no router then it wouldn't return anything like your IP, subnet and default gateway. – CrazyHorse019 Jul 15 '16 at 9:17
  • <<Every time a packet is then sent from the computer it will send it to the default gateway of the router>> is not true. Computers on the same LAN send packets directly to one another. Also, the default gateway is the router. – Ron Royston Jul 16 '16 at 2:45
0

In the "conversation words".

You turn on your Computer and the Computer detects that there is a cable connected to your NIC.

Computer thinks "NICE! I'm connected to a network - is their a DHCP server online, so I know where I am??"

Computer sends out DHCP request.

Router/DHCP Server gets this request and says to the Computer:

"Hey! You are and this is your Netmask, your default gateway and other Informations - Welcome to the network!"

enter image description here

This only works if your NIC is configured for DHCP.

0

The router does not broadcast that it is there as a default gateway. A DHCP server does respond to a shout out (broadcast) from the endpoint though. Part of the DHCP response is the IP address of the default gateway (the router). Most routers have built in DHCP servers which are disabled by default. Many server/I.T. admins rather use Windows Server DHCP.

  • "The router does not broadcast that it is there to endpoints." An IPv6 router doesn't broadcast (IPv6 doesn't have broadcast), but it does, by default,multicast to all hosts that it is a router. – Ron Maupin Jul 16 '16 at 2:48
  • Like I said, The router does not broadcast that it is there to hosts. One of it's processes such as a routing protocol might do some broadcasting for other routers to listen for but that's another scenario. – Ron Royston Jul 16 '16 at 2:54
0

The best appropriate answer to your question is DHCP(Dynamic Host Configuration Protocol). When a computer or any network device connect to the network, it sends DHCP Discover Message with broadcast IP adress(255.255.255.255) to obtain its own IP adress. A DHCP server receiving a DHCP Discover Message responds to the client with an DHCP Offer Message. If we look closer to this message, we will look router option field in it. Here it is, hosts or any network device who want to obtain IP adress actually learn the IP adress of default gateway from this field.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.