1

I want to achieve this behavior on IIS 10 and GoDaddy DNS servers.

I have three servers handling three applications, first two are working fine, but having trouble with the third one:

  1. All www.example.com and non-www.example.com traffic goes to one server.
  2. All api.example.com goes to another one.
  3. All s*.example.com goes to a third server (only subdomains starting with the letter S)

Taking into consideration that tomorrow I might have api2.mydomain.com etc..

Thanks!

Patrick Mevzek
  • 9,921
  • 7
  • 32
  • 43
Basilf
  • 113
  • 2
  • you can define a default site for all hosts on your third server. (dont specify any Hostname for the binding) Not sure if you can use DNS wildcards in goday's dns servers. – Mr Zach Feb 20 '18 at 11:17
  • @MrZach If I don't specify any hostname in the third server, what will the A record for that server will be in GoDaddy, if they do not accept wildcards? – Basilf Feb 20 '18 at 11:45
  • The A record on the dns server has to point to the ip address of your third server. – Mr Zach Feb 20 '18 at 14:10

1 Answers1

2

DNS wildcards are binary: it is everything or nothing, you can not match only some part of the label like your s*.example.com. This is part of the protocol, so it will not work whatever software you use[1]

See RFC4592 and its section 2.1.1:

A "wildcard domain name" is defined by having its initial (i.e., leftmost or least significant) label be, in binary format:

 0000 0001 0010 1010 (binary) = 0x01 0x2a (hexadecimal)

The first octet is the normal label type and length for a 1-octet- long label, and the second octet is the ASCII representation [RFC 20] for the '*' character.

So if you want to do something like that, you need to setup a wildcard, and then handle all requests at the application level in your webserver.

Remember that wildcards, as attractive as they may seem to be, can create complicated problems, even more so with CNAME records. Zonefiles are typically text files, so it is easy to automate their creation and putting in them any number of records, instead of using wildcards.

[1]: except of course with an highly specific server where you could plug a specific backend that would act on the label the way you need it.

Patrick Mevzek
  • 9,921
  • 7
  • 32
  • 43