2

I would like to access my RPi on my local network by a FQDN that I have. Example: my home network can be reached at www.mydomain.com and that in turn with port forwarding will reach my RPi internally at 10.0.0.50 (set statically in the router/RPi)

From internally I would like to reach the same RPi at its FQDN of rpi.mydomain.com. Since the hostname = rpi and the static IP = 10.0.0.50 it seems like just adding to the /etc/hosts with the entry: 10.0.0.50 rpi.mydomain.com Should accomplish this. BUT... that's not the case. I can't seem to get around the problem that any hostname gets the .local appended to it in the browser. So all local request end up as rpi.local not rpi.mydomain.com.

I guess my question is "where is the raspberrypi.local DNS record cached and how can I clear it"? with my current setup I should be able to reach it at rpi.local at the least.

  • does your router support NAT loopback? note: adding the entry in the RPi /etc/hosts file won't effect other computers on your networks - you would need the hosts file (or equivalent depending on the OS) entry in each computer - if your router supports NAT loopback, that would be a far easier solution though – Jaromanda X Nov 30 '17 at 23:17
0

You can disable the ".local" domain via these two commands:

$sudo systemctl stop avahi-daemon
$sudo systemctl disable avahi-daemon

on the Raspberry Pi.

The avahi-daemon service enables the .local domain to be resolved on the LAN. It is common to have .local has the domain for LAN hosts. This simplifies accessing LAN hosts, just like it does for Internet hosts, by providing an name to IP address translation.

However, since you have configured your network differently, disabling the avahi-daemon will allow you to set your Raspberry Pi to a different FQDN. If you have accessed your RPi via raspberrypi.local previously, this will no longer function once avahi is disabled. You will need to use the IP address instead or the new FQDN if the address has an A record in your DNS zone.


Updates per comments

The hostname for systemd GNU/Linux systems, such as Raspbian, is set through the hostnamectl utility.

You can change the host name for the Raspberry Pi via:

hostnamectl set-hostname myhostname

If using avahi the new hostname will be accessible at myhostname.local

If avahi is disabled, the new hostname will be accessible at myhostname.domain.tld as long as there is an A record entered in the DNS zone file.

  • If the avahi-daemon is disabled can a host file entry allow the dns to resolve to rpi.mydomain.com or would the default domain entry in the Pi resolve this? – BarclayVision Dec 1 '17 at 1:52
  • @BarclayVision: updated answer to address your comment. – RubberStamp Dec 1 '17 at 2:27
  • So my question is still... is the Pi reachable in the LAN with the FQDM ? And would the router need a DNS entry or the host file? I get the A record in the WAN side. – BarclayVision Dec 1 '17 at 2:34
  • @BarclayVision: For IPv4 addresses, anything on the LAN is only reachable via either the .local tld, the internal IP address, or a NAT port mapped to an Internet domain's A record ... this is not Raspberry Pi specific... it's per RFC 6303 and some other RFCs... – RubberStamp Dec 1 '17 at 2:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.