Use a dynamic global hostname on Mac
If your service provider supports secure dynamic DNS update (RFC 3007), you can give your Mac a global DNS hostname so other computers outside your local network can refer to it by name.
Even if the IP address for your Mac changes at regular intervals, your Mac automatically updates its global DNS hostname to point to its current IP address.
On your Mac, choose Apple menu > System Settings, click General in the sidebar, then click Sharing on the right. (You may need to scroll down.)
Click Edit in the “Local hostname” section at the bottom of the window, then turn on “Use dynamic global hostname.”
Enter the hostname, user, and password for the account.
Ask your service provider or domain administrator for the user and password so your Mac can update its hostname every time its address changes.
If your service provider supports Wide-Area Bonjour registrations, you can also turn on “Advertise services in this domain using Bonjour” to advertise your computer’s active sharing services in its domain.
If Bonjour browsing is enabled for this domain, other computers see the services listed automatically in their apps, based on the search domains entered in their Network settings or based on information returned by DHCP.