1

I have a dev machine with Windows 11 where I run a web application. I use a custom domain to address it, i.e. I have put the following lines in the hosts file

127.0.0.1 myapptest.com
127.0.0.1 sub.myapptest.com
etc

Now I want to have the opportunity to test a mobile version of it using a real physical device, connected to the same wifi network as my dev pc. How can I set my environment so that if I typed sub.myapptest.com in the phone's browser it'd work?

I assume a custom DNS server might be an answer. Are there any for Windows nowadays? Can I run one using WSL2? Docker?

4
  • 1
    The way that I'm reading this, the web app is running in Windows itself currently, not WSL2, correct? Commented Jun 6, 2022 at 12:49
  • Yes, it is on Windows itself. Sorry for confusion. Commented Jun 6, 2022 at 12:53
  • 1
    No worries. Just a heads-up that running a DNS inside WSL2, at least, would be problematic due to the need for port forwarding. It might be easier to do so in WSL1 actually, although I haven't had a chance to try it. It's possible in WSL2, just requires some extra effort. I believe Docker would have similar challenges since it is running in WSL2. I realize that @harrymc's first option probably won't meet your testing need, but the second option is probably best since many routers do have DNS servers with some level of configuration. The Android option is a great fallback. Commented Jun 6, 2022 at 14:49
  • 1
    For greater justice this post superuser.com/questions/1239419/… has very detailed instructions on installing BIND under Windows. Commented Jun 7, 2022 at 9:29

1 Answer 1

1

The hosts file only has validity within your computer, so doesn't affect accesses from outside of it.

For your phone to address your application on your computer, I can suggest:

  • Don't use a domain-name, but directly the IP address of the computer (192.168.0.1 etc)

  • If your router has a local DNS function, it can resolve the address and return the IP address of the computer

  • If your phone uses Android and is rooted, you can modify /etc/hosts. If not rooted, see LazyMan.

  • Otherwise you will need to create your own DNS server inside your local network.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .