All technological notes.
IP (Internet Protocol)
Private IP
Public IP
Static IP
Dynamic IP
Dynamic Host Configuration Protocol (DHCP) server.Network Interface
MAC address
network interface controller (NIC) for use as a network address in communications within a network.Subnet mask
Gateway
DNS (Domain Name System)
nmtui: Text Interfacenmtui
root

nm-connection-editornm-connection-editor


/etc/hostname/etc/hostname
hostname
| CMD | Desc |
|---|---|
hostname |
Display the Current Hostname |
hostname -a |
Display the alias name |
hostname -i |
Display IPv4 and IPv6 of the host. |
hostname -I |
Display IPv4 of the host. |
sudo hostname newhostname |
Set a Temporary Hostname |
hostnamectl |
Display Hostname Information |
sudo hostnamectl set-hostname newhostname |
Sets a new hostname and updates the /etc/hostname |
sudo hostnamectl set-hostname "pretty_name" --pretty |
Set the Pretty Hostname |
sudo hostnamectl set-hostname newstatichostname --static |
set a static hostname |
sudo hostnamectl set-hostname newtransienthostname --transient |
set a transient hostname (temporary hostname for the current session) |
hostname command
hostname command are not persistent after a reboot unless explicitly configured in /etc/hostname and /etc/hosts.hostnamectl command
systemd-based utility for managing the hostname.Static hostname: The permanent hostname set in /etc/hostname.Pretty hostname: An optional, human-readable version of the hostname.Transient hostname: A temporary hostname assigned dynamically (e.g., by DHCP).Icon name: An optional system identifier, usually for graphical systems.# display hostname
hostname
# rhelhost.localdomain
# display hostname info
hostnamectl
# Static hostname: rhelhost.localdomain
# Icon name: computer-vm
# Chassis: vm
# Machine ID: ca299475723c4510bf96994f9b0391d6
# Boot ID: 8236fb4874fc4e958e092424c1617a84
# Virtualization: vmware
# Operating System: Red Hat Enterprise Linux 8.10 (Ootpa)
# CPE OS Name: cpe:/o:redhat:enterprise_linux:8::baseos
# Kernel: Linux 4.18.0-553.30.1.el8_10.x86_64
# Architecture: x86-64
# Display hostname
hostname
# rhelhost.localdomain
# Change hostname temporarily
sudo hostname newhost
# view the hostname in cf
cat /etc/hostname
# rhelhost.localdomain
# reboot
systemctl reboot
# Display hostname
hostname
# rhelhost.localdomain
# view the hostname in cf
cat /etc/hostname
# rhelhost.localdomain
# Display hostname info
hostnamectl
# Static hostname: rhelhost.localdomain
# Icon name: computer-vm
# Chassis: vm
# Machine ID: ca299475723c4510bf96994f9b0391d6
# Boot ID: db70d05de8e7435798baa3b443c97ea7
# Virtualization: vmware
# Operating System: Red Hat Enterprise Linux 8.10 (Ootpa)
# CPE OS Name: cpe:/o:redhat:enterprise_linux:8::baseos
# Kernel: Linux 4.18.0-553.30.1.el8_10.x86_64
# Architecture: x86-64
# Change the static hostname
sudo hostnamectl set-hostname newhostname
# Change pretty name
sudo hostnamectl set-hostname "pretty_name" --pretty
# Change transient name
sudo hostnamectl set-hostname newtransienthostname --transient
# Confirm
# hostname for current session
hostname
# newhostname
# confirm
cat /etc/hostname
# newhostname
hostnamectl
# Static hostname: newhostname
# Pretty hostname: pretty_name
# Transient hostname: newtransienthostname
# Icon name: computer-vm
# Chassis: vm
# Machine ID: ca299475723c4510bf96994f9b0391d6
# Boot ID: db70d05de8e7435798baa3b443c97ea7
# Virtualization: vmware
# Operating System: Red Hat Enterprise Linux 8.10 (Ootpa)
# CPE OS Name: cpe:/o:redhat:enterprise_linux:8::baseos
# Kernel: Linux 4.18.0-553.30.1.el8_10.x86_64
# Architecture: x86-64
# reboot
systemctl reboot
# show hostname
hostname
cat /etc/hostname
# newhostname
hostnamectl
# Static hostname: newhostname
# Pretty hostname: pretty_name
# Icon name: computer-vm
# Chassis: vm
# Machine ID: ca299475723c4510bf96994f9b0391d6
# Boot ID: 5a82a02c3a634367991075db25be1cf1
# Virtualization: vmware
# Operating System: Red Hat Enterprise Linux 8.10 (Ootpa)
# CPE OS Name: cpe:/o:redhat:enterprise_linux:8::baseos
# Kernel: Linux 4.18.0-553.30.1.el8_10.x86_64
# Architecture: x86-64
/etc/hosts/etc/hosts
hostname-to-IP address mapping.IP_address hostname [aliases...]
/etc/resolv.conf/etc/resolv.conf
Domain Name System) settings.File format
option value
nameserver 8.8.8.8
Common options:
search: Defines a list of domain names to append to unqualified hostnames for resolution.nameserver: Specifies a DNS server by its IP address.domain: Specifies the default search domain.options: Allows additional resolver options, such as timeouts.
options timeout:2 attempts:3Example:
domain example.com
search example.net example.org example.edu example.gov
nameserver 192.168.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver configured on the localhost,/etc/nsswitch.conf/etc/nsswitch.conf file
File Structure:
database: source1 source2 source3
Common databases:
passwd: Resolves user account information.shadow: Resolves user password information.hosts: Resolves hostnames to IP addresses.networks: Network names and numbersgroup: Resolves group account information.services: Resolves network service names to port numbers.ethers: Resolves Ethernet address to hostnames.netgroup: Resolves NIS netgroups.protocols: Resolves network protocols.aliases: Resolves mail aliases.Common sources:
files: Refers to local files (e.g., /etc/hosts, /etc/passwd).dns: Refers to DNS servers.nis: Refers to NIS (Network Information Service).mdns: Refers to Multicast DNS.ldap: Refers to LDAP (Lightweight Directory Access Protocol).Default Host
/etc/hosts file for hostname resolution.hosts: files dns
cat /etc/nsswitch.conf | grep dns
# hosts: files dns myhostname
# networks: files dns
cat /etc/resolv.conf
# search localdomain
# nameserver 192.168.204.2
# nameserver 8.8.8.8
cat /etc/hosts
# 192.168.204.10 localdomain
hostname
# localdomain
ping localdomain
Step-by-Step Domain Name Resolution
/etc/nsswitch.confhosts: files dns myhostname:
files: Local files like /etc/hosts.dns: Queries DNS servers specified in /etc/resolv.conf.myhostname: Resolves using the local machine’s hostname./etc/hosts:
/etc/hosts file for the localdomain hostname.192.168.204.10 localdomain
192.168.204.10, the system uses this entry and resolves localdomain without further queries.ping abc.com
Step-by-Step Domain Name Resolution
/etc/nsswitch.conf
hosts: files dns myhostname:
files: Local files like /etc/hosts.dns: Queries DNS servers specified in /etc/resolv.conf.myhostname: Resolves using the local machine’s hostname./etc/hosts:
/etc/resolv.conf
search localdomain: directive appends localdomain to single-label hostnames (e.g., resolving abc as abc.localdomain before querying DNS).nameserver 192.168.204.2: the gateway, possibly a local DNS server or resolvernameserver 8.8.8.8: Google’s public DNSResult Handling:
nmclinmcli device status
# DEVICE TYPE STATE CONNECTION
# ens160 ethernet connected ens160
# ens224 ethernet connected static_con
nmcli connection down ens160
nmcli connection modify ens160 ipv4.dns 8.8.4.4
nmcli connection show ens160 | grep "ipv4.dns:"
# ipv4.dns: 8.8.4.4
nmcli connection up ens160
# confirm
grep "nameserver" /etc/resolv.conf
# nameserver 8.8.4.4
# nameserver 192.168.204.2
| CMD | Desc |
|---|---|
nmcli connection modify "id_name" ipv4.dns "dns_ip" |
Set the DNS ip |
sudo nano /etc/resolv.conf |
Configure DNS server |
grep "nameserver" /etc/resolv.conf |
Get DNS server |
nslookup target_domain |
DNS lookup a domain name |
nslookup target_domain nameserver |
DNS lookup a domain name with a nameserver |
dig target_domain |
DNS lookup a domain name |
host target_domain |
DNS lookup a domain name |
dig -x ip_address |
Reverse lookup |
host -v ip_address |
Reverse lookup |
nslookup ip_address |
Reverse lookup |
# Get DNS server
grep "nameserver" /etc/resolv.conf
# nameserver 192.168.128.2
# query a domain name
nslookup google.com
# Server: 192.168.128.2
# Address: 192.168.128.2#53
# Non-authoritative answer:
# Name: google.com
# Address: 142.251.32.78
# Name: google.com
# Address: 2607:f8b0:400b:807::200e
# DNS lookup using a specific nameserver
nslookup google.com 192.168.128.2
# Server: 192.168.128.2
# Address: 192.168.128.2#53
# Non-authoritative answer:
# Name: google.com
# Address: 142.251.41.78
# Name: google.com
# Address: 2607:f8b0:400b:807::200e
dig google.com
# ; <<>> DiG 9.16.23-RH <<>> google.com
# ;; global options: +cmd
# ;; Got answer:
# ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48899
# ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
# ;; OPT PSEUDOSECTION:
# ; EDNS: version: 0, flags:; MBZ: 0x0005, udp: 4000
# ;; QUESTION SECTION:
# ;google.com. IN A
# ;; ANSWER SECTION:
# google.com. 5 IN A 172.217.165.14
# ;; Query time: 17 msec
# ;; SERVER: 192.168.128.2#53(192.168.128.2)
# ;; WHEN: Sat Feb 08 17:22:12 EST 2025
# ;; MSG SIZE rcvd: 55
host google.com
# google.com has address 142.251.32.78
# google.com has IPv6 address 2607:f8b0:400b:807::200e
# google.com mail is handled by 10 smtp.google.com.
# perform a reverse lookup
dig -x 172.217.165.14
# ; <<>> DiG 9.16.23-RH <<>> -x 172.217.165.14
# ;; global options: +cmd
# ;; Got answer:
# ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7501
# ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
# ;; OPT PSEUDOSECTION:
# ; EDNS: version: 0, flags:; MBZ: 0x0005, udp: 4000
# ;; QUESTION SECTION:
# ;14.165.217.172.in-addr.arpa. IN PTR
# ;; ANSWER SECTION:
# 14.165.217.172.in-addr.arpa. 5 IN PTR yyz12s06-in-f14.1e100.net.
# ;; Query time: 8 msec
# ;; SERVER: 192.168.128.2#53(192.168.128.2)
# ;; WHEN: Sat Feb 08 17:26:16 EST 2025
# ;; MSG SIZE rcvd: 95
host -v 8.8.8.8
# Trying "8.8.8.8.in-addr.arpa"
# ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63281
# ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
# ;; QUESTION SECTION:
# ;8.8.8.8.in-addr.arpa. IN PTR
# ;; ANSWER SECTION:
# 8.8.8.8.in-addr.arpa. 5 IN PTR dns.google.
# Received 62 bytes from 192.168.128.2#53 in 9 ms
nslookup 8.8.8.8
# 8.8.8.8.in-addr.arpa name = dns.google.
# Authoritative answers can be found from:
/etc/sysconfig/network-scripts//etc/sysconfig/network-scripts/ directory
Configuration Files
Network Interface Configuration Files
ifcfg-<interface_name>Common fields:
TYPE: The type of connection (e.g., Ethernet, Bridge).BOOTPROTO: The method of assigning an IP address (none, dhcp, static).NAME: Interface name.DEVICE: Name of the physical device (matches the interface name).ONBOOT: Whether to activate the interface during boot (yes or no).TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=eui64
NAME=ens160
UUID=bea1745d-c7f0-430a-a575-9c06f5d420a7
DEVICE=ens160
ONBOOT=yes
DNS1=8.8.4.4
route-<interface> or route6-<interface>nmcli connection command