How does a router get its IP address assigned?

8,675

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:

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.

Solution 3

The ISP also has a DHCP server, just like your router. The DHCP server may have your old address cached like previous answers posted, and may give you a new address if not.

DHCP sometimes runs directly over your uplink, and sometimes it is terminated at the network equipment that runs the uplinks. In bridged mode, for example, DHCP is used to assign the address directly. For PPP connections (like PPPoA, PPPoE etc.) the DHCP pool is used to supply addresses but the actual configuration is done by the PPP service.

IP-address allocation is pretty much the same for all networks until you reach the RIR blocks.

Basically, you have a globally limited amount of IP addresses, which are divided in to blocks. Those blocks are then given to geographical areas, which in turn are divided in to block which are given to ISP's. IP blocks can be requested when you run out, can be bought form companies, or 'rented' form ISP's.

There are organisations that manage IP allocation to make sure it is known what IP block belongs to someone. It flows like this:

IANA has all of the IP addresses, which get divided in to blocks and those blocks are re-divided by RIR's. A RIR is a Regional Internet Registry. Each RIR covers a geographic area, there are 5 in total. The RIR's in turn divide their IP blocks, and give them out on request to i.e. LIR's and NIR's: Local Internet Registries and National Internet Registries. ISP's and businesses and if I'm not mistaken, individuals, can then request IP addresses from those LIR's or NIR's and in some cases directly form RIR's.

What you do with your block of IP addresses is up to you. To make use of them, it would make sense to make sure the internet knows where your IP address is, on what network, and how to get there. That is done with routers and gateways using protocols such as BGP which makes it possible to let networks communicate to each other so they know they exist and know what networks they make available. But at this point, we're getting past IP-adresses. (if you want to know more, look up Autonomous Systems, peering and BGP)

Most of that information can be found here: http://www.internetassignednumbersauthority.org/numbers

So basically, after a few organisations, a range of IP addresses (a block) is divided and split in to smaller unites down the line and at some point owned by an ISP. That ISP then lets other ISP's know that it has that range of IP addresses so it can be used to communicate. At that point the ISP's network is ready and only needs to allocate a single IP to a client's network which then becomes the client's WAN IP address.

Now, an ISP cannot tell other ISP's that it owns IP addresses it doesn't actually own, because it wouldn't match the registries at the LIR/NIR/RIR level which can be publicly checked (and automatically as well). So at that level, duplicate IP's are not going to happen. When a rogue ISP tries to do that anyway, it pretty much gets disconnected from the rest of the internet by not allowing it to communicate with other ISP's (as they basically pull the plug on the fake ISP's network-connections to their own networks).

This leaves you at the ISP-level of things. Since the ISP knows what addresses it has, and know what clients it has, and on which network connections those clients are connected, it can simply enforce it's rules by not allowing a client to use an IP that is not assigned by the ISP. It simply ignores all internet traffic from a client that's not supposed to be there. Assigning IP addresses as explained at the top is done by a system that remembers who was given what IP address and as such it never gives out the IP address twice.

Share:
8,675

Related videos on Youtube

Justin Hou
Author by

Justin Hou

Updated on September 18, 2022

Comments

  • Justin Hou
    Justin Hou over 1 year

    I understand how a device connecting to a router (e.g. 72.73.74.75) gets assigned a local IP address (e.g. 192.168.1.5) using DHCP.

    BUT, how does the router itself get the IP address assigned from the ISP in the first place? How does it make sure another server on the Internet isn't assigned the same IP address?

  • joeqwerty
    joeqwerty about 9 years
    Good answer. Additionally, on a more practical note, the actual assignment/configuration of the ip address on the router itself is either done manually by someone with administrative access to the router or automatically by the ISP as in the case of DSL, cable internet, etc.
  • fukawi2
    fukawi2 about 9 years
    Good point, updated the answer to include practical example.
  • dunni
    dunni about 9 years
    It's quite unlikely, that on an ISP level anything is done manually (and i think, the question refers to the router, which connects you to your ISP). I don't know how it works exactly, but i think, ISPs also just use DHCP to assign IP addresses to the client routers.
  • Dan
    Dan about 9 years
    @dunni I don't think it's as automated as you think there - lots of business class installations will see an engineer turn up with a Cisco Router for the client, which will then be configured manually as required.
  • dunni
    dunni about 9 years
    I don't think we are talking about the same thing. Here for example, (almost) everytime my router at home connects to the internet, it gets a new IP, but at least every 24 hours. This will of course happen automatically, not manually (with DHCP i think).
  • Sotis
    Sotis about 9 years
    @dunni - this is where we need to draw a distinction from routers within an organisation's network (manually set IP) and a single router within a home network with a dynamically assigned external IP. A home router's external IP will be assigned by the IP through DHCP or similar, but it's internal IP will almost always be pre-set by the manufacturer.
  • dunni
    dunni about 9 years
    That's right, but the OP asked about a router at home connected to an ISP in the first place, so strictly spoken this answer doesn't apply to the question.