Can't ping pi4.local

I'm absolutely new to FreeBSD, but I've managed to install 14.1 on a Raspberry Pi 4B, got ntp working, installed nano and sudo, and done an update. So far, so good. I've changed the hostname from generic to pi4.local and expected to be able to to ping pi4.local from my iMac, but ping returns - ping: cannot resolve pi4.local: Unknown host. What's more, my router thinks the pi is called generic. Please can someone tell me what the problem is and how to fix it?
 
Just because you've set a hostname on a certain device doesn't mean other hosts on your network are able to resolve that hostname. There's this thing called DNS that does the translation of a hostname to an IP address. If that hostname isn't registered in DNS then other hosts will not be able to resolve it.

What's more, my router thinks the pi is called generic.
Restart the Pi after you changed the hostname. It's likely your router registered the hostname when it did a DHCP request.
 
I did reboot after changing the hostname. I then rebooted again after adding defaultrouter="192.168.1.1" to /etc/rc.conf. My router acts as a local DNS with everything else on my LAN. It's odd that it was able to recognise generic (without the .local domain). The router doesn't provide a way to delete generic, but is should drop it automatically and pick up the new hostname if FreeBSD was behaving like a default Debian of macOS. I'm guessing FreeBSD needs to be told to do something, bit I don't know what that might be.
 
Are you using DHCP on the PI? If yes, remove defaultrouter, you're getting a default gateway from DHCP.

If you're using static IP addresses on the PI then your router will not register the hostname. Most home internet routers will automagically register DHCP addresses in their DNS.
 
I've removed defaultrouter from /etc/rc.conf and rebooted, but macOS still can't resolve. How do I know if pi is using DHCP?

I know the router is allocating 192.168.1.40, because I can ssh pi@192.168.1.40 from macOS, but not by hostname. Also, I can't ssh root@192.168.1.40 - it resolves the hostname, but won't accept the password. This could be a security thing and not something I would normally wish to do.
 
Without knowing the DNS configuration on the router it will be a little difficult to help.
.local top level domain addresses are usually used in mDNS hostnames.
Many home routers use .lan or .home as the top level domain.

Just by naming the system pi4.local does not mean that the router will cache that name. It could be configured differently.

To test, I just setup a test FreeBSD vm (I named it fbsdtest.local), and ran some packet captures on DHCP requests from the FreeBSD machine.

The FreeBSD machine will only send the first part of the name, fbsdtest, in my case. It does not send the whole fbsdtest.local. (only sending hostname, not hostname and top level domain)

If your router is not using .local as the top level domain, and you are not running mDNS on the FreeBSD machine. Client systems on the LAN will not be able to resolve py4.local, without manually adding them to the hosts file on each client.


If you do want to use mDNS, here is a link to another post on configuring the mDNS service.
 
can you post the entire /etc/rc.conf file?
hostname="pi4.local"
# ifconfig_DEFAULT="DHCP inet6 accept_rtadv"
ifconfig_DEFAULT="DHCP"
sshd_enable="YES"
sendmail_enable="NONE"
sendmail_submit_enable="NO"
sendmail_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
growfs_enable="YES"
powerd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
ntpd_enable="YES"
ntpd_sync_on_start="YES"
# defaultrouter="192.168.1.1"
 
You can remove all the 'sendmail' declarations to help clean up the /etc/rc.conf file. Sendmail is no longer part of the base system in FreeBSD 14.0+.
 
Thank you to all who helped.
I now have pi4.local working as expected by installing openmdns and editing /etc/rc.config
mdnsd_enable="YES"
mdns_flags="genet0"
 
As said #18 above, I installed openmdns, but I now realise it's unmaintained and will likely be removed. I've also discovered there are similar sounding packages in the FreeBSD repository.

pkg search mdns

So I've no idea how to proceed. Should I remove openmdns and hope a FreeBSD version was already installed, or what?
 
I'm out of my depth here and don't know what openmdns does specifically.

There is this in the ports/pkg system: 'pkg search nsd-'

nsd-4.10.1 Authoritative only non-recursive name server

Would that serve the function you need?
 
I'm not totally sure what your end goal is here.
mDNS is a broadcast system, and as such not reliable (Subject to easy poisoning, etc) and intended for use on small networks that do not have a DNS server implemented.
You do have a DNS server on your router, so it would be far better to use that.

Additionally, being a broadcast system, it will not traverse networks (routers/vlans/firewalls) so unless it is on a very simple network it will not work well.

If you really want mDNS, you will have to explore and learn more about the other packages that are available. From the responses here, it does not seem that mDNS has a very big following. Build some Virtual Machines, and test the additional packages.

You could also clone the openmdns repo, and keep a copy of the source yourself to compile for future use if dropped.
Or better yet, if you really need the software, pick up the mantle of maintaining the software...

Additional thoughts...(a little off topic...)
If you are building a solution for a client, do you know if mDNS is allowed and not blocked on their network? Do they expect this to work across VLANs, wireless and wired?
Do they have a DHCP / DNS server setup that can handle the naming and resolution? Do they have an internal domain, and would it be better to integrate this device directly into the client network...
 
I'm not totally sure what your end goal is here.
I develop two GUI apps in Go for amateur television. They're published on GitHub free and open (github.com/ea7kir). Both run on Raspberry Pi 4's within a Wayland DE on Pi OS Bookworm, as a single application fullscreen on 7" touchscreens (kiosk mode, if you prefer). However, the RPI distribution includes loads of unwanted bloat, so I thought I'd give the latest FreeBSD a try.

The applications are strictly for home use on a 192.168.1.0 local area network. Apple, for whatever reason, defaults the hostname to a .local TDL and my home router (provided by Movistar, Spain) has no trouble remembering this. I can ping or ssh into any of my LAN devices.

As said, openmdns is working now, but I've discovered a bigger problem in another thread here which prevents me from adopting FreeBSD for the foreseeable future. The Raspberry Pi version doesn't have a video driver for Wayland. People may question why Wayland, but hey, I'm an amateur and, despite being 78, like to be trendy. Digital Amateur Television (DATV) via a geostationary satellite is experimental, cutting edge and also trendy.

Perhaps I should have explained my use case from the start. Thank you to all who have helped.
 
Back
Top