Score:2

macos /etc/hosts ignored using wildcard subdomain

jp flag

Why is macos ignoring etc/hosts

I have seen this: /etc/hosts file being ignored

And it is not a TAB but a space between ip address and domain.

Is there something special you need to do on MacOS to use etc/hosts.

I have a local sige mydns.com in etc/hosts:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
172.18.0.0 *.mydns.com

When I do curl subdomain.mydns.com it goes out to the nameservers getting the Internet ip address and not the local ip address specified in the etc/hosts?

vidarlo avatar
ar flag
Does this answer your question? [In my /etc/hosts/ file on Linux/OSX, how do I do a wildcard subdomain?](https://serverfault.com/questions/118378/in-my-etc-hosts-file-on-linux-osx-how-do-i-do-a-wildcard-subdomain)
jp flag
Hmm interesting
Michael Hampton avatar
cz flag
You don't. Wildcards aren't valid in the hosts file. The linked question provides a variety of different workarounds that you may consider for your specific situation.
Score:0
cn flag

The HOSTS file of all of todays operating systems can contain letters and some symbols. The is no such thing as "wildcards" in the basic internet naming system (rfc882), so as the most basic name resolution table. For example, it doesn't deal with providing additional information, wildcards, QCLASS=*, or overlapping zones.

If you want to redirect a large number of hostnames (*) I would recommend using a DNS server or at least a DNS proxy allowing that.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.