How can I test software that uses avahi while my laptop is disconnected from any router?

All of the services run on the same machine, so Avahi would be advertising an IP address of for all of the services.

As an example, I am using a file at /etc/avahi/services/postgresql.service to register a database:

$ cat /etc/avahi/services/postgresql.service
<?xml version="1.0" standalone="no"?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

When I am connected to the router, avahi-browse shows the service:

$ avahi-browse -a | grep my_database_name
+  wlan0 IPv6 my_database_name                              PostgreSQL Server    local
+  wlan0 IPv4 my_database_name                              PostgreSQL Server    local

When I am disconnected from the router, avahi-browse no longer shows any services and my software cannot find the database:

$ avahi-browse -a

Here is my interface information when I am disconnected:

$ ifconfig
eth0      Link encap:Ethernet  HWaddr f0:de:f1:ac:a6:37  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:20 Memory:f3900000-f3920000 

lo        Link encap:Local Loopback  
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:3637633 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3637633 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1242209987 (1.2 GB)  TX bytes:1242209987 (1.2 GB)

I am running Ubuntu 14.04 but may need to do this on other distributions as well.

Update: One of my (busy) friends sent me the following, which I have not been able to figure out yet:

Avahi, by nature will not properly bind to a loop interface. You can either turn up a dummy interface (best solution) or turn up a non-routable number on a physical interface. (works, but can be problematic if you are using a transient connection.)

2 Answers 2


Avahi requires that the interface have the MULTICAST flag set. That is,

ifconfig dummy0 multicast

Once the MULTICAST flag is set, avahi will automatically advertise services on that interface, no need to restart or otherwise mess with avahi configuration unless the interface is disallowed in the avahi configuration.

  • Complete instructions for my Ubuntu 14.04 system: enable dummy0 with: sudo modprobe dummy and configure it for ipv4 with: sudo ifconfig dummy0 netmask multicast Nov 4, 2014 at 1:52
  • Or for ipv6 (default on my system): sudo ifconfig dummy0 up multicast Nov 4, 2014 at 2:04

I did some digging and this ticket in the Chromim project's issue tracker sounds like what you're after. The ticket: Issue 288385: P2P: Write a fake avahi/zeroconf network to simulate a private network of peers has the following description:

Project Member Reported by [email protected], Sep 9, 2013

We want to run P2P tests on a single machine, faking the rest of the peers. This requires to isolate the avahi/zeroconf traffic to prevent seeing services from other DUTs on the same network and also expose services to the network.

The libavahi, used by p2p and update_engine, uses a private API to contact the avahi-daemon over DBus, thus replacing the avahi-daemon with a fake implementation would require to implement this interface that's not documented. Replacing the libavahi requires to compile a different version or use a fake libavahi interface that kind of looses the point of having an integration autotest test.

To fake the network of peers, another option is to create a TAP interface with a python script that fakes all the required avahi traffic, and let avahi-daemon listen ONLY on that interface during the test (we can do this through the avahi-daemon config file).

I looked through this ticket and it seems to have all the pieces you'd need, but figuring out how to put them together is missing. Perhaps you could drop a line to the Chromium project asking for some assistance with these pieces might be a good place to start.


  • Is this still what you would recommend even though I am not interested in faking other machines, but just one (the localhost) machine? Aug 25, 2014 at 17:39
  • @Oleg - I'm still searching for other methods and coming up empty. This is one approach that I've found, it seems like overkill for what you want though, but it does appear to be at least 1 option.
    – slm
    Aug 25, 2014 at 17:50
  • Please see the quote I added at the bottom of my question. Does that help? Sep 17, 2014 at 20:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .