Configure networking and hostname resolution statically or dynamically

How to see the hostname of the system:

$ hostname            <-- just the hostname 
$ hostnamectl         <-- The hostname detailed

To change the hostname:

$ hostnamectl set-hostname newname.domain.com

Configuring the network by GUI:

Applications –> System Tools –> Settings –> Network:

Network settings.

Configuring the network by Terminal:

To view the current network settings, you can execute any of these commands:

# ip a    
# ifconfig

To view the route table, you can execute the command route -n:

$ route -n
 Kernel IP routing table
 Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
 0.0.0.0         192.168.122.1   0.0.0.0         UG    100    0        0 eth0
 192.168.122.0   0.0.0.0         255.255.255.0   U     100    0        0 eth0
 192.168.124.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

To view the DNS, check the file resolv.conf :

$ cat /etc/resolv.conf 
Generated by NetworkManager
search example.com
nameserver 192.168.122.230

note: The file /etc/sysconfig/network-scripts/ifcfg-eth0 contain the configuration of the network too.

Using nmcli command

$ nmcli connection show 
 NAME    UUID                                  TYPE            DEVICE 
 eth0    7fb041e9-a7ec-4a84-83fa-62c81f5040e9  802-3-ethernet  eth0   
 virbr0  7afda38c-73e9-445f-a954-b11a7b720dfc  bridge          virbr0 

$ nmcli device s
 DEVICE      TYPE      STATE      CONNECTION 
 virbr0      bridge    connected  virbr0     
 eth0        ethernet  connected  eth0       
 lo          loopback  unmanaged  --         
 virbr0-nic  tun       unmanaged  --   

to see more details:

$ nmcli -p connection show eth0 | less
===============================================================================
                        Connection profile details (eth0)
 connection.id:                          eth0
 connection.uuid:                        7fb041e9-a7ec-4a84-83fa-62c81f5040e9
 connection.stable-id:                   --
 connection.interface-name:              eth0
 connection.type:                        802-3-ethernet
 connection.autoconnect:                 yes
 connection.autoconnect-priority:        0
 connection.timestamp:                   1572395453
 connection.read-only:                   no
 connection.permissions:                 
 connection.zone:                        --
 connection.master:                      --
 connection.slave-type:                  --
 connection.autoconnect-slaves:          -1 (default)
 connection.secondaries:                 
 connection.gateway-ping-timeout:        0
 connection.metered:                     unknown
 connection.lldp:                        -1 (default)
...

Configure networking resolution statically

# nmcli connection modify eth0 ipv4.addresses 192.168.4.123/24 ipv4.gateway 192.168.4.2 ipv4.dns 192.168.4.231 connection.autoconnect yes ipv4.method manual
# nmcli connection down eth0
# nmcli connection up eth0

To delete a network connection:

# nmcli connection delete eth0

Configure networking resolution dynamically

# nmcli connection modify eth0 connection.autoconnect yes ipv4.method auto

Using tui utility:

# nmtui

To restart the network services:

# systemctl restart network.service

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *