Last updated
Last updated
As the name implies, NetworkManager is one of the utilities that is used to manage network, including network interface cards (NIC) in Linux.
systemctl enable --now NetworkManager -> to enable the NetManager service.
vim /etc/sysconfig/network-scripts/ifcfg-<nicname> -> the network interface configuration file.
ip a -> To see the network cards available on a Linux system, use the command.
You can modify a network properties using network-manage-command-line-interface nmcli or network-manager-text-user-interface nmtui.
This all you need to know about networking, now lets learn how to modify a network properties (ipv4-ipv6-dns-gateway-prefix-) using different options. before doing this make sure to restart your network manager using the command below.
You can change the network properties using the configuration file below. -> /etc/sysconfig/network-scripts/ifcfg-<nicname>
All you have to do is adding the IPADDR-NETMASK-DNS-GATEWAY on the file. Make sure to change the BOOTPROTO to "none".
nmcli is a command-line client for NetworkManager. It allows controlling NetworkManager and reporting its status. For more information please refer to nmcli(1) manual page.
We are going to use long commands with nmcli
which are hard to memorize. bash-completion
will be helpful & ready to compose them for us.
- yum install -y bash-completion -> to install the bash-completion package.
- rpm -qa | grep bash-completion -> to verify.
Now lemme show you an few examples using the nmcli command.
nmcli conn show -> to list the connections.
nmcli conn add con-name network_name ifname ens160 ipv4.addresses 192.168.255.135/24 ipv4.gateway 192.168.0.1/24 ipv4.dns 8.8.8.8 type ethernet => Adding new connection type ethernet.
nmcli conn modify ens160 ipv4.adresses 192.168.132.125/24 ipv4.gateway 192.168.10.1 ipv4.dns 8.8.8.8 ipv4.method manual connection.autoconnect yes => Modifying the setting of the device ens160.
Is very important to set the method to manual, otherwise it will set to DHCP method by default. remember? we did this too in this configuration file when we did BOOTPROTO="none"
To add an ipv4 or ipv6 address with nmcli use the command below:
nmcli conn modify ens160 +ipv4.adresses 192.168.22.10/24
nmcli conn modify ens160 ipv6.method manual ipv6.adresses 3731:54:65fe:2::a8
nmtui - network manager text user interface will do the same job, also is more easier than all the options and is "noob-friendly". I will let the pictures speak haha.
See, ain't this easy? but honestly, I would recommend learning the nmcli command instead.
to change the hostname :
hostnamectl set-hostname <your_hostname>
vim /etc/hostname
/etc/resolv.conf
is the name of a computer file used in various operating systems to configure the system's Domain Name System (DNS) resolver.
consult this document for more advanced informations :
IP forwarding is a process used to determine which path a packet or datagram can be sent. The process uses routing information to make decisions and is designed to send a packet over multiple networks.
sysctl -a | grep net.ipv4.ip_forward
cat /proc/sysnet/ipv4/ip_forward => to check if IP Forwarding is enabled.
sysctl -w net.ipv4.ip_forward = 1 echo " net.ipv4.ip_forward= 1" >> /etc/sysctl.conf => to enable the IP Forwarding, change the value to 0 if you wish to disable.
Can't believe it, we made it haha! now we are free to move to the next chapter. great job body! don't forget to practice.
Learn about the basic network management in Linux.