Assign a link-local address to Linux and use DNS-SD / SSDP

For devices that automatically come up with a link local address (IPv4) in an environment without DHCP How to use APIPA on Ubuntu / Debian and how to discover for automatic configuration

Preparation

Installation of required packages

If you just use APIPA, you can achieve your goal with avahi-autoipd.

sudo apt-get install -y avahi-autoipd

As related tools, avahi-daemon and avahi-utils, as there are cases where names and services are resolved. In addition, if you want to detect with SSDP, add gupnp-tools.

sudo apt-get install -y avahi-utils gupnp-tools

Setting

If you want to use it with eth2, add the following to / etc / network / interfaces. With this setting, APIPA is applied to the eth2: avahi interface.

/etc/network/interfaces


auto eth2
iface eth2 inet manual
  up /usr/sbin/avahi-autoipd -D --force-bind eth2
  down /usr/sbin/avahi-autoipd -k eth2

Use

Just up the interface

sudo ifup eth2

Verification

root@buster:~# ip -4 a
...
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    inet 169.254.5.253/16 brd 169.254.255.255 scope link eth2:avahi
       valid_lft forever preferred_lft forever

Resolve IPs for things you know the name of

If you know the name, mDNS resolves the name in the .local domain. For example, if you want to resolve a machine called fs, ping fs.local

Try to display the service list with DNS-SD

avahi-browse -al

When you run it, it looks like this

root@buster:~# avahi-browse -al
+   eth1 IPv4 amzn.dmgr:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:xxxxxxxxxx:##### _amzn-wplay._tcp     local
+   eth1 IPv4 fs - SSH                                      SSH Remote Terminal  local
+   eth1 IPv4 fs - SMB/CIFS                                 Microsoft Windows Network local
+   eth1 IPv4 fs - NFS - home                               Network File System  local
+   eth1 IPv4 Google-Home-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  _googlecast._tcp     local
+   eth1 IPv4 Chromecast-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   _googlecast._tcp     local

If you add r to the option, it will resolve and display even the IP and port.

Try to display the device list with SSDP

Specify the interface and use gssdp-discover

gssdp-discover -i eth2:avahi

root@buster:~# gssdp-discover -i eth2:avahi --timeout=3
Using network interface eth2:avahi
Scanning for all resources
Showing "available" messages
resource available
  USN:      uuid:1a78e91b-d86d-11ea-8157-080027e8f737::upnp:rootdevice
  Location: http://169.254.86.237:1900/ddd.xml

Recommended Posts

Assign a link-local address to Linux and use DNS-SD / SSDP
Beginners! Basic Linux commands and how to use them!
[Linux] [C / C ++] How to get the return address value of a function and the function name of the caller
A super introduction to Linux
How to set up and use OMC Log Analytics --Linux version -
[sed] Use sed to replace tab characters on both macOS and Linux
How to install and use Tesseract-OCR
A memorandum to change to Manjaro Linux
How to use .bash_profile and .bashrc
How to install and use Graphviz
Connect to postgreSQL from Python and use stored procedures in a loop.
Use a shortcut to enable or disable the touchpad in Linux Mint
Build Linux on a Windows environment. Steps to install Laradock and migrate
[Linux] How to subdivide files and folders
How to split and save a DataFrame
How to install and use pandas_datareader [Python]
[Linux] How to use the echo command
How to use the Linux grep command
To get a local IP address programmatically
python: How to use locals () and globals ()
How to use Python zip and enumerate
How to use is and == in Python
How to use pandas Timestamp and date_range
Flutter in Docker-How to build and use a Flutter development environment inside a Docker container
On Linux (Ubuntu), tune the Trackpad and set the function to a three-finger swipe
A tool to insert the country name and country code in the IP address part