When and how does a device get information about default gateway in LAN? I know you can define default gateway statically, but which protocol is used when it is not statically defined? Is it from discovered DHCP server (by broadcast and dhcp_discover) together with leased IP address?


As you note, gateways can be statically configured. You can have a default gateway (gateway of last resort to and/or gateways for more specific networks (prefixes longer than 0). A gateway is the host on a network that is used to reach other networks.

An IPv4 host can receive a default gateway from the DHCP (Dynamic Host Configuration Protocol) server if it is using DHCP to configure the host addressing. An IPv4 gateway needs to be in the same network as the host interface it serves, otherwise you would need a gateway to reach the gateway, and it does not work that way.

An IPv6 host will receive its gateway(s) from NDP (Neighbor Discovery Protocol), specifically from the RAs (Router Advertisements). Unlike IPv4, the IPv6 gateways will be the router(s) Link-Local address(es) for all networks configured on the host interface (IPv6 allows multiple networks on a single interface), not an address in the network for which it is a gateway.

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.