This content originally appeared on DEV Community and was authored by Ashen Chathuranga
This will let other devices on your local network access your machine using a hostname like:
http://archlinux.local:8080
instead of remembering the IP (192.168.x.x
).
1. Install required packages
sudo pacman -S avahi nss-mdns
2. Enable and start Avahi
sudo systemctl enable --now avahi-daemon
3. Configure /etc/nsswitch.conf
Open /etc/nsswitch.conf
with your favorite editor:
sudo nano /etc/nsswitch.conf
Replace its contents with this (copy and paste):
# Name Service Switch configuration file.
# See nsswitch.conf(5) for details.
passwd: files systemd
group: files [SUCCESS=merge] systemd
shadow: files systemd
gshadow: files systemd
publickey: files
hosts: files mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns myhostname
networks: files
protocols: files
services: files
ethers: files
rpc: files
netgroup: files
Save and exit.
4. Restart name resolution
sudo systemctl restart systemd-resolved
5. Test
On your Arch machine, run:
ping archlinux.local
You should see it resolve to your LAN IP (e.g., 192.168.3.224
).
On another device (Linux/macOS/iOS), try opening:
http://archlinux.local:8080
This content originally appeared on DEV Community and was authored by Ashen Chathuranga