exentriquesolutions / nip.io

http://nip.io
Other
1.39k stars 148 forks source link

Allow (or guide on configuring) binding to several DNS names #43

Open JonTheNiceGuy opened 1 year ago

JonTheNiceGuy commented 1 year ago

I want to resolve the AWS naming convention from my local machine. These addresses are in the format:

ip-192-0-2-1.ex-ampl-1.compute.internal

For example, ip-192-0-2-1.eu-west-1.compute.internal and ip-192-0-2-1.us-east-1.compute.internal

These both resolve to 192.0.2.1 (surprise! :) )

I have created my backend.conf for the region I mostly use (eu-west-1) as follows:

[main]
# main domain
domain=eu-west-1.compute.internal

# default ttl
ttl=432000

# default IP address for non-wildcard entries
ipaddress=127.0.0.1

# Indicates whether this response is authoritative, this is for DNSSEC.
auth=1

# Scopebits indicates how many bits from the subnet provided in the question.
bits=0

# SOA
[soa]
# serial number
id=1
# Hostmaster email address
hostmaster=jon@sprig.gs
# Name server
ns=ns1.compute.internal

# nameservers
[nameservers]
ns1.nip.io.example=127.0.0.1
ns2.nip.io.example=127.0.0.1

I've then configured dnsmasq on my network to forward eu-west-1.compute.internal to the docker container running this software, but I'd love to have it either respond to multiple domain names (e.g. ip-192-0-2-1.eu-west-1.compute.internal and ip-192-0-2-1.us-west-1.compute.internal) or respond to any DNS name matching a regex (e.g. .*.compute.internal)

Any thoughts? Happy to try to cobble together some code, if that'd help :)

vanillajonathan commented 1 year ago

I don't know but if you look at https://github.com/exentriquesolutions/nip.io/blob/c1532cd6dd110046edf1ea5d9771485ada59174f/nipio/backend.py#L241-L247

It looks like you might be able to insert an elif clause there to handle that.