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
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
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
Just up the interface
sudo ifup eth2
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
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
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.
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