DNS lookup aliasing of hostnames (not IP aliases), probably via dnsmasq

I'd like to be able to set up a host, say "eg", to be an alias to some server on the internet, say "example.example.com".

I just need this functionality to be available from my local machine. I'm running dnsmasq on that machine, which is running ubuntu 9.10.

Is there a way to configure dnsmasq or the resolver subsystem (including avahi) to resolve that alias hostname via the actual hostname, so that eg will resolve to the ip address of example.example.com?


The dnsmasq manpage says:

--cname=<cname>,<target>

Return a CNAME record which indicates that <cname> is really <target>. There are significant limitations on the target; it must be a DNS name which is known to dnsmasq from /etc/hosts (or additional hosts files) or from DHCP. If the target does not satisfy this criteria, the whole cname is ignored. The cname must be unique, but it is permissable to have more than one cname pointing to the same target.

I think the "known target" criteria will make it unsuitable for your requirements.

I do know that Unbound does support this feature, though.


In your dnsmasq.conf add this line

expand-hosts

This will allow you to create a name that can be used.

This was not asked but if you want to all devices to use it set up the dhcp options. Just for a guide here is my config.

expand-hosts # allows /etc/hosts to be used
dhcp-range=192.168.2.2,192.168.2.50,255.255.255.0,24h #Range and lease time
dhcp-option=3,192.168.2.1 #gateway
dhcp-option=6,192.168.2.51 #dns server
dhcp-option=28,192.168.0.255

I am runing this on a Raspberry pi that is also acting as a pi-hole and webserver.