Posts: 128
Joined: Sun Dec 23, 2012 9:44 pm

Use of hostname in directing connections

Sun Feb 02, 2014 12:18 pm

Hi folks

I've quickly realised that the effort I went to to provide static IPs for my RPi's was a little over-the-top. I can SSH, connect via HTTP and complete other command line tasks (such as rsync) using the hostnames I have uniquely applied.

However, I'm a little uneasy as I'm not sure why this should work in the mixed environment that I have (Windows and *nix).

Could it be because I'm using Samba or should this work "out-of-the-box"? Could it be simply that I've made a good choice (incidentally) in the router and its DHCP capabilities?

Why am I concerned? Yes it does work, but my objective is to learn and understand!

Thanks in advance for any responses

Posts: 17410
Joined: Tue Jul 17, 2012 3:02 pm

Re: Use of hostname in directing connections

Sun Feb 02, 2014 6:11 pm

When you connect via ssh or http or whatever using a host name those programs will ask a DNS server to tell them the IP address that is the server for that host name. DNS = "Domain Name System".

This means that:

a) You don't need a static IP address.
b) You need a host name that is resolvable to the current IP address of the server.
c) You need a DNS server to serve up IP address resolution requests.

I guess in your case your router is allocating a dynamic IP addresses to your Pi as it connects to the local LAN and then acting as the DNS server when other machines on the LAN want to know an IP address for a host name.

In my case I have dynamic addresses on the local LAN assigned by my router, which has a dynamic public IP address on the internet provided by my ISP's DHCP. Then I use to provide a host name a Dynamic DNS. It's a free service.

None of this is to do with Samba.
Memory in C++ is a leaky abstraction .

User avatar
Posts: 6986
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Use of hostname in directing connections

Wed Feb 05, 2014 12:09 pm

There is also zeroconf/avahi

This way you can access your LAN devices with "hostname.local".
I don't remember if rasbian has avahi installed/configured by default.

But yes, in my opinion samba can be the cause also because samba uses the "netbios" protocol for name lookups.

Return to “Raspberry Pi OS”