A. Change hostname
$ hostnamectl set-hostname new-hostname
Check hostname
$ hostname
Reboot the server
B. Change IP Address
Find the following file – /etc/netplan
/01-netcfg.yaml
OR 50-cloud-init.yaml
Edit the IP/Interface info –
$ sudo chmod 600 /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: no
addresses:
- 192.168.1.10/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
Ensure that the Netplan configuration file permissions are secure to prevent unauthorized access.
$ sudo chmod 600 /etc/netplan/01-netcfg.yaml
Apply the configuration change
$ sudo netplan apply
Verify the ip address
$ ip a