Dynamic and Static Addresses
As noted above, there is only a finite number of available IP addresses, even on the largest of WANs, the Internet. Simply put, there aren't enough addresses for everyone.
Dynamic Addresses on The Internet
Let's say an Internet Service Provider has 100,000 users subscribed. Does that mean the ISP must also lease 100,000 "real" IP addresses -- one per user account?
Luckily, no. When you think about it -- it's highly unlikely that all 100,000 users will be connected at any given moment. Most likely, only a certain percentage of the users will be concurrently connected -- perhaps only 40% of all users registered with this ISP. So, this ISP theoretically only needs 40,000 "real" IP addresses to satisfy all the needs of its clients at any given moment -- which is 60,000 less IP addresses to lease.
So, the obvious solution for this ISP is to lease 40,000 "real" IP addresses, and to dynamically assign those IP addresses to the hosts who wish to connect. A host logs on, authenticates with the ISP (provides username and password), and is then assigned an IP address for use while online.
When that host closes the connection, the address is 'reserved' for him for a certain amount of time -- so if he re-connects within 5 minutes it is likely that he will get the same address. However, once that set amount of time elapses, the IP address is no longer reserved, and returns to the address pool . Some time later, a different host connects and gets that same address.
That is how dynamic addresses are usually used in the context of the internet.
Dynamic Addresses on A LAN
The internet isn't the only place where dynamic IP addresses can be of use. Some corporations run very large internal networks (whether LANs, in one large installation, or WANs, connecting several remote places). When you have thousands of hosts connected to the same network, manually assigning an IP address for each and every one of them can be quite a hassle. It is also error prone -- what if you happen to assign the same IP address to two hosts? Or what if you made a typo?
Thus, dynamic IP addresses are often used also for LANs. Once you perform the initial setup, the system 'runs itself', and every host gets a correct address automatically.
The protocol by which a host asks to be assigned an IP address, and gets that dynamic IP address, is called DHCP, which stands for Dynamic Host Configuration Protocol.
Disadvantages of Dynamic Addresses
So far we've come to see that dynamic IP addresses seem to save quite a lot of money and manual labor. So -- what could possibly wrong with them?
Let's say you wish to talk to a friend. You both know each other's number, so you call each other. One day, you get a new mobile phone, and your old number is no longer valid. Until you let your friend know your new number -- only you can call him. He won't be able to call you, as he doesn't have your number.
Now, what happens if before you've had a chance to call your friend and let him know you have a new number, he got a new number as well? Now, neither one of you can call the other!
That is the main drawback of using dynamic addresses. If the computer you're trying to reach has an IP address which sometimes changes, you can never be sure it will be there next time you'll want to access it.
For reliable communication, each connection must have at least one end which is fixed. The dynamic end of the connection will be able to reach the fixed end. If both ends are fixed, they will of course be able to freely originate communications to each other (just like when calling your friend from above).
As covered above, static addresses are mostly needed for internet servers. When you need to be able to reach a certain host on the network, that host needs a static IP address! You need to know where it is, to reach it. Static IP addresses can be leased from any ISP.