3

My linux desktop machine is running Kubuntu 16.04 Desktop LTS (Debian based linux); running a the KDE Plasma Desktop. To connect to the LAN I've simply configured the WiFi GUI (cable is not an option due to building), pointed it to the router and filled the password. Works just fine without problems.

However, the IP address allocated to my machine is handed via the DHCP server running on the router. Currently it's 192.168.0.34 but from day to day it changes depending on if I've switched off my machine, the router gets power cycled etc.

There are some options in the router under 'DHCP Reservation' which allows me to reserve a fixed IP address based on the MAC address of my WiFi card.

I have a MacBook and I like to SSH to the Linux machine so I can work anywhere in the house and garden. Usually I alter the /etc/hosts file on the MacBook and make an association mylinuxbox 192.168.0.34.

Without using DHCP Reservation, I would have to continuously change the /etc/hosts file to match the current DHCP Allocated IP Address.

Is there a way for the Linux machine to broadcast its IP address on the LAN?

If so, how is this done and is this a secure and acceptable practice?

Would fixing the IP on the router using DHCP Reservation be a better solution?

6
  • 2
    Run a DNS server? Commented Aug 9, 2016 at 15:44
  • Have you triied ssh mylinuxbox.local ? If both boxes are running zeroconf (i.e., bonjour on mac, avahi on linux), using the local domain should work. Commented Aug 9, 2016 at 15:45
  • 1
    Possible duplicate of How to make a machine accessible from the LAN using its hostname Commented Aug 9, 2016 at 15:55
  • Also see, unix.stackexchange.com/questions/52617/… Commented Aug 9, 2016 at 15:56
  • This seems more about getting the IP known by other machines, rather than getting hostnames known. It could be solved with DNS and dynamic updates, but that would be a bit excessive for such a simple situation Commented Aug 9, 2016 at 16:59

3 Answers 3

4

You can try to install Avahi, which is the Linux implementation of Zeroconf (known as Bonjour in Apple Mac/iOS environments), and set it to advertise your host as <hostname>.local.

All it takes is to install the following packages:

sudo apt-get install avahi-daemon avahi-dnsconfd avahi-discover avahi-utils libnss-mdns

You can find more details at https://askubuntu.com/questions/460371/trouble-using-ssh-and-avahi

3

You can use avahi.

Make sure avahi is running:

sudo service avahi-daemon status

If it's not running start it:

sudo service avahi-daemon start

then you can replace your ip with host-name.local while using ssh.

host-name is your host name

0

First of all, setting a static IP address for your main devices is a smart idea, and a must if you are running servers that need to be port forwarded. Second, you should just be able to fill in the IP address with the hostname on most Linux/Unix OSes out of the box (without using /etc/hosts). Try just using ssh mylinuxbox when mylinuxbox is the remote computers hostname.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.