Short answer
DNS must ultimately provide an IP address before somebody can connect to your website. That address does not, however, have to belong permanently to one particular server.
If the public IP address of your server changes, software can update the corresponding DNS record. This is known as dynamic DNS.
Cloud environments often use another approach. Instead of pointing your domain directly to one server, you point it to a stable service such as a load balancer or content delivery network. The provider manages the changing servers and IP addresses behind that service.
A fixed IP address can still be useful. It is simply not the only way to give a website a stable name.
DNS points to a destination, not to a website
Suppose somebody enters www.example.com in a browser.
Before the browser can connect, it asks DNS where that name can be reached. DNS may return an IPv4 address, an IPv6 address or another name that must be resolved in turn. Eventually, the browser obtains an address and opens a network connection.
The website itself is not stored in DNS. DNS provides directions towards a system that can handle the request.
When the browser reaches that system, it still includes the hostname it intended to visit. That allows one server, load balancer or CDN to handle many different websites using the same IP address. The hostname is also normally used when checking the website's TLS certificate.
So the IP address leads the browser to a network destination, while the hostname tells that destination which website to serve.
Pointing directly to a server
The simplest arrangement is to create an address record that points directly to the public IP address of a server:
- an A record contains an IPv4 address;
- an AAAA record contains an IPv6 address.
This works well while the address remains the same. If the server receives a different address after a restart, replacement or network change, the DNS record still contains the old one. Visitors will then be sent to the wrong destination until the record is updated.
Many hosting and cloud providers therefore let you reserve a public address. The terminology differs: it may be described as a static, reserved or elastic IP address. The address can remain associated with your account and may be moved from one server to another.
For one server, a reserved address can be the most straightforward answer. It does introduce another resource that must be managed and may incur charges even when it is not being used.
Updating DNS when the address changes
If a permanent address is unavailable or unnecessary, the DNS record can be updated whenever the public address changes.
A dynamic DNS client normally performs three steps:
- It discovers the current public IP address.
- It compares that address with the value currently published in DNS.
- If they differ, it sends an authenticated update to the DNS provider.
The domain continues to use the same name, but the address associated with it changes.
This can be practical for a small server, a laboratory environment or a system running behind an internet connection with a dynamically assigned address. Many DNS providers offer an API that can be used for these updates, and general-purpose dynamic DNS clients can work with several providers.
There is usually a delay. DNS answers are cached for a period determined partly by the record's time to live, or TTL. A resolver that has recently received the old address may continue using it until that cached answer expires. Lowering the TTL can reduce this interval, but it cannot make every change instantaneous.
Dynamic DNS also provides no availability by itself. It can update the directions to a server, but it does not repair the server, replace it or verify that the application is working correctly.
A public address must actually be reachable
Successfully publishing an address in DNS does not guarantee that visitors can connect to it.
A system on a home or office network may be behind a router performing network address translation. Incoming connections then need to be forwarded to the correct internal system, and the firewall must permit them.
Some internet providers place multiple customers behind carrier-grade network address translation (CGNAT), effectively sharing one public IPv4 address between them. In that case, the apparent public IPv4 address is shared and the customer may not be able to accept arbitrary inbound connections at all. Dynamic DNS cannot create reachability that the network provider does not offer.
IPv6 can provide globally routable addresses without IPv4 address sharing, but the firewall, server configuration and DNS records must still be correct. A service intended for a broad public audience will commonly support both IPv4 and IPv6 rather than assume every visitor can use IPv6.
Pointing to a service instead of a server
A production website does not always expose an individual server directly.
It may place one of the following in front of its servers:
- a load balancer;
- a content delivery network;
- an application gateway;
- a managed application platform;
- a static website hosting service.
Such a service normally has a provider-controlled hostname. Your DNS configuration can refer to that hostname or use a provider-specific alias record.
The provider can then change the underlying IP addresses without requiring you to edit your DNS configuration. It may add capacity, replace failed infrastructure, direct visitors to different locations or distribute traffic across several systems.
Your domain remains stable while the service manages the changing destinations behind it.
The visitor still receives an IP address and connects to it. The difference is that the address belongs to the stable service in front of the application rather than permanently identifying one application server.
This is one reason that cloud documentation often tells you to point DNS to a supplied hostname rather than copy one of the IP addresses to which that hostname happens to resolve. Those addresses may change as the provider operates the service.
CNAME and provider-specific aliases
A CNAME record makes one DNS name an alias of another. For example, www.example.com might refer to a provider-controlled name for a CDN or load balancer.
A conventional CNAME cannot normally be used for the root of a domain, such as example.com, because that name also needs other DNS records. DNS providers therefore offer mechanisms with names such as alias records, ANAME records or CNAME flattening. These let the provider return the appropriate address records while still following a managed destination behind the scenes.
For example, with an Amazon Route 53 alias, your domain can point to an AWS service such as a load balancer or CloudFront distribution. If AWS changes the addresses behind that service, you do not have to update your DNS record yourself.
Using the same provider for DNS and the cloud service can make configuration considerably easier. Instead of entering addresses yourself, you may be able to select a load balancer, CDN distribution or other managed resource directly. The provider can then keep the DNS answers aligned with changes to that resource.
That convenience also creates dependency. Provider-specific alias mechanisms are not represented identically everywhere, so moving the service or its DNS may require configuration changes. Keeping DNS with an independent provider can preserve a separate control point from which traffic can be redirected if the hosting relationship, account or platform becomes unavailable.
Neither arrangement is automatically better. Integration reduces routine work; separation can preserve independence. What matters is that you retain control of the domain and have a practical way to redirect it.
What happens to HTTPS?
Changing an IP address does not normally invalidate a website's TLS certificate.
The certificate is generally issued for the hostname, such as www.example.com. When a visitor connects, the browser indicates which hostname it wants and checks whether the certificate presented by the destination is valid for that name.
The certificate must still be available on whichever system terminates the encrypted connection. That might be the web server, but it could also be a load balancer or CDN. Managed services can often issue and renew certificates automatically.
This is why several secure websites can share an IP address and why a website can move to a different address without obtaining a completely different identity.
Which approach should you use?
The answer depends on what is hosting the website.
One virtual server
If DNS points directly to a virtual machine, reserving a static public address is often the simplest arrangement. It avoids an interruption whenever the machine's automatically assigned address changes.
A server on a dynamic internet connection
Dynamic DNS may be sufficient, provided the connection accepts incoming traffic and the necessary firewall and NAT configuration is possible.
Several application servers
A load balancer provides a stable destination and distributes requests across the application servers. Individual servers can then be replaced or added without changing the public website address.
A static website
Object storage combined with a CDN or managed static hosting service may remove the need for a publicly accessible web server. DNS points to the managed service, which retrieves and distributes the files.
A globally used website
A CDN or global traffic service can answer from several locations and direct users towards suitable infrastructure. The origin servers behind it do not necessarily need to be exposed directly to visitors.
DNS changes are not failover magic
DNS can help direct traffic to another destination, but cached answers do not disappear immediately. A visitor or resolver may continue using an earlier answer until it expires.
Health-aware DNS services can avoid returning a destination they consider unhealthy, but they cannot withdraw an answer that is already cached elsewhere. Their health checks may also test only one aspect of the service. A successful network connection does not necessarily mean that checkout, login or another important application function works.
For faster or more controlled failover, a load balancer or CDN may be more suitable because it can make routing decisions for each new connection without waiting for DNS caches around the internet to expire.
So do you need a fixed IP address?
Not necessarily.
You need a dependable way for the hostname to lead visitors to a working destination. That can be achieved by:
- assigning a fixed address to a server;
- automatically updating DNS when an address changes; or
- pointing DNS to a stable managed service that handles changing addresses and servers for you.
A fixed IP address is one solution to the problem. It is not a requirement of DNS and it is not automatically the best design for every website.
If your domain points directly to one server, you can reserve a static address or use dynamic DNS to update the record when the address changes. If your website uses a load balancer, CDN or managed hosting service, DNS can point to that stable service while the provider manages the changing addresses behind it.
So the part that normally remains stable is the domain name and its connection to the service—not necessarily the server or its IP address. Visitors continue using the same name, while DNS keeps directing them towards a current, reachable destination.