Correct way to redirect domains to localhost

I have a dockered Ycast Server running on OWRT, which requires to point certain domains to my ycast Server. I followed this guide which basically tells to add several entries to Network/Hostnames (config dhcp). This seemed to work, my AVR connected successfully to ycast. However, as I modiefied ycast for my needs, I debugged stuff using firefox on my Linux Laptop, and that is where things become strange.
Sometimes, I got my local ycast Instance, sometimes i got the original vtuner.com domain.

I tried pinging the domain and the reproducible result was,
Ping 1: goes to ycast.
Ping 2: vtuner
Ping 3: ycast
and so on (Ping numbers means a new ping request, not an answer within a request, they are constant during a ping session)
enabling and looking into dnsmasq logs, to my surprise, indeed every second ping resulted into a lookup into my providers dns, where of course the real Ip is listed.

I was able to fix that by removing those host entries and adding them to config dnsmasq,

        list address '/vtuner.com/192.168.1.1'
        list address '/radioyamaha.vtuner.com/192.168.1.1'
        list address '/radioyamaha2.vtuner.com/192.168.1.1'

But i am wondering, is this the right way to do that?
Why did dnsmasq give such strange results (and as far as i can tell, only when my linux Laptop did those requests).

There several ways to do this, yours is valid - personally I'd use cname or host definitions in /etc/config/dhcp.

2 Likes

Hm, still strange that dnsmasq gave me the original IP half the time when using hosts definition. Anyway, since it works now, i guess i leave it that way.

The address option includes subdomains, so you can remove redundant list entries.

1 Like

Good to know, thank you.

1 Like

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