Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 668  / 2 Years ago, sat, july 23, 2022, 10:34:25

TL;DR: How can I get myhost.local to resolve to my wifi interface rather than the Docker virtual network?


My desktop system's hostname is "myhost" (from /etc/hostname etc), running Ubuntu 18.04.
The ip a command tells me that my wifi ip address is 192.168.0.6, and my rarely-used docker-network ip address is 172.17.0.1.


I like to use mdns/Avahi to access my desktop, via "myhost.local", e.g. when connecting to local jupyter notebooks from other hosts on my home LAN.


For some reason, mdns is assigning two addresses to myhost.local:


$ host myhost.local
myhost.local has address 192.168.0.6
myhost.local has address 172.17.0.1
myhost.local has IPv6 address fe80::46da:e48:c3c0:112

Jupyter notebook is running with ip=192.168.0.6


When I ping myhost.local, or connect to http://myhost.local:8888/ it worked a few months ago, but now it tries the 172.17.0.1 address, which doesn't work for jupyter.


This seems related to the unanswered question at the Docker Community Forum: Docker network interface interferes with mDNS address.


Update: to answer a question, this is the hosts file. I think it comes from the default way that Ubuntu sets up the hosts file, so localhost is not actually the same as myhost, but I might have tweaked it.


$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 myhost

Bonus Update


user10489 correctly notes that other hosts will resolve myhost.local via mdns just fine. And my underlying problem was that I wanted to know what ip address to configure in my jupyter notebook to make it available over my wireless LAN. It's just that we don't see an easy way to use mdns on the local machine to get that answer.


The resolution to that underlying problem is this, to just figure out which ip address I have on a given interface (here illustrated with Ubuntu's awkwardly-named first wireless network name):


dev=wlp3s0
ip=$(ip -br -o a show $dev | (read interface status ip ip6; echo ${ip%/*}))
jupyter notebook --no-browser --ip=$ip

More From » networking

 Answers
2

There are multiple name resolution mechanisms active here by default:



  • /etc/hosts

  • mdns

  • dns


This is the default order, and mdns usually tries to resolve *.local


But also consider that this is the case separately for two machines -- the local and the remote machine.


So, if you want myhost.local to resolve to a specific interface without disabling mdns on other interfaces, you should be able to just put an override in /etc/hosts. However, this only affects the local machine.


Remote machines will resolve myhost.local with whatever mdns broadcasts they hear. So if they are on your docker network, and your lan (as your local machine would be), they would get all those addresses from mdns. If they're only on one of those networks, they should see only the address that corresponds to that network.


So perhaps the solution is not to change configuration, but change what host you are using to ask the question.


[#1595] Monday, July 25, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rhaeams

Total Points: 115
Total Questions: 111
Total Answers: 103

Location: Burundi
Member since Wed, Nov 25, 2020
4 Years ago
rhaeams questions
;