Skip to content

Commit cdc28ff

Browse files
authored
Merge pull request #1453 from kernelkit/discovery-docs
mDNS discovery improvements
2 parents 9b9ba63 + e2d1ed2 commit cdc28ff

File tree

18 files changed

+540
-200
lines changed

18 files changed

+540
-200
lines changed

.github/workflows/coverity.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
env:
99
PROJECT_NAME: Infix
1010
CONTACT_EMAIL: troglobit@gmail.com
11+
LIBYANG_VERSION: 4.2.2
12+
SYSREPO_VERSION: 4.2.10
1113

1214
jobs:
1315
coverity:
@@ -59,12 +61,20 @@ jobs:
5961
6062
- name: Build dependencies
6163
run: |
62-
git clone https://github.com/CESNET/libyang.git
64+
git clone -b v${LIBYANG_VERSION} --depth 1 https://github.com/CESNET/libyang.git
65+
for p in patches/libyang/${LIBYANG_VERSION}/*.patch; do
66+
git -C libyang apply < "$p"
67+
done
6368
mkdir libyang/build
6469
(cd libyang/build && cmake .. && make all && sudo make install)
65-
git clone https://github.com/sysrepo/sysrepo.git
70+
71+
git clone -b v${SYSREPO_VERSION} --depth 1 https://github.com/sysrepo/sysrepo.git
72+
for p in patches/sysrepo/${SYSREPO_VERSION}/*.patch; do
73+
git -C sysrepo apply < "$p"
74+
done
6675
mkdir sysrepo/build
6776
(cd sysrepo/build && cmake .. && make all && sudo make install)
77+
6878
git clone https://github.com/troglobit/libite.git
6979
(cd libite && ./autogen.sh && ./configure && make && sudo make install)
7080
make dep

doc/discovery.md

Lines changed: 86 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ link-local IPv6 address is then seen in the response. In the following
1818
example, the PC here uses *tap0* as *if1*, Infix responds with address
1919
*fe80::ff:fec0:ffed*.
2020

21-
```
22-
linux-pc:# ping -6 -L -c 3 ff02::1%tap0
21+
<pre class="cli"><code>linux-pc:# <b>ping -6 -L -c 3 ff02::1%tap0</b>
2322
PING ff02::1%tap0(ff02::1%tap0) 56 data bytes
2423
64 bytes from fe80::ff:fec0:ffed%tap0: icmp_seq=1 ttl=64 time=0.558 ms
2524
64 bytes from fe80::ff:fec0:ffed%tap0: icmp_seq=2 ttl=64 time=0.419 ms
@@ -28,20 +27,19 @@ PING ff02::1%tap0(ff02::1%tap0) 56 data bytes
2827
--- ff02::1%tap0 ping statistics ---
2928
3 packets transmitted, 3 received, 0% packet loss, time 2043ms
3029
rtt min/avg/max/mdev = 0.389/0.455/0.558/0.073 ms
31-
linux-pc:#
32-
```
30+
linux-pc:#
31+
</code></pre>
3332

3433
> [!TIP]
3534
> The `-L` option ignores local responses from the PC.
3635
3736
This address can then be used to connect to the device, e.g., using SSH.
3837
Notice the syntax `username@address%interface`:
3938

40-
```
41-
linux-pc:# ssh admin@fe80::ff:fec0:ffed%tap0
39+
<pre class="cli"><code>linux-pc:# <b>ssh admin@fe80::ff:fec0:ffed%tap0</b>
4240
admin@fe80::ff:fec0:ffed%tap0's password: admin
43-
admin@infix-c0-ff-ee:~$
44-
```
41+
admin@infix-c0-ff-ee:~$
42+
</code></pre>
4543

4644
### Windows
4745

@@ -52,29 +50,26 @@ no extra software required.
5250

5351
From the command line, use the `.local` hostname directly:
5452

55-
```cmd
56-
C:\> ping infix-c0-ff-ee.local
57-
C:\> ssh admin@infix-c0-ff-ee.local
58-
```
53+
<pre class="cli"><code>C:\> <b>ping infix-c0-ff-ee.local</b>
54+
C:\> <b>ssh admin@infix-c0-ff-ee.local</b>
55+
</code></pre>
5956

6057
> [!NOTE]
6158
> IPv6 multicast ping (`ping ff02::1%if1`) may not display responses on
6259
> Windows even though the Infix device replies correctly. If you need to
6360
> confirm connectivity, Wireshark will show the ICMPv6 echo replies
6461
> arriving. Use mDNS (see [mDNS-SD](#mdns-sd) below) as the reliable
6562
> alternative.
66-
67-
![Wireshark showing IPv6 ping responses](https://github.com/addiva-elektronik/alder/assets/122900029/c45d7726-448f-4c30-878e-bcf976dff531)
68-
63+
>
64+
> ![Wireshark showing IPv6 ping responses](img/windows-ipv6-ping-reply.png)
6965
7066
## LLDP
7167

7268
Infix supports LLDP (IEEE 802.1AB). For a device with factory default
7369
settings, the link-local IPv6 address can be read from the Management
7470
Address TLV using *tcpdump* or other sniffing tools[^1]:
7571

76-
```
77-
linux-pc:# tcpdump -i tap0 -Qin -v ether proto 0x88cc
72+
<pre class="cli"><code>linux-pc:# <b>tcpdump -i tap0 -Qin -v ether proto 0x88cc</b>
7873
tcpdump: listening on tap0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
7974
15:51:52.061071 LLDP, length 193
8075
Chassis ID TLV (1), length 7
@@ -103,8 +98,8 @@ tcpdump: listening on tap0, link-type EN10MB (Ethernet), snapshot length 262144
10398
End TLV (0), length 0
10499
^C
105100
1 packet captured
106-
linux-pc:#
107-
```
101+
linux-pc:#
102+
</code></pre>
108103

109104
If the device has an IPv4 address assigned, it is shown in an additional
110105
Management Address TLV.
@@ -116,8 +111,7 @@ Management Address TLV.
116111
In the example below, the IPv4 address (10.0.1.1) happens to be
117112
assigned to *eth0*, while the IPv6 address (2001:db8::1) is not.
118113

119-
```
120-
linux-pc:# sudo tcpdump -i tap0 -Qin -v ether proto 0x88cc
114+
<pre class="cli"><code>linux-pc:# <b>sudo tcpdump -i tap0 -Qin -v ether proto 0x88cc</b>
121115
tcpdump: listening on tap0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
122116
15:46:07.908665 LLDP, length 207
123117
Chassis ID TLV (1), length 7
@@ -152,43 +146,40 @@ tcpdump: listening on tap0, link-type EN10MB (Ethernet), snapshot length 262144
152146
2 packets received by filter
153147
0 packets dropped by kernel
154148
linux-pc:#
155-
```
149+
</code></pre>
156150

157151
The following capabilities are available via NETCONF/RESTCONF or the Infix CLI.
158152

159153
### LLDP Enable/Disable
160154

161155
The LLDP service can be disabled using the following commands.
162156

163-
```
164-
admin@infix-c0-ff-ee:/> configure
165-
admin@infix-c0-ff-ee:/config/> no lldp
166-
admin@infix-c0-ff-ee:/config/> leave
167-
admin@infix-c0-ff-ee:/>
168-
```
157+
<pre class="cli"><code>admin@infix-c0-ff-ee:/> <b>configure</b>
158+
admin@infix-c0-ff-ee:/config/> <b>no lldp</b>
159+
admin@infix-c0-ff-ee:/config/> <b>leave</b>
160+
admin@infix-c0-ff-ee:/>
161+
</code></pre>
169162

170163
To reenable it from the CLI config mode:
171164

172-
```
173-
admin@test-00-01-00:/config/> set lldp enabled
174-
admin@test-00-01-00:/config/> leave
175-
```
165+
<pre class="cli"><code>admin@test-00-01-00:/config/> <b>set lldp enabled</b>
166+
admin@test-00-01-00:/config/> <b>leave</b>
167+
</code></pre>
176168

177169
### LLDP Message Transmission Interval
178170

179171
By default, LLDP uses a `message-tx-interval` of 30 seconds, as defined
180172
by the IEEE standard. Infix allows this value to be customized.
181173
To change it using the CLI:
182174

183-
```
184-
admin@test-00-01-00:/config/> set lldp message-tx-interval 1
185-
admin@test-00-01-00:/config/> leave
186-
```
175+
<pre class="cli"><code>admin@test-00-01-00:/config/> <b>set lldp message-tx-interval 1</b>
176+
admin@test-00-01-00:/config/> <b>leave</b>
177+
</code></pre>
187178

188179
### LLDP Administrative Status per Interface
189180

190181
Infix supports configuring the LLDP administrative status on a per-port
191-
basis. The default mode is `tx-and-rx`, but the following options are
182+
basis. The default mode is `tx-and-rx`, but the following options are
192183
also supported:
193184

194185
- `rx-only` – Receive LLDP packets only
@@ -197,64 +188,72 @@ also supported:
197188

198189
Example configuration:
199190

200-
```
201-
admin@test-00-01-00:/config/> set lldp port e8 dest-mac-address 01:80:C2:00:00:0E admin-status disabled
202-
admin@test-00-01-00:/config/> set lldp port e5 dest-mac-address 01:80:C2:00:00:0E admin-status rx-only
203-
admin@test-00-01-00:/config/> set lldp port e6 dest-mac-address 01:80:C2:00:00:0E admin-status tx-only
204-
admin@test-00-01-00:/config/> leave
205-
```
191+
<pre class="cli"><code>admin@test-00-01-00:/config/> <b>set lldp port e8 dest-mac-address 01:80:C2:00:00:0E admin-status disabled</b>
192+
admin@test-00-01-00:/config/> <b>set lldp port e5 dest-mac-address 01:80:C2:00:00:0E admin-status rx-only</b>
193+
admin@test-00-01-00:/config/> <b>set lldp port e6 dest-mac-address 01:80:C2:00:00:0E admin-status tx-only</b>
194+
admin@test-00-01-00:/config/> <b>leave</b>
195+
</code></pre>
206196

207197
> [!NOTE]
208-
> The destination MAC address must be the standard LLDP multicast
198+
> The destination MAC address must be the standard LLDP multicast
209199
> address: `01:80:C2:00:00:0E`.
210200
211201
### Displaying LLDP Neighbor Information
212202

213203
In CLI mode, Infix also provides a convenient `show lldp` command to
214204
list LLDP neighbors detected on each interface:
215205

216-
```
217-
admin@test-00-01-00:/> show lldp
218-
INTERFACE REM-IDX TIME CHASSIS-ID PORT-ID
219-
e5 1 902 00:a0:85:00:04:01 00:a0:85:00:04:07
220-
e6 3 897 00:a0:85:00:03:01 00:a0:85:00:03:07
206+
<pre class="cli"><code>admin@test-00-01-00:/> <b>show lldp</b>
207+
<span class="header">INTERFACE REM-IDX TIME CHASSIS-ID PORT-ID </span>
208+
e5 1 902 00:a0:85:00:04:01 00:a0:85:00:04:07
209+
e6 3 897 00:a0:85:00:03:01 00:a0:85:00:03:07
221210
e8 2 901 00:a0:85:00:02:01 00:a0:85:00:02:05
222-
```
211+
</code></pre>
223212

224213
## mDNS-SD
225214

226215
DNS-SD/mDNS-SD can be used to discover Infix devices and services. By
227216
default, Infix use the `.local` domain for advertising services. Some
228217
networks use `.lan` instead, so this configurable:
229218

230-
```
231-
admin@infix-c0-ff-ee:/> configure
232-
admin@infix-c0-ff-ee:/config/> edit mdns
233-
admin@infix-c0-ff-ee:/config/mdns/> set domain lan
234-
```
219+
<pre class="cli"><code>admin@infix-c0-ff-ee:/> <b>configure</b>
220+
admin@infix-c0-ff-ee:/config/> <b>edit mdns</b>
221+
admin@infix-c0-ff-ee:/config/mdns/> <b>set domain lan</b>
222+
</code></pre>
235223

236224
Other available settings include limiting the interfaces mDNS responder
237-
acts on:
225+
acts on, `allow`:
238226

239-
```
240-
admin@infix-c0-ff-ee:/config/> set interfaces allow e1
241-
```
227+
<pre class="cli"><code>admin@infix-c0-ff-ee:/config/> <b>set interfaces allow e1</b>
228+
</code></pre>
242229

243-
or
230+
or `deny`. The `allow` and `deny` settings are complementary, `deny` always wins.
244231

245-
```
246-
admin@infix-c0-ff-ee:/config/> set interfaces deny wan
247-
```
232+
<pre class="cli"><code>admin@infix-c0-ff-ee:/config/> <b>set interfaces deny wan</b>
233+
</code></pre>
234+
235+
Use `leave` to activate the new settings, then inspect the operational
236+
state and any detected neighbors with `show mdns` from admin-exec
237+
context:
248238

249-
The `allow` and `deny` settings are complementary, `deny` always wins.
239+
<pre class="cli"><code>admin@gateway:/> <b>show mdns</b>
240+
Enabled : yes
241+
Domain : local
242+
Deny : wan
243+
244+
<span class="header">HOSTNAME ADDRESS LAST SEEN SERVICES </span>
245+
Living-Room.local 192.168.0.139 17:28:43 trel(59813) sleep-proxy(61936) raop(7000) srpl-tls(853)
246+
firefly-4.local 192.168.0.122 17:28:37 workstation(9)
247+
gimli.local 192.168.0.180 17:28:37 smb(445)
248+
infix.local 192.168.0.1 17:28:38 https(443) workstation(9) ssh(22) https(443)
249+
</code></pre>
250250

251251
----
252252

253253
In Linux, tools such as *avahi-browse* or *mdns-scan*[^2] can be used to
254254
search for devices advertising their services via mDNS.
255255

256-
```
257-
linux-pc:# avahi-browse -ar
256+
<pre class="cli"><code>linux-pc:# <b>avahi-browse -ar</b>
258257
+ tap0 IPv6 infix-c0-ff-ee SFTP File Transfer local
259258
+ tap0 IPv4 infix-c0-ff-ee SFTP File Transfer local
260259
+ tap0 IPv6 infix-c0-ff-ee SSH Remote Terminal local
@@ -281,7 +280,7 @@ linux-pc:# avahi-browse -ar
281280
txt = []
282281
^C
283282
linux-pc:#
284-
```
283+
</code></pre>
285284

286285
> [!TIP]
287286
> The `-t` option is also very useful, it stops browsing automatically
@@ -294,17 +293,15 @@ name mappings for IP addresses. By default, it translates from IPv4
294293
addresses. This function allows users to confirm that addresses are
295294
mapped correctly.
296295

297-
```
298-
linux-pc:# avahi-resolve-host-name infix-c0-ff-ee.local
296+
<pre class="cli"><code>linux-pc:# <b>avahi-resolve-host-name infix-c0-ff-ee.local</b>
299297
infix-c0-ff-ee.local 10.0.1.1
300298
linux-pc:#
301-
```
299+
</code></pre>
302300

303301
Thanks to mDNS we can use the advertised name instead of the IP
304302
address for operations like `ping` and `ssh` as shown below:
305303

306-
```
307-
linux-pc:# ping infix-c0-ff-ee.local -c 3
304+
<pre class="cli"><code>linux-pc:# <b>ping infix-c0-ff-ee.local -c 3</b>
308305
PING infix-c0-ff-ee.local (10.0.1.1) 56(84) bytes of data.
309306
64 bytes from 10.0.1.1: icmp_seq=1 ttl=64 time=0.852 ms
310307
64 bytes from 10.0.1.1: icmp_seq=2 ttl=64 time=1.12 ms
@@ -314,8 +311,8 @@ PING infix-c0-ff-ee.local (10.0.1.1) 56(84) bytes of data.
314311
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
315312
rtt min/avg/max/mdev = 0.852/1.105/1.348/0.202 ms
316313

317-
linux-pc:# ssh admin@infix-c0-ff-ee.local
318-
(admin@infix-c0-ff-ee.local) Password:
314+
linux-pc:# <b>ssh admin@infix-c0-ff-ee.local</b>
315+
(admin@infix-c0-ff-ee.local) Password:
319316
.-------.
320317
| . . | Infix OS — Immutable.Friendly.Secure
321318
|-. v .-| https://www.kernelkit.org
@@ -324,27 +321,25 @@ linux-pc:# ssh admin@infix-c0-ff-ee.local
324321
Run the command 'cli' for interactive OAM
325322

326323
linux-pc:#
327-
```
324+
</code></pre>
328325

329326
To disable mDNS/mDNS-SD, type the commands:
330327

331-
```
332-
admin@infix-c0-ff-ee:/> configure
333-
admin@infix-c0-ff-ee:/config/> no mdns
334-
admin@infix-c0-ff-ee:/config/> leave
335-
```
328+
<pre class="cli"><code>admin@infix-c0-ff-ee:/> <b>configure</b>
329+
admin@infix-c0-ff-ee:/config/> <b>no mdns</b>
330+
admin@infix-c0-ff-ee:/config/> <b>leave</b>
331+
</code></pre>
336332

337333
### Human-Friendly Hostname Alias
338334

339-
Each Infix deviuce advertise itself as *infix.local*, in addition to its
335+
Each Infix device advertises itself as *infix.local*, in addition to its
340336
full hostname (e.g., *infix-c0-ff-ee.local* or *foo.local*). This alias
341337
works seamlessly on a network with a single Infix device, and makes it
342338
easy to connect when the exact hostname is not known in advance. The
343339
examples below show how the alias can be used for actions such as
344340
pinging or establishing an SSH connection:
345341

346-
```
347-
linux-pc:# ping infix.local -c 3
342+
<pre class="cli"><code>linux-pc:# <b>ping infix.local -c 3</b>
348343
PING infix.local (10.0.1.1) 56(84) bytes of data.
349344
64 bytes from 10.0.1.1: icmp_seq=1 ttl=64 time=0.751 ms
350345
64 bytes from 10.0.1.1: icmp_seq=2 ttl=64 time=2.28 ms
@@ -354,8 +349,8 @@ PING infix.local (10.0.1.1) 56(84) bytes of data.
354349
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
355350
rtt min/avg/max/mdev = 0.751/1.482/2.281/0.626 ms
356351

357-
linux-pc:# ssh admin@infix.local
358-
(admin@infix.local) Password:
352+
linux-pc:# <b>ssh admin@infix.local</b>
353+
(admin@infix.local) Password:
359354
.-------.
360355
| . . | Infix OS — Immutable.Friendly.Secure
361356
|-. v .-| https://www.kernelkit.org
@@ -364,7 +359,7 @@ linux-pc:# ssh admin@infix.local
364359
Run the command 'cli' for interactive OAM
365360

366361
admin@infix-c0-ff-ee:~$
367-
```
362+
</code></pre>
368363

369364
When multiple Infix devices are present on the LAN the alias will not
370365
uniquely identify a device; *infix.local* will refer to any of the
@@ -390,12 +385,11 @@ portal to access all others, if it goes down another takes its place.
390385
To disable the netbrowse service, and the *network.local* alias, the
391386
following commands can be used:
392387

393-
```
394-
admin@infix-c0-ff-ee:/> configure
395-
admin@infix-c0-ff-ee:/config/> edit web
396-
admin@infix-c0-ff-ee:/config/web/> no netbrowse
397-
admin@infix-c0-ff-ee:/config/web/> leave
398-
```
388+
<pre class="cli"><code>admin@infix-c0-ff-ee:/> <b>configure</b>
389+
admin@infix-c0-ff-ee:/config/> <b>edit web</b>
390+
admin@infix-c0-ff-ee:/config/web/> <b>no netbrowse</b>
391+
admin@infix-c0-ff-ee:/config/web/> <b>leave</b>
392+
</code></pre>
399393

400394

401395
[^1]: E.g., [lldpd](https://github.com/lldp/lldpd) which includes the

doc/img/network-local.png

-185 KB
Loading

0 commit comments

Comments
 (0)