Guide- Setting up a Hostname
Setting up a Hostname
Depending on your network configuration, and how often you reboot your Rock 64 or your Router, you might see that the IP Address of the board changes. This is simply the byproduct of the device having a dynamically assigned IP address, most devices on home/small default to that mode.
If you wish to keep logging in or accessing your Board without having to keep track of your IP, there are two strategies. The first is assigning a Hostname to your device, so that even if it's IP address changes in the network, it will still be identifiable (and contactable) via a hostname. The second option is to configure the device to keep its IP address Static.
In this guide, we will be setting up a Hostname.
You'll need to make sure you know the IP address of your device, and be logged in via SSH.
The easiest way to do this is to use a tool called "nmtui". You'll need superuser privileges to invoke this text user interface, so put the following into the terminal and hit enter:
Use the arrows key to select "Set System Hostname" and press the tab key to highlight "okay".
Hit enter and you should get a text field to set the hostname of your choice.
Press the tab key to highlight "okay" and hit enter to set your new hostname:
Not all Distros have this tool installed. If you dont have nmtui installed, there is another fairly simple way.
You'll need to edit the file /etc/hostname and to do that, you'll need superuser privilege. Type in:
Then type in your password and hit enter.
It will open a basic text editor, in which you put down the hostname you'd like:
Hold down the Control key and Hit X to save and exit, you'll be prompted to save. Press the Y key:
Press enter to save the file, dont worry about the filename:
You'll need to edit one more file, in a similar way:
Change the first line to the same hostname you set prior:
Save and exit the document the same way: press Control + X, then Y, the Enter to finally save and exit the text editor. To immediately change the hostname without a reboot, you'll need to run a script:
sudo /etc/init.d/hostname.sh start
It should take a moment to run and return you to prompt. You should have your hostname changed now, confirm it by typing in "hostname" into the terminal:
To login using a hostname instead of an IP Address, you simply put in the hostname followed by a ".local" into your SSH client. This way, it will connect to the server, regardless of what its IP address may be. In this case, my hostname was rock64.
So, instead of doing
I can simply do
Which follows this notation:
Using this method, you will be able to access your board, regardless of what the IP address is.