[avahi] Publishing Services on Specific Interfaces

Shilliday, Peter Peter.Shilliday at garmin.com
Wed Apr 29 23:52:34 UTC 2020


Yes, that worked.  Thanks!

-Peter


Date: Tue, 28 Apr 2020 15:43:28 +0000
From: Callum wilson <calwilson at live.co.uk>
To: Avahi ML <avahi at lists.freedesktop.org>
Subject: Re: [avahi] Publishing Services on Specific Interfaces
Message-ID: <DAF1E896-1B98-463A-ABF6-A9CBD25ADA4F at live.co.uk>
Content-Type: text/plain; charset="utf-8"

Hi Peter,

You can use if_nameto_index() to do this, see man page here: http://man7.org/linux/man-pages/man3/if_nametoindex.3.html

That will give you the index from the interfaces name (e.g. eth0, eno1, etc.).

Is that what you?re looking for?

Thanks,
Callum

From: avahi <avahi-bounces at lists.freedesktop.org> on behalf of "Shilliday, Peter" <Peter.Shilliday at garmin.com> Reply to: Avahi ML <avahi at lists.freedesktop.org>
Date: Tuesday, 28 April 2020 at 16:34
To: "avahi at lists.freedesktop.org" <avahi at lists.freedesktop.org>
Subject: [avahi] Publishing Services on Specific Interfaces


I am integrating avahi-client in a Linux application to publish a TCP-based service on two separate local networks, each on their own interface.  Since the service uses the ephemeral TCP port range, the listening port on network #1 and network #2 will almost always be different, so I want to add the service on each network/interface individually as to publish the right port number.  It appears avahi_entry_group_add_service() can take an interface index argument for this purpose; how can I look up the index for a given interface/network on my system?



Thanks,

Peter Shilliday


More information about the avahi mailing list