Introduction
I have a Raspberry Pi running Rasbian connected to a Windows Server based network. This is a corporate (education) network that has its own intranet consisting of all connected computing systems and also has a publicly accessible website. For the purpose of this question, the domain will be named exampledomain.com
.
On this intranet, connected Windows computers can append a DNS suffix to their hostname through configuration on the network adapter (steps listed here). This would allow a computer with the name comp1
to be addressable by comp1
or comp1.ns.exampledomain.com
from the local network (i.e. ipconfig
lists ns.exampledomain.com
as the connection-specific suffix).
The Problem
I have a Raspberry Pi 2 that has the hostname comppi
that I need to be accessible by the address comppi.ns.exampledomain.com
. The Pi is currently accessible by its hostname comppi
, by using comppi.local
or by IP address.
Access via the hostname was achieved by installing samba to the RPi using sudo apt-get -y install samba
. This was the easy way to setup avahi
on the RPi.
I have no access to the DHCP/DNS servers involved. But I should be able to achieve this result without needing to. (As it can be done from a Windows computer just fine without)
I will also note that I have poor understanding of the /etc/dhcp/dhclient.conf
file even after reading the associated man
pages. I'm probably missing something trivial.
Current Attempts
- Tried changing the hostname directly to
comppi.ns.exampledomain.com
in all places in below files. - Tried changing the hostname line to
send host-name = "comppi.ns.exampledomain.com"
in/etc/dhcp/dhclient.conf
. - Tried adding the line
append domain-name = "ns.exampledomain.com"
to/etc/dhcp/dhclient.conf
user Jordan over on askubuntu.com. However I think this is just addingns.exampledomain.com
to outgoing hostname resolves when they fail.
Technical Info
- OS: Raspbian GNU/Linux 8 (jessie) (Note: this was the lite version)
- Pi: Raspberry Pi 2
- Hostname: comppi
Files
Contents of /etc/network/interfaces
unchanged.
Contents of /etc/hostname
:
comppi
Contents of /etc/hosts
:
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 comppi comppi.ns.exampledomain.com
Contents of /etc/dhcp/dhclient.conf
:
# Configuration file for /sbin/dhclient, which is included in Debian's
# dhcp3-client package.
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
#send host-name = gethostname();
send host-name = "comppi"
append domain-name = "ns.exampledomain.com"
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
dhcp6.name-servers, dhcp6.domain-search,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;
Best Answer
So, to resolve the
comppi.ns.exampledomain.com
on your network, you will need help from your DHCP server admin and here is why. At the bottom of this answer the Linux optionWindows environment
Unless additional software is installed, a LINUX client is not AD (Active Directory) aware. So, must rely on DHCP server to update the DNS Server on a properly configured Windows environment.
For the DHCP server to register a hostname on the local DNS server, must have dynamic updates authorized. This setting is not user configurable, your network admin should modify it, and yes, you will need this to work.
Along with the IP address from your DHCP server, you also receive the domain suffix for this network; the suffix is stored by your host and will be used later. Please note than unless your DHCP server and DNS server are on the same box, dynamic updates will require the DHCP server to authenticate with your DNS server.
At this point the DHCP server should do the DNS network registration for you. It is not under the client host control, however your host must request that. Currently Debian request the DNS registration automatically.
On windows your can force a re-registration with
ipconfig /registernds
.On a local network, a host can find your using two 'legal' names and methods: the plain hostname and the hostname plus the domain. The suffix '
.local
' if often ignored and is used to avoid the addition of another suffix.1 The first method doesn't use the DNS: using LAN broadcasts the host ask 'who know this name', the subject host will answer with a MAC address and IP.
Every few seconds, hosts broadcast their names so other sharing the LAN will learn about their presence. Often this broadcast are filtered by switch/routers, so unless you are on the same switch it's hard to make it reliable.
2 The second method is to send a request to the LAN designated DNS server, with the 'plain' hostname and also the hostname with the LAN suffix.
Home router and intranets are not public, so the use of generic DNS (8.8.8.8, 8.8.4.4) on your default DNS server will not resolve your local hosts at all. Every local host with a DHCP assigned address will be 'remembered' by your router.
On your host you can add one or more suffixes that you want when resolving a DNS address (using Linux
host
ordig
and on windowsnslookup
)I will recommend to have setup your hostname properly. On
/etc/hostname
and also on/etc/hosts
(for ::1 and 127.0.0.1) and then run. /etc/init.d/hostname.sh
.Manually updating DNS Server from Linux
There is another option that only requires manual cooperation on the client. The use of a little known utility nsupdate. This will add the functionality you require to register on a valid DNS Server. It follows RFC published protocols related to DNS.
Example:
You can create a simple file with your dynamically obtained IPV4 or IPv6 addresses and run on 'post-up' script on
/etc/network/interfaces