There are a wide variety of solutions to that, they all fall under the general name of "dynamic DNS". Most DNS providers have some sort of system for updating it even. I use cloudflare and there's a wide variety of scripts that can be used to automatically update CF DNS records. There's also some purpose-built services and many home NAT routers include features for this.