Getting rid of aliases for local dns replies

Hi everyone

Here is what I'm trying to do. I have a local Ubuntu mirror on my network, and I want requests for
to be directed to the local machine.

I have added
to /etc/hosts on my lede router.

Somehow this isn't working quite as expected. See blow.

I suspect that the "alias" thing is messing with my setup, but my understanding of DNS isn't good enough to really know what is going on.

root@LEDE:/etc# host has address is an alias for has IPv6 address 2001:878:346::116 is an alias for

Any help is appreciated.

There seem to be several ways to implement this kind of requirement, depending on the OS.
I was also searching for the most appropriate way and found this working rock stable for me:

On OpenWrt In


add (at the bottom)


and in


maintain your mapping, e.g.

results in

host has address

(on any host of the (sub)net)

This applies only to the machine on which you add the entry to the hosts file, in your case it would need to be done on the machine where you check "host". But then, it is does not apply to other machines

Thanks for your reply, but I would like to avoid configuring on the individual machine. That way it won't break, when I take my laptop to another network.

So I would prefer the router dns server to provide the solution.

Well, with "On OpenWrt In" I meant that this is done on OpenWrt, I hope that this is your router.
The other option you mentioned with the hosts file is on each device and NOT on the router.

I am wondering if there is another way to describe that something is done on a router or on openwrt. Should I say "in the embedded system"?

No, you should supply the method for doing this in OpenWrt (editing /etc/dnsmasq.conf is not the suggested method):

On LuCI web GUI:


Via SSH editing /etc/config/dhcp

config domain
	option name ''
	option ip ''

config domain
	option name ''
	option ip ''
1 Like

Well, in general, dhcp is for an internal network "whereby a DHCP server dynamically assigns an IP address and other network configuration parameters to each device on a network so they can communicate with other IP network" (Wiki)

DNS in our use cases is used to resolve external hostnames.
It associates various information with domain names assigned to each of the participating entities. Most prominently, it translates more readily memorized domain names to the numerical IP addresses. (Wiki)

The config in /etc/config/dhcp is rather pointing to the possibility for applying settings for internal hosts.
Whereas it is also important to see if you want to resolve the hostname including or excluding the subdomains or: If you want to "assign" an internal ip to a specific "external" subdomain like only (without touching

As I noted, you do this in /etc/config/dhcp. I provided an example above already.

:confused: ?????

We're talking about DNS, please stick to the topic.

Are you confused by the name dhcp???
In OpenWrt to edit DHCP and DNS, you use /etc/config/dhcp


I know, that's why I stated to add a config domain entry in /etc/config/dhcp

Yes you provided an example. Unfortunately there is no RFC for that.
It is a common practice for decades to do this with dnsmasq (addn-hosts=/etc/dnsmasq.hosts) if not in /etc/hosts on the host itself (if possible).
Are there any arguments why "editing /etc/dnsmasq.conf is not the suggested method"?

I would like to avoid using /etc/config/dhcp for internal and external host names and /etc/dnsmasq is "closer" to /etc/hosts.

1 Like


If you prefer your configs to be located all over the place (and creating custom config to back those up), your method is fine.

I am totally open for improvements.
In that case, it took me long to find "an" appropriate place to do this config and to feel comfortable with.
There are tons of pro arguments and examples for dnsmasq.conf and only one for /etc/config/dhcp. I have tested both, they work perfectly fine.
All my settings for the image are in /files/usr and /files/etc, so that is perfectly fine.

BTW, did you read
Now, there are in fact 0 arguments for using ../dhcp (1 minus the info from the link above)

Sure it is...this is a big one, especially for n00bs:

Note that options in /etc/config/dhcp take precendence over dnsmasq.conf since they are translated to command line arguments.

Can you provide instructions on how to configure via /etc/dnsmasq.conf; and how to backup the settings with the other configs?

  • I can't find instructions. Your link immediately goes into configuring via the /etc/config/dhcp file

Also this:

The dnsmasq.conf file does not exist by default

  • How do you make the file persistent?
  • Can you provide those instructions?

Please find all information in my very first post at the top of this thread.
Backup as usual; backup list in Luci (/luci/admin/system/flashops/backupfiles) or backed up and added to the /files/etc/ folder for the next build
The file is persistent after creation.
Generally: Google for dnsmasq.conf addn-hosts brings lots of examples.

In general, /etc/config/dhcp is not used for "redirecting" external hosts to internal IPs. If /etc/config/dhcp take precendence over dnsmasq.conf then everything is totally fine. If you do conflicting config in both places, you should rather decide before you do that - which config is more important for you. Then you do only one of them in one of the two places. That is pretty logical, I hope also for noobs.
/etc/config/dhcp is not in conflict with any logic for external hosts since it might be used for internal hosts only.

Using whatever is available on Luci is best for most users

1 Like

Wouldn't editing sources.list be a more direct solution for using a local/private mirror

That could also work, but I want the mirror to work also when I bring my laptop outside of my local network.

The solution to that is to add multiple mirrors and organise them in priority order or specify the priority

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.