How do routers get their external IP address?

Solution 1:

Very much like how you have a local DHCP server running on your home router to serve IPv4 addresses on your LAN network (typically in the 192.168.1.x subnet), your ISP also has a DHCP server running somewhere that your router gets its WAN address from. The IP address range your ISP's DHCP server hands out are public IP addresses that it has purchased or been assigned.

Solution 2:

There is no single answer to this save to say that ISP's provide IP addresses out of blocks they own. A non-exclusive way as to how they may be implementing this -

If the connection used PPPoE or PPPoA the PPP session will have an IP address associated with it. Very commonly these IP addresses will be configured in a Radius server (often backed by a database). The ultimate assignment could be based on userid, come from an IP pool or a characteristic associated with the connection.

In a simple ethernet case an IP address could be assigned statically or via DHCP - although this is not a great way to do things unless there are additional controls to prevent people "stealing" others IP addresses.

Solution 3:

Have to agree with you, quite difficult to find a straight answer via google. To me that means it's a good question!

Reason why answering this question is difficult, like Davidgo mentioned, is because there is no single answer. What he probably means is that there is more than one single method or process that leads to assignment of an IP address to a machine. Which method or process is used depends on specific circumstances like e.g. is the router connected to the internet or is it connecting to a(-nother) private network.

Try to keep in mind that all methods, protocols, policies, processes etc. that are required to enable communication are part of a logical, systematic and strict set of rules (so a structure) to ensures unique identification for all connecting machines. If the uniqueness fails, then communication drops out and no networking is possible. So in that sense this full set of rules is the correct answer to your question but that's just a bit too much to take in at once.

Here is a start A short guide to IP addressing... from the Internet Society

Intro below (there is much much more on their site as I just found out.

IP addresses are managed by the Internet Assigned Numbers Authority (IANA), which has overall responsibility for the Internet Protocol (IP) address pool, and by the Regional Internet Registries (RIRs) to which IANA distributes large blocks of addresses.

The RIRs manage, distribute, and publicly register IP addresses and related Internet number resources, such as Autonomous System Numbers (ASN) and reverse Domain Name System (DNS ) delegations within their respective regions.

They do this according to policies which are developed within their respective regional communities, through open and bottom-up processes.