So, I'm setting up an experiment network for me and the other geeks at my school to use for website testing and server practice. I'm the sys and net admin (but really it's just for playing Quake).

Messing with it at home, I find it tedious to have to type a whole IP address to SSH into a host (in this case, a Raspberry Pi). The current hostname I have for it is hyperfang. Instead of pi@longip, how can I make it so that I can make this pi@hyperfang? On my router, there are settings for a static DNS. Would I have to make a DNS server on my network for this to work?

My network is wireless, and laptops will be connected to the network. I have no root access to the laptops, but I have a Raspberry Pi for users to login through ssh. What I want is when anybody joins the network and wants to login to my Pi, they can use pi@hyperfang. I am not looking for a hostfile configuration solution, but something else like local domains.

I have avahi running on my Pi, but it isn't working.

NOTE: this network is NOT connected to the internet, it's a pure local network.


4 Answers 4


You can ssh into the Pi with [email protected]. hostname.local works in most places you would use an IP Address, although there are a few exceptions e.g. rsync.

This assumes that avahi is running, which should be the case for recent installations of Raspbian

  • This sounds very promising! My pi doesn't have it, but I'm apting it as I type. Commented May 25, 2016 at 2:09
  • Should be avahi - I misspelled it.
    – Milliways
    Commented May 25, 2016 at 2:13
  • Ah, I do have it then. It doesn't seem to be working though, any ideas? Commented May 25, 2016 at 2:19
  • What does ping hyperfang.local show? What are you testing on? I sometimes find it doesn't work after sleep etc, but should after restart does.
    – Milliways
    Commented May 25, 2016 at 2:56
  • It states that the host is unknown. I'm using a chromebook in a chroot. Commented May 25, 2016 at 3:00

There are a few different options depending on how much time you want to invest, your technical ability and how flexible you want the system to be.

For a small mixed or non-windows network I suggest using the hosts file on each machine. For a completely windows based network (which you do not have obviously, based on your post and the name of this site), you can generally rely on netbios to 'find' other windows machines on the network, providing hostname lookup capabilities among other things.

The hosts file, located in /etc/hosts on linux machines, is a simple list mapping IP addresses to hostnames. If you have fixed IP addresses and a relatively small number of machines to assign hostnames and IP addresses to, this is the way to go.

Here is a copy of the hosts file I have on this machine; not much in it because I use a local dns server (dnsmasq).

# /etc/hosts: static lookup table for host names

#<ip-address>   <hostname.domain.org>   <hostname>       localhost.localdomain   localhost
::1             localhost.localdomain   localhost     lenny
# End of file

Simply add a new line to this file for each IP address/hostname pair that you have. The localhost addresses, ipv6 and ipv4, have to stay in the file - things will typically go very poorly without those.

After you have populated this list, you need to distribute it to each machine on your LAN. Once that's done, you can refer to each machine by hostname instead of IP address. You can also give a given IP address multiple hostnames / aliases; eg    lenny   lennon  lemon

From a remote machine you can then connect to that machine with any of those names (if the modified hosts file is installed).

Windows machines also have a hosts file, buried a bit deeper in the system, usually at:


It uses the same syntax as the linux version. Here's a link for more info on this approach.

If you have a dedicated server and want to configure your own local dns, you can with two primary programs - dnsmasq and bind. Since this LAN isn't even connected to the internet, I think either would be overkill, but they are options. dnsmasq tends to be easier to configure, but is less full featured. Properly configured, bind can support enterprise grade infrastructure.


You can definitely use a raspberry pi as a local dns server; it's not uncommon. Here are a couple of links to get you started:

Linux Magazine blog.grobinson.net markwilson.it

The concern I would have is how the clients on this network are currently configured and if you would be able to modify it. If the clients are all configured for DHCP and the router that you have full access to is currently serving that role, then you are all set. You simply set the router's dns server to the fixed (non DHCP) address of the raspberry pi. You can use DHCP if you configure the router to use reserve that DHCP issued IP address for the MAC address of the pi - almost all routers allow that configuration.

Once you have that, configure the dns on the pi following these instructions.

Some routers have additional capability built into them - you should research that a bit - in some cases they create a custom domain (e.g. .local or .lan) and add all dhcp clients to it; allowing LAN communication by hostname. Others have similar capability to a hosts file (or even have a hosts file). I'd take a quick look before diving into dnsmasq.

  • The thing is that the "machines" are school owned laptops, so that forces me to use DNS. But, since you said a DNS solution, I'll try it out. Commented May 25, 2016 at 1:58
  • If you don't have the permissions necessary to modify the hosts file, you would have to have permissions to set the dns server address (admin) on each laptop or setup a DHCP and DNS server.
    – Argonauts
    Commented May 25, 2016 at 2:01
  • Can I run the DNS off of the pi that already uses ssh? I'm sure this will be fine on load, as the maximum amount of people messing with my network will be about 5 (I'm talking REAL tiny here). Commented May 25, 2016 at 2:04

If you only need the alias available on your own system you don't need a DNS server or your router involved. You can simply create the alias in one of two places depending on how you want to use it.

SSH Only Alias

If you only intend to SSH to hyperfang you can create an SSH config file with some information that effectively shortens your SSH command. For example.

  1. Verify that ~/.ssh/config exists. If it does not exist simply create it touch ~/.ssh/config.

  2. Edit the SSH config file as follows:

    Host hyperfang
        HostName <longassip>
        User pi
  3. Initiate an SSH connection using ssh hyperfang.

System Wide Alias (i.e. all network operations, not just SSH)

If you want to be able to ping, telnet, wget, curl etc to hyperfang you want something a bit more visible than the SSH config file. In this case the hosts file will work. You will need root credentials or sudo privilege to make this change.

  1. Edit /etc/hosts to append the following line:

    <longassip> hyperfang

  2. Initiate an SSH connection using ssh pi@hyperfang


If you want everyone on your network to be able to use hyperfang as an alias for , these are not the solutions for you and you want a DNS server. In that case either follow the directions of your router to set that up, or setup a DNS server in your network.

  • I know that trick, but multiple people want to access my pi, so I would like a systemwide solution where anyone can ssh into my pi using hyperfang, which is why I went to DNS. Good awnser though. Commented May 25, 2016 at 1:53

Static IP & 'hosts' File

Set the IP of the device to a static IP and add that IP and hostname to your /etc/hosts file. For example,    hyperfang.localnet.lan    hyperfang

SSH config File

Additionally, as was pointed out in another answer, adding an SSH configuration file/option will allow you to specify different items; e.g. user, port, etc.

$ cat ~/.ssh/config

   User pi


Create a simple script or alias that calls the function. Obviously, if other people are meant to use it as well to facilitate this process, then a script is the way to go; because the alias is local to your system and/or user.

alias sspi='ssh [email protected]'

For a script that can be distributed if/when necessary, this is an extremely simple attempt:


# Optional Message
echo 'This script is about to connect to...'

# Prompt for confirmation
read -p "Are you sure? " -n 1 -r
echo    # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
    exit 1

xterm -e ssh [email protected]

Not the answer you're looking for? Browse other questions tagged .