Edit samba share, when IP changes

I am on Xubuntu 20.04 LTS. I have a samba share on it, with Windows 10 that is running in VirtualBox. VirtualBox has a bridged network connection.

I made a shortcut to the samba share in Thunar.
It looks like this:
smb://10.0.0.4/users/MEOW/Dropbox/
It works great.

Problem is the IP of the VM changes every once in a while. I tried setting a static IP for it, but I had to give that up, because sometimes it prevented the VM from connecting to the network altogether.
So, I could make a new Thunar shortcut every time the IP changes, or… maybe there is a way to edit the shortcut?

https://forums.virtualbox.org/viewtopic.php?f=6&t=93038

https://forums.virtualbox.org/viewtopic.php?f=2&t=91156

https://forums.virtualbox.org/viewtopic.php?f=1&t=49066

It’s hard to find a clear solution to this issue. Sometimes this means, the solution is easier to fix than one might’ve thought.

Just use avahi… if you’re using Ubuntu (or debian jessie/buster/stretch) or downstream like Mint or whatever - it’s just “outta the box” functionality…

e.g. I can hook up all my Linux boxes - plus BSD and even Window and Macs in my home LAN using avahi… e.g. using ssh, or even things like accessing the webui on ResilioSync

e.g. my NAS is baphomet.local - my desktop machine (ubuntu) is titan.local etc etc…

Avahi comes as pretty much running by default in most modern Debian based distros (e.g. Debian and Ubuntu) and default behaviour is each node is {HOSTNAME}.local - i.e. “.local” is the default suffix…

e.g. ssh to my desktop machine :
ssh titan.local
e.g. point my browser to ResilioSync WebUI running on my desktop machine :
https://titan.local:8888/

I had issues a few years back trying to get it to work on CentOS / RedHat / Oracle Linux (and gave up).

“Avahi” has different names on proprietary platforms - there are other names like “zeroconf” and “bonjour”… but its all based on the same guff…

On my system (Xubuntu 20.04) Avahi and Avahi-client are offered in the software store as flatpak. However,

        sudo apt install avahi
            No apt package "avahi", but there is a snap with that name.
    Try "snap install avahi"

    E: Unable to locate package avahi

What would you recommend?
And how to use Avahi?

Avahi is installed by default in Ubuntu - ever since “I don’t know when…” - i.e. I’ve been using it since around 14.04 - I know it’s installed by default with a base install of Ubuntu since at least 16.04 - so its base requirements will be installed on your xubuntu 20.04 system…

e.g. my Ubuntu 20.04 desktop at my desk at work :

╭─x@tethys ~  
╰─➤  apt list --installed |grep -i avah

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

avahi-autoipd/focal,now 0.7-4ubuntu7 amd64 [installed]
avahi-daemon/focal,now 0.7-4ubuntu7 amd64 [installed]
avahi-utils/focal,now 0.7-4ubuntu7 amd64 [installed,automatic]
libavahi-client3/focal,now 0.7-4ubuntu7 amd64 [installed,automatic]
libavahi-common-data/focal,now 0.7-4ubuntu7 amd64 [installed,automatic]
libavahi-common3/focal,now 0.7-4ubuntu7 amd64 [installed,automatic]
libavahi-compat-libdnssd1/focal,now 0.7-4ubuntu7 amd64 [installed,automatic]
libavahi-core7/focal,now 0.7-4ubuntu7 amd64 [installed,automatic]
libavahi-glib1/focal,now 0.7-4ubuntu7 amd64 [installed,automatic]
libavahi-gobject0/focal,now 0.7-4ubuntu7 amd64 [installed,automatic]
libavahi-ui-gtk3-0/focal,now 0.7-4ubuntu7 amd64 [installed,automatic]

Some components that don’t get installed by default are packages like avahi-discover (you shouldn’t need it)…

Summary : it will have been installed by default… you don’t need to run anything special - it’s part of “zeroconf” so there should be nothing to configure… just remember to append “.local” onto your LAN hostnames…

Test it by trying to ping some other Linux box on your LAN like :

ping myservername.local

By default Ubuntu should put this in your /etc/nsswitch.conf file :

hosts: files mdns4_minimal [NOTFOUND=return] dns

The key value here being “mdns4_minimal”… But you shouldn’t even need to touch this file…

Note : I can ping my Windows 10 laptop at my desk from my Linux laptop at my desk on my work’s LAN :

╭─x@tethys ~  
╰─➤  ping REDACTO.local
PING REDACTO.local (10.16.8.99) 56(84) bytes of data.
64 bytes from REDACTO.corp.REDACTO (10.16.8.99): icmp_seq=1 ttl=128 time=0.594 ms
64 bytes from REDACTO.corp.REDACTO (10.16.8.99): icmp_seq=2 ttl=128 time=0.735 ms
^C
---  ping REDACTO.local statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.594/0.664/0.735/0.070 ms

(note - I changed the real names to “REDACTO” to protect my company details)

(but not the other way - i.e. I cannot “ping tethys.local” from my corporate SOE Windows 10 laptop - but I’ve been able to get Avahi *.local names to resolve from Windows 7 stuff on my home LAN)

– edit –
Note - you may get unexpected results if for example - the host you’re trying to get to has two interfaces on the same IP network / LAN - e.g. a machine that has WiFi and ethernet connection, connected simultaneously… usually, but not always, it will default to the ethernet address first - but - it may not, e.g. if your ethernet switch is power cycled, and ethernet goes down, then re-connects - avahi may resolve to the wifi IP address first… YMMV (your mileage may very) - but this stuff is mostly plug and play you should never have to look under the hood :smiley:

1 Like

I installed Recoll, to crawl through the text in my config files, and it turns out the relevant file is:

/home/MY USER NAME/.config/gtk-3.0/bookmarks 

Just need to change the IP in this file, and all is well. The shortcut in Thunar immediately registers the change.