0

I am trying to grasp the purpose of static versus dynamic addressing, specifically when applied to private network. I am using SSH to connect from my PC to RPi via Ethernet.

The RPi has static IP which I simply type as parameter to ssh like this:

os64@os64-desktop:~$ ssh pi@10.0.1.38 

I have not figured out how to use DNS to name this connection. I do not see any such configuration in raspi-config to associate DNS with SSH.

How can this be accomplished with commands - using SSH as test bed?

closed as off-topic by Milliways, joan, tlhIngan, Dmitry Grigoryev, Steve Robillard Aug 14 '18 at 4:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – Milliways, joan, tlhIngan, Dmitry Grigoryev, Steve Robillard
If this question can be reworded to fit the rules in the help center, please edit the question.

3

On your local network you won't necessarily need to use DNS to access the Pi via a different host name. The .local domain, has been officially reserved as a Special-Use Domain Name (SUDN) specifically for the purpose of internal network usage. This way your custom local names don't conflict with existing external addresses.

This will require a service discovery process running on a local network via the mDNS/DNS-SD protocol suite. This could quite possibly already be running on your home router. If not you can install Apple's popular 'Bonjour' local network discovery service either on a Mac or on a windows machine. Of course you could always install it on the Pi as 'Avahi' using sudo apt-get install avahi-daemon

However, lets assume that there is a mDNS service already running, so straight out of the box the Pi should be able to be accessed using the host name raspberrypi. Because it is on your local network you would use raspberrypi.local

Therefore from your PC you would access it using;

ssh pi@raspberrypi.local

To change the host name for the Pi you can either edit /etc/hosts and /etc/hostname using sudo and nano, changing 'raspberrypi' for a name of your choice (then reboot for it to take effect);

sudo nano /etc/hostname
sudo nano /etc/hosts

... or you can do it via sudo raspi-config where you first select 'Network options' and then 'Hostname'.

  • Thanks. 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters 127.0.1.1 pi – Jan Hus Aug 10 '18 at 22:35
1

Posted here because it would not fit in as comment

Thanks for very comprehensive reply. Since I already had “host” name “pi” assigned in raspi-config it was just a matter of me using wrong syntax.

os64@os64-desktop:~$ ssh pi@pi.local

The authenticity of host 'pi.local (10.0.1.38)' can't be established.
ECDSA key fingerprint is SHA256:2hEjoJUeySW/Qqo3d+eV0DEAMX6Ob+9s8W/78/wG2jM.
Are you sure you want to continue connecting (yes/no)? Yes 
Warning: Permanently added 'pi.local' (ECDSA) to the list of known hosts.
pi@pi.local's password: 

And this is my current 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       pi

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