Skip to content

Commit 407b6c6

Browse files
committed
Update, mention format specifiers
Signed-off-by: Joachim Wiberg <[email protected]>
1 parent bbd9265 commit 407b6c6

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

_posts/2024-07-24-setting-hostname.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,49 @@ categories: [examples]
66
tags: [cli]
77
---
88

9-
Notice how the hostname in the prompt does not change until the change
10-
is committed by issuing the leave command.
9+
A common task for initial setup of your operating system is to change
10+
the hostname of a device. The default is a unique name composed from
11+
the built-in default name suffixed by the last three octets of the base
12+
MAC address.
13+
14+
```
15+
admin@infix-c0-ff-ee-:/>
16+
```
17+
18+
In this example the built-in name is `infix` and the last three octets
19+
resemble my favorite morning drink. The built-in name depends on the
20+
Infix build and can be [tailored to your product][0].
21+
22+
The hostname can be changed from the system configuration context:
1123

1224
```
13-
admin@host:/> configure
14-
admin@host:/config/> edit system
15-
admin@host:/config/system/> set hostname example
16-
admin@host:/config/system/> leave
25+
admin@infix-c0-ff-ee:/> configure
26+
admin@infix-c0-ff-ee:/config/> edit system
27+
admin@infix-c0-ff-ee:/config/system/> set hostname example
28+
admin@infix-c0-ff-ee:/config/system/> leave
1729
admin@example:/>
1830
```
1931

20-
The hostname is advertised over mDNS-SD in the `.local` domain. If
21-
another device already has claimed the example.local CNAME, in our case,
22-
mDNS will advertise a "uniqified" variant, usually suffixing with an
23-
index, e.g., `example-1.local`. Use an mDNS browser to scan for
24-
available devices on your LAN.
32+
Notice how the hostname in the prompt does not change until the change
33+
is committed by issuing the leave command.
34+
35+
There are a few format specifiers available:
36+
37+
- `%h`: built-in hostname, here `infix`
38+
- `%i`: built-in identity, here `infix` (depends on branding)
39+
- `%m`: last three octets of base MAC address (may be 00-00-00)
40+
- `%%`: literal `%` character
41+
42+
One good reason to maintain a unique hostname, e.g., using `%m`, is that
43+
it is advertised over mDNS-SD in the `.local` domain. If another device
44+
already has claimed the `example.local` CNAME, mDNS will notice this and
45+
advertise a "uniqified" variant, usually suffixing with an index, e.g.,
46+
`example-1.local`. Use an mDNS browser to scan for available devices on
47+
your LAN.
2548

2649
> Critical services like syslog, mDNS, LLDP, and similar that advertise
2750
> the hostname, are restarted when the hostname is changed.
2851
{: .prompt-info }
52+
53+
54+
[0]: https://github.com/kernelkit/infix/blob/main/doc/branding.md

0 commit comments

Comments
 (0)