I spent hours researching how I can automate 100s of hosts that are all under one local domain. (i'm on a ubuntu linux 17.04 machine)
For example, I have node1.domain.org, node2.domain.org, and the list goes to node100.domain.org
it is practically impossible to edit the /etc/hosts file adding all the alias manually.
For example,
127.0.0.1 localhost
127.0.1.1 harish
manually adding hostname aliases
10.2.1.3 node1.domain.org node1
The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
I tried the ip route | grep default
and found that the gateway to be 10.1.10.1 but not clue if I should be on this gateway or of any further steps from here.
I tried cat /etc/resolv.conf
and found the DNS Server I'm using
cat /etc/resolv.conf
Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN 127.0.0.53 is the systemd-resolved stub resolver. run "systemd-resolve --status" to see details about the actual nameservers.nameserver 10.2.254.254 nameserver 8.8.8.8 nameserver 127.0.0.53
search domain.com
I found the DNS that all my nodes are using
xcat node1 dns
SERVER: 10.2.254.254#53(10.2.254.254)
Both remote node dns and my localmachine dns matched.
However, No clue why it is domain.com in resolve.conf file and not domain.org as all the nodes are under domain.org and not domain.com (but it told it will overwrite when I try to edit it and it did. I tried to run 'sudo /etc/init.d/networking restart' or 'sudo service network-manager restart' after updating it to domain.org and the file is overwritten). I observed that can SSH using all aliases such as node1
without using node1.domain.org
when I did this change but the file is always overwritten on system restart or when i go on to wifi connection instead of Ethernet connection.
I also tried verifying the route
command and everything looks normal, still no clue
route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default gateway 0.0.0.0 UG 100 0 0 enp2s0f1
10.1.10.0 0.0.0.0 255.255.255.0 U 100 0 0 enp2s0f1
link-local 0.0.0.0 255.255.0.0 U 1000 0 0 enp2s0f1
All I want is to ssh node1 instead of ssh node1.domain.org or ssh node50 instead of ssh node50.domain.org or do ssh into any node using its alias without adding it manually to /etc/hosts. I just want to find out a robust way to do this.