Instructions written against Ubuntu 18.04.3 LTS (bionic)
Change the hostname:
sudo hostnamectl set-hostname server1
Check result by running hostnamectl
:
root@www:/# hostnamectl
Static hostname: server1 <-- Check this value
Icon name: computer-vm
Chassis: vm
Machine ID: 202c4264b06d49e48cfe72599781a798
Boot ID: 43654fe8bdbf4387a0013ab30a155872
Virtualization: xen
Operating System: Ubuntu 18.04.3 LTS
Kernel: Linux 4.15.0-65-generic
Architecture: x86-64
Change the domain via new network manager, Netplan, by editing /etc/netplan/01-netcfg.yaml
and changing the search
parameter:
sudoedit /etc/netplan/01-netcfg.yaml
Sample configuration:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: yes
nameservers:
search: [ domain.org ]
Test changes by logging in a second time, and running sudo netplan try
in one of the sessions and checking settings in the other:
# netplan try
Do you want to keep these settings?
Press ENTER before the timeout to accept the new configuration
Changes will revert in 97 seconds
Configuration accepted.
# systemd-resolve --status
...
Link 2 (eth0)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 8.8.8.8
8.8.4.4
DNS Domain: domain.org <-- Check this value
# cat /etc/resolv.conf
...
nameserver 127.0.0.53
options edns0
search domain.org <-- Check this value
# hostname -f
server1.domain.org
It all is well, press ENTER at the sudo netplan try
prompt to make things permanent.