TIPS & TRICKS
To search the contents of the man pages
# man -k searchterm |
Manage networking
Manage networking Example 1
| Assign hostname and ip address for your virtual machine.
| - Hostname: servera.lab.example.com
| - Ip address: 192.168.1.42
| - Mask: 255.255.255.0
| - Gateway: 192.168.1.1
| - NameServer: 192.68.1.200
On console (not remote console) :
# hostnamectl set-hostname servera.lab.example.com |
Note the interface with the ethernet type:
# nmcli connection show |
# nmcli connection modify enp0s8 ipv4.addresses 192.168.1.42/24 |
Note:
If you need to add several IP on a same interface, for example with DNS:
# nmcli connection modify enp0s8 ipv4.dns +192.168.1.43 |
Or you need to delete several IP on a same interface, for example with DNS:
# nmcli connection modify enp0s8 ipv4.dns -192.168.1.40 |
If needed, add autoconnect :
# nmcli connection modify enp0s8 connection.autoconnect yes |
UP the connexion, important:
# nmcli connection up enp0s8 |
From an other server or terminal, check @IP, gateway and DNS:
# ping 192.168.1.42 |
Then reboot:
# reboot |
Then re-test ping from an other server. Then connect to the host and verify configuration with:
# ip a |
New created connection are writted in /etc/
N
etworkManager/system-connections/
with a big N:
# ls -l /etc/NetworkManager/system-connections/ |
The DNS have been writted in /etc/resolv.conf
:
# cat /etc/resolv.conf |
Manage networking Example 2
| Please create new network connection using provided values:
| - IP: 192.168.1.44/24
| - Gateway: 192.168.1.255
| - DNS server: 192.168.1.250
| - Interface: eth0
That command creates a new connection for a specific interface. The interface is specified: “eth0”, you must specify with ifname the interface where the new connection will be created, the type “ethernet” and a name for the connection (here eth0, same as the interface). You can specify autoconnect:
# nmcli connection add con-name eth0 ifname eth0 type ethernet ipv4.method manual ipv4.addresses 192.168.1.44/24 ipv4.gateway 192.168.1.255 ipv4.dns 192.168.1.250 connection.autoconnect yes |
If needed, configure autoconnect :
# nmcli connection modify eth0 connection.autoconnect yes |
At the final stage it is wise to start this connection:
# nmcli con show --active # to check if the connection is not up |
New created connection are writted in /etc/
N
etworkManager/system-connections/
with a big N:
# ls -l /etc/NetworkManager/system-connections/ |
The DNS have been writted in /etc/resolv.conf
:
# cat /etc/resolv.conf |
Manage networking Example 4
| Update the /etc/hosts file on both server and client.
| Add the IP addresses assigned to both connections and map them to hostnames.
| Test connectivity from server to client and from client to server using their IP addresses and then their hostnames
On Server
# vim /etc/hosts |
On client :
# vim /etc/hosts |
Documentations
Internet
Git
ChatGPT