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?

  • 2
    Run a DNS server? – Kevin Aug 09 '16 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. – user4556274 Aug 09 '16 at 15:45
  • 1
  • Also see, http://unix.stackexchange.com/questions/52617/how-can-i-resolve-local-ips-to-hostnames?noredirect=1&lq=1 – Thomas N Aug 09 '16 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 – ilkkachu Aug 09 '16 at 16:59
  • Since your machine looks like a server and talks like a server, give it a fixed address like a server. Either make the router give it the same address each time, or configure a fixed address for it (check the router's configuration to see what address range it uses for DHCP and avoid that). Since you have only one client machine, where you already configured the name in hosts, getting the name out shouldn't be a problem either. – ilkkachu Aug 09 '16 at 17:04

3 Answers3

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.