I'm running Arch on my daily use laptop and I have two SSH terminals open up every time I login. I SSH into another Arch laptop, which is essentially a network connected hard drive in which I backup this laptop via Cron and rsync. The other device is Rasp Pi which is running OSMC and I do basic maintanance with the laptop. However the IPs keep changing all the time in my Wifi network so automatic SSH logins and Cron backups isn't working(since the command is username@ipaddress). Is there a way to assign static names to each Linux systems so the IP Address is not needed? Or am I completely misunderstanding how this thing works? Thanks.

  • 1
    Commercial NAS devices usually run something like busybox distro. A stripped down version of debian. If yours is busybox as well, it is debian based, just like ubuntu. If you search for how to assign static IP address on an ubuntu machine, you will find myriad of documents. Same can be said for whatever distro you are running on your RasPi probably raspian ?? If this is correct, another debian derivative. So same principle applies. – MelBurslan Aug 4 '16 at 3:17
up vote 1 down vote accepted

If you have control over the WiFi you should have control over the DHCP server (in home networks most likely your WiFi router). I would then propose these possible solutions:

  • Configure your DNS server (probably also on the WiFi router) to assign host names to the devices you want to reach. Then you can contact them by name rather than address.

  • Configure your DHCP server so that the devices you want to reach always get assigned the same IP addresses. Most DHCP servers should be able to do so. The server identifies them using their MAC addresses.

  • Have a look which address range is used by your DHCP server to assign addresses to devices. This could probably be something like 192.168.0.100 to 192.168.0.200 (for IPv4). Then assign some static addresses not in that range manually on the devices you want to read. OSMC is Debian-based, so you would most do it in /etc/network/interfaces. For Arch Linux, the configuration is different.

Use your pc hostname to below paths:

/proc/sys/kernel/hostname

/etc/hosts

/etc/sysconfig-network

Next.

If in your network you have a DNS server IP then please assign it to the below path.

/etc/resolve.conf

reboot

ssh itadmin@hostname.

regards. hamid karimi

The most simple way to do that is to configure your DHCP server on the router to give the same IP address to the RPi each time.

Almost all routers supports static leases, take a look on your DHCP server settings.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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