1) I am wondering when is a computer given a static ip address?
Typically when that computer hosts a service that needs to be accessed by other computers.
Such computers are commonly called servers.
2) Does one need to pay for a static ip address?
Typically an ISP will charge extra for providing static IP addresses.
On your private LAN, which is provided by your router, you are free to use dynamic and static IP addresses.
Your wireless router is assigned a static IP address for its LAN-side interface. This ensures that all hosts in your LAN can find the router.
Note that DHCP can hand out a reserved IP address as well as a dynamic IP address. This reserved address would always be provided to a host specified by MAC address.
3) Since the point of ip address is to uniquely identify a computer in a network, shouldn't the address be always static?
Typically only servers need static (i.e. known) IP addresses.
When you use your web browser on your PC, you're the client in the client-server model. The client makes a request to the server (e.g. Google or Amazon).
The server handles the request by returning a response back to the client.
In theory the client could use a different IP address for each request, because the request contains the return address of the client.
Hence the client (e.g. your PC) does not need a static IP address.
in other words if the address keeps changing then how can it help in uniquely identifying a computer?
There are other mechanisms for finding hosts on a network.
You might use a hostname rather than an IP address to identify a host. Then you need a DNS server to maintain and map hostnames to IP addresses. (Windows has its own protocol/service to keep track of Windows hosts on the LAN, e.g. the workgroup or homegroup.)
Each Ethernet interface is identified by a MAC address. The ARP protocol is used to map an IP address to a MAC address.
You might need to clarify which address is being changed. There would normally be 2 addresses involved. 1 is the 'local' address, which is commonly assigned by your router, to your machine, and Identifies the machine to the local network. The other is the 'External' this is assigned by the ISP and identifies the router to the internet. Your router handles the translation of connections between the 'local' network and the internet. – Stese – 2017-04-13T08:27:47.410
thanks! is it true that if i connect bunch of computers to my wifi router then the computers form a lan and NAT is used for address translations? – user734861 – 2017-04-13T08:29:59.140
Yes. Thats correct. Each machine will have it's own local address, but would 'appear' to only have one internet address. – Stese – 2017-04-13T08:31:07.400