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

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         UG    100    0        0 eth0   U     100    0        0 eth0   U     0      0        0 virbr0

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

$ cat /etc/resolv.conf 
Generated by NetworkManager

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
 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)                          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                   no
 connection.permissions:                                 --
 connection.master:                      --
 connection.slave-type:                  --
 connection.autoconnect-slaves:          -1 (default)
 connection.gateway-ping-timeout:        0
 connection.metered:                     unknown
 connection.lldp:                        -1 (default)

Configure networking resolution statically

# nmcli connection modify eth0 ipv4.addresses ipv4.gateway ipv4.dns 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 *