How does a router get its IP address assigned?

Solution 1:

IANA is the organization responsible for global IP assignments. They assign "blocks" of IP addresses to Regional Internet Registries which are geographically based organizations responsible for allocation within their geographic areas -- there are 5 RIR's:

  • AfriNIC (Africa)
  • LACNIC (Latin America & Caribbean)
  • APNIC (Asia Pacific)
  • ARIN (United States, Canada, parts of the Caribbean, Antarctica)
  • RIPE NCC (Europe, Russia, the Middle East, and Central Asia)

From there, smaller blocks of addresses are assigned by the RIR to a LIR (Local Internet Registry). This includes your ISP.

It is up to each organization to manage their assigned block(s) of IP Addresses. This is usually done using some kind of IPAM (IP Address Management) software.

How each LIR assigns addresses from within it's allocation is up to them.

From a practical perspective, addresses are assign manually (by an admin or sometimes a configuration management system) as opposed to DHCP. For example, to assign an IP address to ethernet interface #4 on a Cisco router, an admin would need to connect to the router (eg, using SSH) and issue commands similar to:

Router> enable
Router# configure terminal
Router(config)# interface fastethernet 4
Router(config-int)# ip address 192.0.2.1 255.255.255.0
Router(config-int)# no shutdown
Router(config-int)# exit

If you want to know about how all the information is aggregated and shared between LIR's, then you need to read up on AS Numbers and the BGP protocol.

Solution 2:

(Here I'm talking about the customer edge router. The one which is on your LAN. In the ISP network, the router is usually/probably configured manually).

If you have a PPP-based connection (PPPoE, PPPoA, PPPoEoA), your router will receive its IP addresses from the ISP addresses:

  • using IPCP for IPv4;

  • using IPCPv6 and SLAAC or DHCPv6 for IPv6.

If you have non-PPP-based connection (IPoE, IPoA, IPoEoA), the router will receive its IP addresses from the ISP using the same method your machine gets its IP addres from the router:

  • using DHCP (for IPv4);

  • using SLAAC or DHCPv6 for IPv6.

For IPv6, the local network usually has a whole IPv6 delegated prefix, for example a /60, /56 or /48. This prefix is announced to the router using the DHCPv6 IA_PD option.

The assignment of the IP addreses is done the using the same mechanisms as on the LAN:

  • either static allocation is used;

  • or a pool of available addreses is managed by the DHCP server;

  • in the case of IPv6, the IPv6 address may be negociated with SLAAC which is designed to avoid and detect conflicts.