Typical Setup Methods

Its been a while since I setup a serious server so I’m trying to understand how things are done typically. I’m rebuilding THE central machine for my SOHO LAN used for software development. Will be doing DNS, NFS, SMB, homes, rsync snapshots, etc for a handful of laptops and PCs.

From reading the documentation and generally Googling around, I’m getting the sense that there are multiple ways to do things. I’d like to know what the prevailing techniques are today.

For example, I already set my hostname using:

# hostnamectl set-hostname nektar

However, this page:

https://docs.rockylinux.org/en/books/admin_guide/12-network/#the-hostname

reads:

To set the host name, the file /etc/sysconfig/network must be modified

and yet that file contains only a comment:

# Created by anaconda

Is there one true source of configuration in Rocky or are there multiple overlapping sources?

Presumably there’s a “low-level” way of doing things that requires additional knowledge and then there is another method that adds “code intelligence”. What are these methods referred to, what are their boundaries and, most important, which do most admins use?

Mike

1 Like

You should not need to “google around”, just follow the official docs:

In your case, you probably want Chapter 10

Uhg. RedHat’s documentation is awful. It always has been. Click on this, type that. No explanation of how it actually works. Like we’re dumb robots.

That documentation is intended to tell you how to do it.

“Why” is a somewhat different and substantially more complex question. In many cases the objective is simply to get the job done.

Awful or not, 6.2. Configuring Host Names Using Text User Interface, nmtui Red Hat Enterprise Linux 7 | Red Hat Customer Portal says:

Important

In Red Hat Enterprise Linux, NetworkManager uses the systemd-hostnamed service to read and write the static host name, which is stored in the /etc/hostname file. Due to this, manual modifications done to the /etc/hostname file are no longer picked up automatically by NetworkManager ; you should change the system host name through the hostnamectl utility. Also, the use of the HOSTNAME variable in the /etc/sysconfig/network file is now deprecated.

Note that this was for RHEL 7. So, the /etc/sysconfig/network was deprecated already in 7. It has not been resurrected for 8.

If RHEL docs are awful, then how do you rate that part of Rocky ‘Book’ that says “do this”, but was correct for RHEL 6, not for Rocky?

Rocky is a community effort both in good and bad. We all can contribute, but that does not ensure that each contribution is of same quality.

I don’t agree that the RHEL docs are awful, the intro asks the right questions, putting you on the right track for your use case; anything from a single user workstation to a datacentre. We see a lot posts on the Rocky forum where people have followed a guide that doesn’t apply to RHEL / Rocky, and then they complain that it doesn’t work.

I see. So the Rocky ‘Book’ is not accurate and no one wanted to tell me because it would shame someone. Whatever.

So how do you set the hostname?

Obviously I’m long past this step but I think it might help me understand how things are done these days. From the RH docs section 10.3.4.1 only the “Installation Summary window” is described and not how to change it after installation. There’s nothing about hostnamectl in the RH docs for 8. It is described in the docs for 7. But not 8. Clearly there’s some churn going on. Either in the docs, in the code, or both.

PS: The RH docs ARE awful. I would much rather understand the setup tools in general and not just some procedures from RH docs. Maybe THAT is why people are blindly trying stuff that doesn’t apply and complaining. Many (most?) of these tools are not specific to RH and it’s derivatives yes? I want to know how to troubleshoot and I’m not going to learn that from those awful docs. I’m guessing nobody uses that documentation anyway because the site doesn’t even work. When you click on a link in the left frame the entire page reloads and resets the left frame to the top.

PS2: Instead of trying to write a ‘Book’ which is apparently out dated before it’s completed, maybe write “Application Notes” that describe some feature in more depth and more generally. I read about 5 pages on the web about running named and they were all superficial and yet different in not insignificant ways. Writing a “RAN110: A DNS Server Configuration for a Small Private Network” app note might be a manageable piece of work for a contributor and more approachable for users.

Hi @ioplex ,

There is many ways to configure hostname. If you go deep, everything in Linux represented as file and to change something you need to perform file i/o operation.

So same action will be done by many ways but ultimately it will reflect on some file and reflected on system.

Just for your information you can change hostname in three ways:

  1. Edit respected file like /etc/hosts.
  2. through hostnamectl command.
  3. through nmcli command.

Everything is same and give you expected result, Some time one file have precedence over other file and it will over write configuration but if you perform same configuration to all file the no need to worry about unexpected result. if you aware about all these file then it will not make any diffrence which method you are using. But if you have any doubt then use program (hostnamectl OR nmcli )to make changes so they will care about all file.

I think this post will help you and answer your query.

With hostnamectl

RHEL 8 has multiple documents: Product Documentation for Red Hat Enterprise Linux 8 | Red Hat Customer Portal

@gerry666uk did point to the “How to use the Anaconda installer” piece. That is for initial installation. Even there are both interactive and automated (kickstart) methods. The interactive ask for values and choices and does then install. In kickstart user supplies the pre-made values and choices via a “kickstart-file”.

That is for the initial install. When you have a system and want to set hostname, methods are different.
Strangely, “A guide to configuring and managing networking in Red Hat Enterprise Linux 8” does not mention hostnamectl, while “Configuring and managing networks, network interfaces, and network services in RHEL 7” did.

The RH documentation is available as Single-page and Multi-page HTML, PDF, and ePub. Yes, the behaviour of TOC-pane in HTML versions is most inconvenient. Perhaps PDF ond ePub viewers are more comfy?

Most of the time I don’t set hostname at all – transient hostname is received from DHCP server.

Btw, for small network I do prefer dnsmasq as it can act as DHCP server, DNS server, and as TFTP server for PXEboot. Furthermore, rather than running separate dnsmasq.service, I have the NetworkManager.service start an instance. While that instance is primarily a caching DNS relay (as the default glibc resolver is “awful”), it can be customized to act as DHCP and authoritative DNS too.
How to make NM use dnsmasq: Chapter 31 in Configuring and managing networking Red Hat Enterprise Linux 8 | Red Hat Customer Portal

How to customize that instance … NM starts dnsmasq with some options. Some you can override, some work around. I have copy of configs somewhere and deploy with Ansible tasks:

- name: Get service facts
  service_facts:

- name: Install dnsmasq
  yum:
    name:  dnsmasq
    state: present
  when:
    - ansible_facts.services["NetworkManager.service"] is defined
    - ansible_facts.services["NetworkManager.service"].state == "running"

- name: Set NetworkManager to use dns=dnsmasq
  copy:
    src:  00-dns.conf
    dest: /etc/NetworkManager/conf.d/00-dns.conf
  when:
    - ansible_facts.services["NetworkManager.service"] is defined
    - ansible_facts.services["NetworkManager.service"].state == "running"
  notify: Restart NetworkManager

- name: Add config for dnsmasq in server
  copy:
    src:  "{{ dnsmasq_conf }}"
    dest: "/etc/NetworkManager/dnsmasq.d/{{ dnsmasq_conf }}"
  when:
    - ansible_facts.services["NetworkManager.service"] is defined
    - ansible_facts.services["NetworkManager.service"].state == "running"
    - dnsmasq_conf is defined and dnsmasq_conf|length > 0
  notify: Restart NetworkManager

- name: Add hosts for dnsmasq in server
  copy:
    src:  "{{ dnsmasq_hosts }}"
    dest: "/etc/{{ dnsmasq_hosts }}"
  when:
    - ansible_facts.services["NetworkManager.service"] is defined
    - ansible_facts.services["NetworkManager.service"].state == "running"
    - dnsmasq_hosts is defined and dnsmasq_hosts|length > 0
  notify: Restart NetworkManager

with 00-dns.conf:

# Ansible managed #
[main]
dns=dnsmasq

The dnsmasq_conf starts:

# Ansible managed #
domain-needed
bogus-priv
expand-hosts
domain=admin,10.0.0.0/24,local
interface=admin
listen-address=10.0.0.1
addn-hosts=/etc/ourhosts

# DHCP pool setup
dhcp-range=set:admin,10.0.0.200,10.0.0.240,12h
dhcp-option=tag:admin,option:router,10.0.0.1

Yes, but …

When system boots, services read files and act accordingly. However, changes on running system are not as clear. For most functions the active configuration is in memory. For example, firewall (nftables ruleset) is in kernel memory. One can change the active ruleset or change the ruleset stored in files; they are independent. Changes in memory do not persist after reboot. One can sync to/from memory and files.

Some services read files only when they start. You edit files and then you have to restart the service to get the changes in use right now, rather after reboot.
Some services watch their files and automatically reread after each change.
The ‘hostnamectl’ updates in memory data, but the service that “owns” that data does (auto)update files too.

A thing with files is that you can write anything into them. If you don’t write in correct format, then services fail to parse the file. You are responsible of both content and syntax.

You can type anything as command-line for CLI tool too, but it will give immediate feedback, rather than write unparseable files.

The GUI tools present only valid options that you have choose from. Writing a GUI that can show all combinations of complex set of values in meaningful way is not trivial.

The CLI and GUI hide the files; you “don’t need to know”. However, you can still feed them nonsense content. (Remember Little Bobby Tables from XKCD?)

This is the part that made me assume we were talking about “install time” as opposed to “already installed”.

Very interesting jlehtone!

I was not at all aware of dnsmasq but that might be precisely what I need actually. Unless …

I just got a Peplink router. Its just an entry level router but does DHCP and has a relatively sophisticated builtin DNS proxy. It seems you can create multiple VLANs (and not just one “guest” VLAN like the consumer routers) w/ multiple ESSIDs, each with their own configs mostly. Haven’t tried it yet though. Just arrived and its pre-owned so I have to reset it, see if it’s alive and if it will do what I need. If not, dnsmasq is clearly what I will need.

Thanks,
Mike