DNS, Hostname, Alias
Q: When there are multiple NICs, how to generate /etc/hosts records?
When there are multiple NICs, and you want to use confignetwork to configure these NICs, suggest to use hosts table to configure the installation NIC (installnic) and to use nics table to configure secondary NICs. Refer to the following example to generate /etc/hosts records.
Best practice example:
There are 2 networks in different domains:
mgtnetworkandpubnetwork
mgtnetworkis xCAT management networkThere are 2 adapters in system node1:
eth0andeth1Add installnic
eth010.5.106.101record in/etc/hosts, its alias ismgtnichostnames
node1-pubandnode1.public.comare for niceth1, IP is192.168.30.101
Steps:
Add networks entry in
networkstable:chdef -t network mgtnetwork net=10.0.0.0 mask=255.0.0.0 domain=cluster.com chdef -t network pubnetwork net=192.168.30.0 mask=255.255.255.0 domain=public.comCreate
node1with installnic IP10.5.106.101, its alias ismgtnic:chdef node1 ip=10.5.106.101 hostnames=mgtnic groups=allConfigure
eth1innicstable:chdef node1 nicips.eth1=192.168.30.101 nichostnamesuffixes.eth1=-pub nicaliases.eth1=node1.public.com nictypes.eth1=Ethernet nicnetworks.eth1=pubnetworkCheck
node1definition:lsdef node1 Object name: node1 groups=all ip=10.5.106.101 hostnames=mgtnic nicaliases.eth1=node1.public.com nichostnamesuffixes.eth1=-pub nicips.eth1=192.168.30.101 nicnetworks.eth1=pubnetwork nictypes.eth1=Ethernet postbootscripts=otherpkgs postscripts=syslog,remoteshell,syncfilesExecute
makehosts -nto generate/etc/hostsrecords:makehosts -nCheck results in
/etc/hosts:10.5.106.101 node1 node1.cluster.com mgtnic 192.168.30.101 node1-pub node1.public.comEdit
/etc/resolv.conf, xCAT management node IP like10.5.106.2is nameserver:search cluster.com public.com nameserver 10.5.106.2Execute
makedns -nto configure DNS
Q: How to configure aliases?
There are 3 methods to configure aliases:
Use
hostnamesinhoststable to configure aliases for the installnic.If you want to use script
confignetworkto configure secondary NICs, suggest to usealiasesinnicstable to configure aliases. Refer to Configure AliasesIf you want to generate aliases records in
/etc/hostsfor secondary NICs and you don’t want to use the scriptconfignetworkto configure these NICs, suggest to useotherinterfacesinhoststable to configure aliases. Refer to following example:If you want to add
node1-hd20.1.1.1inhoststable, and don’t useconfignetworkto configure it, you can addotherinterfaceslike this:chdef node1 otherinterfaces="node1-hd:20.1.1.1"
After executing
makehosts -n, you can get records in/etc/hostslike following:20.1.1.1 node1-hd
Note: If suffixes or aliases for the same IP are configured in both hosts table and nics table, will cause conflicts. makehosts will use values from nics table. The values from nics table will over-write that from hosts table to create /etc/hosts records.
Q: How to handle the same short hostname in different domains?
You can follow the best practice example.
Best practice example:
There are 2 networks in different domains:
mgtnetworkandpubnetwork
mgtnetworkis xCAT management networkGenerate 2 records with the same hostname in
/etc/hosts, like:10.5.106.101 node1.cluster.com 192.168.20.101 node1.public.comNameserver is xCAT management node IP
Steps:
Add networks entry in
networkstable:chdef -t network mgtnetwork net=10.0.0.0 mask=255.0.0.0 domain=cluster.com chdef -t network pubnetwork net=192.168.30.0 mask=255.255.255.0 domain=public.comCreate
node1withip=10.5.106.101, xCAT can manage and install this node:chdef node1 ip=10.5.106.101 groups=allCreate
node1-pubwithip=192.168.30.101, this node is only used to generate/etc/hostsrecords for public network, can use_unmanagedgroup name to label it:chdef node1-pub ip=192.168.30.101 hostnames=node1.public.com groups=_unmanagedExecute
makehosts -nto generate/etc/hostsrecords:makehosts -nCheck results in
/etc/hosts:10.5.106.101 node1 node1.cluster.com 192.168.30.101 node1-pub node1.public.comEdit
/etc/resolv.conf, for example, xCAT management node IP is 10.5.106.2 :search cluster.com public.com nameserver 10.5.106.2Execute
makedns -nto configure DNS
Q: When to use hosts table and nics table?
hosts table is used to store IP addresses and hostnames of nodes. makehosts use these data to create /etc/hosts records. nics table is used to stores secondary NICs details. Some scripts like confignetwork use data from nics table to configure secondary NICs. makehosts also use these data to create /etc/hosts records for each NIC.