What's new

creating a service with Merlin Avahi daemon : invalid host name (FIXED)

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Chuckles67

Regular Contributor
Asus AC-66U_B1 flashed with Merlin 386.2_2

I'm trying services (printer, Mac share, smb; all on a different subnet than the router's IP pool) with the stock Merlin Avahi daemon by creating .service files in the /tmp/avahi/services folder.
After restarting the avahi daemon with
Code:
service restart_mdns
the router System Log shows avahi tries to create the services:
Code:
Apr 24 08:09:36 avahi-daemon[16166]: Server startup complete. Host name is RT-AC66U_B1-8300.local. Local service cookie is 2487634299.
Apr 24 08:09:36 avahi-daemon[16166]: Failed to add service 'Printer on RT-AC66U_B1-8300' of type '_ipp._tcp', ignoring service group (/tmp/avahi/services/printer.service): Invalid host name
Apr 24 08:09:36 avahi-daemon[16166]: Failed to add service 'MacMini Share' of type '_afpovertcp._tcp', ignoring service group (/tmp/avahi/services/macmini-share.service): Invalid host name
Apr 24 08:09:36 avahi-daemon[16166]: Failed to add service 'NAS EX2' of type '_smb._tcp', ignoring service group (/tmp/avahi/services/ex2.service): Invalid host name
Apr 24 08:09:36 avahi-daemon[16166]: Alias name "RT-AC66U_B1" successfully established.
For each service the indicated failure is an Invalid host name for which I have specified the IP addresses in the specific .service XML files.

Each IP address is "pingable" from the router ssh command line, and I can connect the smb services using Finder > Connect to Server on a Mac computer so these are connectable IP addresses even though they are on a different subnet. The subnet for the SMB services is on another Merlin enabled router with OVPN Server connected through OVPN client on this AC66U_B1 router and, apart from Bonjour discovery not working, the connections work as expected (devices on subnet offer web GUI login, smb connections in finder, Plex media servers).

Any suggestions for Avahi service configuration error message "Invalid host name" - are user specified services not supported? Is using IP address in the <host-name>192.168.xxx.xxx</host-name> field incorrect?
 
reading a bit more, I should try creating a hosts file in /tmp/avahi that would contain the static IP and host names like this:
Code:
192.168.1.10 HPprinter.lan
192.168.1.11 Mac.lan
Then use these host names in the service xml files. I'll try this next.

(I know there is a hosts file in /etc associated with dnsmasq but I think that should not be edited for my case)
 
Creating a hosts. file in /usr/tmp/avahi, and .service file in the /usr/tmp/avahi/services folder then restarting the mDNS service is successful with a NAS SMB service on another subnet: the service group name then appears in the network folder in Mac - which is great. Then clicking on this starts a connecting popup as expected.

Rebooting the router causes these new files to disappear, so the firmware must create temporary folders and files for avahi.

Looking at the custom-config-file wiki page, I think I could write a avahi-daemon.postconf script to copy in hosts and .service files into the /usr/tmp/avahi folders.
 
Got this working over my two OPVN connected Merlin routers for remote connections to two home NAS devices supporting SMB and TimeMachine.

Two routers are running Merlin 386.2_2:
  • home router AX-86U with Domain Name "lan" has NAS and OVPN server set up for LAN only.
  • remote router AC-66U_B1 with Domain Name "remotelan" has OVPN client.
  • => In this setup each router has a different IP address and a unique subnet. For testing, the remote router can be connected to a LAN port on home router.
0) For the following to work: Home NAS must not be connected to internet through a VPN client on the home router.

All these steps are made on the remote router:

1) check you can ping the home NAS IP, if not check Step 0)

2) add IP address of home NAS and NAShostname (this host name needs to be exactly the same as in Time Machine preferences) to hosts.add in /jffs/configs

/jffs/configs/hosts.add
Code:
192.168.1.10 NAShostname.lan
192.168.1.10 NAShostname.local

3) create two .service files for Avahi and store on user-created folder such as /jffs/user - these will be copied at router boot time over to /usr/tmp/avahi/services

/jffs/user/NAS-SMB.service
Code:
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
   <name>my NAS for SMB</name>
   <service>
    <type>_smb._tcp</type>
    <host-name>NAShostname.lan</host-name>  # added to hosts file in step 2.
    <port>445</port>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=RackMac</txt-record>
  </service>
</service-group>

/jffs/user/NAS-timemachine.service
Code:
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
   <name>TimeMachine on my NAS</name>
   <service>
    <type>_smb._tcp</type>
    <host-name>NAShostname.lan</host-name>  # Specified in hosts. file in Step 2.
    <port>445</port>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=RackMac</txt-record>
  </service>
  <service>
    <type>_adisk._tcp</type>
    <port>9</port>
    <txt-record>dk0=adVN=TimeMachine,adVF=0x82</txt-record>  # Share name TimeMachine.
  </service>
</service-group>

4. create a bash executable script for avahi-daemon.postconf in /jffs/scripts that will copy the .service files from Step 2 over to /usr/tmp/avahi/services. Read this Wiki link to understand more. Test first in another location!

/jffs/scripts/avahi-daemon.postconf
Code:
#!/bin/sh
logger 'Starting avahi-daemon.postconf..'
logger 'Copying .service files to avahi services folder..'
cp /jffs/user/NAS-timemachine.service /usr/tmp/avahi/services
cp /jffs/user/NAS-SMB.service /usr/tmp/avahi/services
I didn't need to restart the mDNS in this bash script: avahi detects the changed service files and updates accordingly.

Reboot the remote router only when you are confident the bash script runs without hanging..

Now remotely I see the NAS in Mac OS Finder network and Time Machine finds the home NAS and can run a backup. The backup is slow in my case due to limited internet upload speed at the remote location, but completes.

In the Finder, you'll see two icons for the NAS. This method did not work for me with just one service.

During a two week period I had to remotely reboot the home router one time to restore the OVPN connection between the routers.

(UPDATE: the above did not work for a second NAS on the same home network because it was connected through a VPN client on the home router, added Step 0).
 
Last edited:

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top