0

I've installed dnsmasq DNS server on ubuntu instance and added domain name in the configurations. It is working fine except that it is resolving unkown hosts the same way it will do for the domain name.

Here is my configurations:

/etc/dnsmasq.conf

# domain name
domain=example.com
local=/example.com/

address=/example.com/127.0.0.1 
listen-address=127.0.0.1

/etc/hosts

127.0.0.1 localhost
172.217.16.195 www.google.com
10.10.1.x testhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

I've installed nginx server on the "example" instance, so I expect to see the default page when I send GET request to the port 80 and this is working as planned:

curl example.com

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
...

On the "testhost" instance I've installed simple server that returns "hello world", this is working fine as well.

curl testhost.example.com

hello world

However, when I request an non existing host, it is redircted to the "example" host: curl random-string-asfasfasfasf.example.com

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
...

How can I prevent this behaviour?

Kingindanord
  • 115
  • 4

1 Answers1

1

Remove the address= line and put the example.com hosts you want to resolve in /etc/hosts.

tater
  • 1,395
  • 2
  • 9
  • 12