Thursday, September 8, 2016

Silly Linux Question

I have a mixed LAN (Linux, Windows, some printers, etc. -- call it perverse and degenerate if you like, but everyone has his/her/its own purpose).  I would like to run rsh hostname from one Linux box to another.  But I really do not want to use the IP addresses.  How do you get a list of LAN hosts in Linux?

Second question: /etc/hosts contains static IP/name entries.  How do you get the hostnames IP address list from your router into /etc/hosts?  Maybe I am fooling myself but I would think this would be a very common thing to do.  I suspect that I just need the right search string.  local DNS from router DHCP table?  It appears that dnsmasq is the right solution, but it doesn't work for me.


  1. Dont use RSH, use SSH. If you don't want to bother with a password, set up a certificate. Basically use ssh-keygen to make a key on the client, then take the public key from that client and put it in .ssh/authorized_keys of the account you want to be able to log on to. Sometimes it's authorized_keys2, but I think that's been mostly deprecated by this point.

  2. Edit /etc/hosts. Reference the Linux Network Adminstrators Guide for more complete details.

  3. If you have a local dns server, grabbing the local zone file should work. If you don't have a local dns server, you probably should. You probably don't need more than a raspberry pi for your likely loads if you don't want to run the daemon on an existing linux box.

  4. I'm not sure Linux hosts advertise their hostnames on the LAN. (I could be wrong.)

    Possible plan B: Without setting up DNS for your LAN, you might put your
    hostname->ip mapping in each Linux host's '/etc/hosts' file.

    man 5 hosts

  5. 1. Don't use rsh. Rsh in ancient, probably not very well supported and Considered Bad. OTH, on Linux Mint rsh is a symlink to ssh and rsh isn't even available anymore.

    2. On a small network you can add all of your hosts to /etc/hosts and you can then use rsh *shudder* or even better, ssh to connect to them.

    /etc/hosts should already have at least one entry (depending on what flavor of Linux your are running) to use as an example: localhost

    Just add more hosts below that. The syntax is:

    On an internal network you only need the first two. For publicly reachable systems you would use the fully qualified domain name as the second and then the short hostname as the third.

    So for a small, internal network: localhost host1 host2

    Add the entries on every host and you should be able to $ ssh without using the IP.

    3. If you have a slightly larger network you can look into using dnsmasq and set one up as an internal DNS server.

  6. Since these are static ip's on your private internal network it would be easiest to follow the suggestion of just adding entries in /etc/hosts. That is how I've done it on my home and test lab networks for over 20 years (I was running Unix workstations at home back in the 90's).

  7. (a) You do not want to "rsh hostname". You want to "ssh hostname". Rsh considered harmful.
    (b) You can try something like this: also: This might help with RHEL: Debian

    Or if you have a really small number of machines you can edit /etc/hosts directly.

  8. I don't know much about convincing Linux to find hostnames via local DNS. There are ways to do it manually, usually with a tool like nmap or arp-scan.

    But I do know this: all the comments about /etc/hosts assume a list of hosts with static IP addresses.

    On my in-house network, the router is configured to offer dynamic IP addresses in a certain range. (Let's say, "" to "".) I let most WiFi access, and the Windows machine, get their IP from the router in that way.

    Then, I configure most Linux machines to claim static IPs in a lower range. (Say, addresses in the range to

    Every time I add a machine, I have to add that machine-name, plus its new IP, to the "/etc/hosts" list of all Linux machines on the network. I also have to set up the static IP config file to use the router's internal address as a Gateway, and to use either the router or the ISP as a source for DNS resolution for the internet. (This is in /etc/resolv.conf on most Linux installations, where DNS-name servers can be referenced. You can add multiple sources to this listing; I think they will be queried in the order listed in the file. If you add an internal DNS to your network, you will need to reference that server in this file on any Linux host that wants to use the DNS.)

    I think that there is an equivalent file to /etc/hosts somewhere in the C:\Windows\ directory, if you wish to set up the same listing on a Windows machine. I think Windows will let you use static IP addresses, but it's been ages since I tried. Windows-Static-IP's will definitely need a gateway and a list of DNS-resolution-addresses.

    A related thought...if you have multiple routers, you first want to figure out which ones are offering DNS, what IP ranges they are handling, and how all the segments talk to each other.

  9. SJ: No problem setting up Linux boxes with both DHCP and fixed IP addresses? It's ugly, but easier than trying to get the DHCP list from the router. Is there some painless way to copy the /etc/hosts file to all my Linux boxes, or just plan on doing an scp each time I add a new host and update it on one box?

  10. I define all of my IP devices in my router's DHCP section by MAC address. I not only assign them an IP address, but a Host Name.

  11. Michael: Unfortunately, this Tenda router seems to have no way to access the DHCP settings. Easy to plug in as appliance. I think I am going to make all my Linux boxes fixed IP in their /etc/hosts files.