If I have a computer with a network card, it will have a MAC address and a localhost IP of So how does a computer with a network card discover routers and connect to them initially? I understand that once it is connected, the router will assign it an IP using DHCP or a static IP if that is configured.

But before the computer is connected to the network, isn't the only information associated with it, its MAC address? How does the computer send data to the router asking it to connect? Also there is no ARP capability yet since the computer does not have an IP.

This seems to be a purely layer 2 communication.


The computer can send any kind of data over its network interface – if you're connected to Ethernet, then the OS is in full control of the Ethernet frames that it sends. It's the OS, not the network hardware, that handles IP, ARP, and other protocols.

Rather, the only question is how regular programs on that computer are able to send data without having an IP address.

In IPv4, the DHCP client uses raw packet sockets – that means it directly sends layer-2 frames; the DHCP client has to build its own IP header when sending and performs its own filtering when receiving. (See for example packet(7) on Linux.)

When doing so, the DHCP client software will just fill in "" (aka the "unspecified" address) as the source address in IP packets used for DHCP 'discover' and 'request' messages. These packets are broadcast so the destination is "" and ARP is not necessary to send them, as IPv4 broadcasts use a fixed layer-2 address.

(So yes, you could say that DHCP in IPv4 is practically layer-2 communication that's just disguised as UDP/IP.)

In IPv6, meanwhile, a host will (generally) always have an automatically assigned "link-local" address on each interface. This means there is no need for raw sockets – infrastructure packets such as DHCPv6 requests or Router Solicitations can simply be sent from the link-local address using standard UDP or "raw IP" sockets. (The latter are documented in raw(7).)

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.