Setting the hostname
1
| sudo hostnamectl set-hostname new_hostname
|
Find the NIC name
In this case it is named “ens18”.
1
2
3
4
| $ nmcli device
DEVICE TYPE STATE CONNECTION
ens18 ethernet connected ens18
lo loopback unmanaged --
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| $ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 62:bc:97:42:fd:4c brd ff:ff:ff:ff:ff:ff
altname enp0s18
inet 192.168.1.118/24 brd 192.168.1.255 scope global dynamic noprefixroute ens18
valid_lft 42106sec preferred_lft 42106sec
inet6 2600:1700:60ee:19f:60bc:97ff:fe42:fd4c/64 scope global dynamic noprefixroute
valid_lft 1788sec preferred_lft 1788sec
inet6 fd2d:f81:8e91:0:60bc:97ff:fe42:fd4c/64 scope global noprefixroute
valid_lft forever preferred_lft forever
inet6 fe80::60bc:97ff:fe42:fd4c/64 scope link noprefixroute
valid_lft forever preferred_lft forever
|
Change the IP address using nmtui
Using the “nmtui” utility”
Change the IP address using nmcli
1
2
3
4
5
6
7
8
9
| # Change the IP address to 'manual' (static) and specify the gateway (default route)
sudo nmcli con modify 'ens18' ipv4.method manual ipv4.addresses 192.168.1.181/24 gw4 192.168.1.1
# Set the DNS
sudo nmcli con modify 'ens18' ipv4.dns 4.2.2.2
# Stop and start the interface to use the new settings. Reboot also works.
sudo nmcli con down 'ens18'
sudo nmcli con up 'ens18'
|
Setting the interface to DHCP is way easier using the nmtui utility.