1

I've a network with a router (TP-LINK) which delivers internet to my PC and laptop. Recently, I got raspberry pi and would like to connect to via ssh. The fact that I'm aware how to set ssh connection to raspberry pi from laptop or PC but I'm wondering how to bind specific domain to my raspberry pi's ip adress. For instance, I'would like ssh hostname@domain_ from PC or my laptop instead of entering it's ip adress of pi in my home network to ssh. Can you help me?

P.S. There is a situation, where dynamic ip address allocated to my pi every time I reconnect it to network.

  • If you don't have a DNS server setup, then you have no system to bind IP's to host names. Give you Pi a static IP, and edit your HOSTS file. – Ƭᴇcʜιᴇ007 Feb 17 '15 at 16:41
  • 1
    possible duplicate of [How can I get my home machines to connect to each other via hostname?](http://superuser.com/questions/121236/how-can-i-get-my-home-machines-to-connect-to-each-other-via-hostname), http://superuser.com/questions/45789/running-dns-locally-for-home-network?rq=1 – Ƭᴇcʜιᴇ007 Feb 17 '15 at 16:41

4 Answers4

1

If you just want to use the simpler command to establish ssh connection you can try to make a config file:

$ cat ~/.ssh/config
Host pi4
  HostName 192.168.88.252
  User ak
  IdentityFile ~/.ssh/id_ecdsa

Host pi3
  HostName 192.168.88.248
  User ubuntu
  IdentityFile ~/.ssh/id_ecdsa

And If you want to use domain names, you must assign them to your raspberry somehow. I use MikroTik, so I just add static DNS records:

[admin@MikroTik] > ip dns static print
Flags: D - dynamic, X - disabled
 #    NAME                   REGEXP                  ADDRESS                                                  TTL
 0    router.lan                                     192.168.88.1                                             1d
 1    pi4.local                                      192.168.88.252                                           1d
 2    pi3.local                                      192.168.88.248                                           1d

As an alternative, you can edit hosts file on your machine like that:

$ cat /etc/hosts
127.0.0.1       localhost
127.0.1.1       pi4

192.168.88.252  pi4.local
192.168.88.248  pi3.local

P.S But of course, you need to make sure that your raspberry have a static IP address if you don`t want to edit all this configs every time

0

Why don't you just create an alias in Terminal to connect you via SSH automatically?

alias pi="ssh root@10.0.0.X"

So in future, just type in 'pi' in terminal and it will send the command.

0

As It is behind your router and I suppose you use NAT. One way to achieve this is to use a dns server with a dhcp server. The point is to create in your dhcp a static lease for your raspbery and add this to your dns. Other strategy is to add the raspberry in your host and to configure it with a static ip :)

izulh
  • 1
  • 2
-1

You could use No-Ip

You will an account (which is free) and select a domain.

Felipe
  • 16
  • 2