The Internet Protocol (IP) enables communication over computer networks, a set of addressing and routing standards that ensure different devices can talk. Every internet-enabled device has an IP address so that “IPs” play a crucial role in the interconnected world. This article looks at the difference between static and dynamic IP addresses and how to use them.
In a local network (LAN), devices inside this specific location are assigned a unique IP address manually or automatically by the DHCP server. These addresses are selected from a pool of internal IP addresses reserved for the internal LAN and thus invisible to the outside world. This setup comes with a catch. The local address is unique only in the specific location, but the same range is used in different LANs. A device has to use a unique identifier to communicate on a network. Therefore in the case of connecting to the global Internet, a public IP address has to be used.
Network Address Translation (NAT) solves this problem on the gateway (router) by ensuring the device is provided with a public IP address. The decision lies on the administration to choose whether a particular device needs a dynamic or static IP.
But before we dig deeper into what affects the usage of static and dynamic IP, let's explain what IP address is first.
An IP (Internet Protocol) address is a numerical identifier assigned to devices communicating on a computer network (LAN, WAN, Internet). It comprises four 8-digit binary numbers (0,1), for simplification presented in a decimal range of 0-255 separated by periods (example 192.168.2.1). An IP address is a unique differentiator that we can imagine as a physical street address. To make things easier, when users access web services, IP addresses are translated to domain names by DNS servers. Thanks to DNS no one needs to type a series of numbers into the url and just type the name of the desired page.
Today, the most widely used IP version is IPv4, but the newer version IPv6 is increasingly more popular since it offers a much wider range of unique addresses thanks to its format. The IPv6 format consists of eight groups of four hexadecimal digits separated by colons.
An IP address is assigned to a host statically - selected by an administrator - or dynamically using DHCP service. The best practice is to manually assign a static IP address to the device where continuous availability is critical. All the other devices should be assigned a dynamic IP address via DHCP.
A static IP address (fixed IP address) is a numerical identifier that remains changeless indefinitely when assigned to a device. It is used when it is undesirable to change the address dynamically, typically when permanent access is required (e.g., access to servers, routers, printers)
There are two main options on how to get a static IP address:
The most common static IP address use cases are restricting network access (with IP whitelisting) and enabling remote access (when you host a service inside your LAN and need to access it regardless of geographical constraints). Fixed IP address will deliver you a value if you want to:
In case you don't need a static IP for the particular device (typically smartphones, tablets, PCs) a dynamic IP address is an obvious choice.
A dynamic IP address is a numerical identifier assigned to a host (server, PC, laptop, mobile device, etc.) by DHCP (Dynamic Host Configuration Protocol) service to enable network communication. The address is leased for a specified timeframe. After this period, the IP address becomes available to any other host that requests a new assignment (or a renewal) of an IP address - either when connecting to the network or after its previous IP lease time expired respectively (see figure 1). So a different address can be assigned after this period (usually 24 hours, but this is a custom configuration) if the previous one is already in use by another host. This means that one host's address may change over time.
Pros and Cons of Using Dynamic IP Address:
Both static and dynamic IP addresses have their purpose and every responsible network administrator should follow best practices. Sometimes, questions like whether static IP is safe or at least safer than dynamic IP address arise. From the server perspective, there is no relation between the security and the address type. You are facing a potential danger no matter if your server has static or dynamic IP. What matters is correct firewall settings and access rights restriction.