Forwarding all *.example.com requests to a local webpage

Sorry if I don't use the correct terminology for what I'm trying to do, I don't have a ton of experience with networking.

Essentially, what I want all devices on my local network to be forwarded to a local host (let's say the ip is 192.168.1.2) when a request is made to *.example.com.

Apologies again if this was already answered on this sub.

EDIT: I should have probably mentioned this before, but I have a device that won't connect to my router without going to an address and getting a 200 OK, but I don't have an internet connection on my router so I'm simply looking for a way to send that 200 OK to the device from within my isolated network.

Posted Mar 27, 2019, 4:21 PM UTC · edited

149
TheMuffnMan•

You're wanting to modify DNS. The cheap/free way would be to edit each machine's host file.

Slightly fancier is if you have a router with OpenWRT (or similar) you could create a record on the router assuming all the clients on the network are configured to use it as the DNS server. See here

Or if you have a Pi-Hole you can do the same see here

9
TheMuffnMan•

This is all assuming you don't have a domain with AD DNS or another DNS system already in place.

3
BlazingSpiritOP•

OpenWRT seems like it would be helpful, thank you for pointing that out to me.

1
Turtlecupcakes•

You don't necessarily explicitly need OpenWRT - just a configuration that allows you to modify DNS entries.

The PiHole route might be the best one for you. It lets you use your existing router (which you will configure to redirect DNS requests to the pihole) and you get all the great added functionality that a pihole brings.

3
Pip-Master•

Depends on if your DNS supports WildCard DNS entries.

If it does support it, put a '*' in the host field and point to whatever IP.

3
MrEnigmaPuzzle•

I'm being very brief here, but Its possible that your home router will allow you to do this by either creating a wildcard hosts entry e.g. *.domainname.com = 192.168.1.1 for example

If your router doesn't allow it you could install dns service on a machine on your local network.

put default forwarder on the dns server to be your to your internet router

You can manage redirects via wildcards on the dns server. Note all your clients on your network would have to resolve dns from that server as their starting point.

​

failing all of the above then you could manage it using your windows hosts file (or other OS hosts file)

​

or get net nanny or something equivalent

​

I would add that restricting internet access is like playing whackamole.

As soon as you hit one, another pops up. better to not hit any moles, and just point out why the moles are bad to those concerned.

1
theblindness•

If you want to do this for your devices in a local network, you need to run your own local DNS server. Providing you already have a local resolver working, you would create a new primary zone for example.com and add two records.

@    IN    A    192.168.1.2    ; IPv4 address for example.com
*    IN    A    192.168.1.2    ; IPv4 address for *.example.com

By the way, it goes without saying, but this is just for example. In real life, when choosing a domain for your LAN please don't use any domains that you don't own like example.com, and also avoid using .local, because you can get conflicts with mDNS. If you use something fake like *.blazingspirit.lan, that would be okay until you want to start using certificates and no one will give you a certificate for a .lan domain because you can't prove you own a domain that doesn't exist. It's easier to buy a domain for $10 now and use LetsEncrypt for free certificates later, than it is to use a fake domain now and build your own PKI later on.

1
phunkygeeza•

At a total guess, Google's generate 204?

1
closms•

Https might give you trouble.

1