exentriquesolutions / nip.io

http://nip.io
Other
1.39k stars 148 forks source link

Allow CNAME support, not just "A" record #38

Open dapeleg-dn opened 1 year ago

dapeleg-dn commented 1 year ago

Use case: I have an internal machine in my private network with DNS: myvm.mycompany.com.

I need it to support wildcard subdomains, for example: db.admin.myvm.mycompany.com. This is useful when I use a reverse proxy or Kubernetes ingress controller, mapping host name to a service. From the host name it knows where to route the traffic. This is an elegant alternative to opening additional ports or using URL-prefix and URL-rewrite.

As long as the internal IP doesn't change, I can easily define service.10.10.1.1.nip.io and db.admin.10.10.1.1.nip.io. They both return the same IP, but in my reverse proxy or ingress controller, I can map them to different services, by the supplied host name HTTP header. (The usual web "virtual host" approach.)

The question is what to do if IP changes frequently, and it's beyond my control.

My suggested solution is to use part of nip.io DNS service as a service that only returns CNAME alias instead of "A" record with a static IP.

For example, I may use myvm.mycompany.com.cname.nip.io to get CNAME response pointing to myvm.mycompany.com. And db.admin-myvm.mycompany.com.cname.nip.io will also give CNAME response of myvm.mycompany.com. So if my company's IT staff changes the IP of the internal machine myvm, all URLs will stay valid, since they are just a CNAME reference to the real machine name.

normanr commented 1 year ago

Why not just use the original name? i.e. instead of myvm.example.com.cname.nip.io, why not just use myvm.example.com?

Ahh, you want it for handling wildcard names. You can add these in your local dns too, i.e. you can configure *.myvm.example.com to be a CNAME for myvm.example.com.

dapeleg-dn commented 1 year ago

@normanr, the whole idea is that I have no control over my company's DNS servers and that I don't want to make just local changes to /etc/hosts file on my machine but to be able to share a URL between all team members easily.

I am sure there are more use cases; this is just one that I found helpful for me.

normanr commented 1 year ago

You should chat to your network administrator about adding wildcard names for your machine. I'm sure they'd prefer to keep DNS requests with private company machine names internal to their network instead of sending them to a 3rd party service somewhere on the internet.

dapeleg-dn commented 1 year ago

I am asking from a technical perspective. Believe me that if I wanted to talk to my administrator I would not have to come here. Finding people-related solutions is not the purpose of GitHub. Since technically it's possible I am asking here to implement that. I don't need a GitHub issue to tell me "that's not possible". We're here to make things possible and to develop new innovative technical solutions, not to be stuck in "this-is-not-possible land".

jc01rho commented 1 year ago

exactly facing same issue here.