NetworkManager Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 70: Line 70:
=Specifying a DNS Server=
=Specifying a DNS Server=


==With nmcli==
==Configure DNS with nmcli==


Configuring DNS details with nmcli has the advantage that it keeps in sync /etc/resolv.conf, and avoids complications related to having to configure NetworkManager '''not''' to manage DNS.
Configuring DNS details with nmcli has the advantage that it keeps in sync /etc/resolv.conf, and avoids complications related to having to configure NetworkManager '''not''' to manage DNS.
Line 83: Line 83:
  ...
  ...


Use the connection name "eth0" to query the current DNS configuration:
2. Use the connection name "eth0" to query the current DNS configuration:


  nmcli con show eth0 | grep ipv4.*dns
  nmcli con show eth0 | grep ipv4.*dns


Modify the DNS configuration:
3. Modify the DNS configuration:


  nmcli con mod eth0 ipv4.dns-search "ocp36.local"
  nmcli con mod eth0 ipv4.dns-search "ocp36.local"
nmcli con mod eth0 ipv4.dns-domain "ocp36.local"
  nmcli con mod eth0 ipv4.dns "192.168.122.23 8.8.8.8"
  nmcli con mod eth0 ipv4.dns "192.168.122.23 8.8.8.8"


Line 120: Line 119:


=Disable the Network Manager=
=Disable the Network Manager=
 
<syntaxhighlight lang='bash'>
 
<pre>
systemctl stop NetworkManager
systemctl stop NetworkManager
systemctl disable NetworkManager
systemctl disable NetworkManager
</pre>
</syntaxhighlight>


If it is not going to be used, it can be removed completely.
If it is not going to be used, it can be removed completely.


<pre>
<syntaxhighlight lang='bash'>
yum -y remove NetworkManager
yum -y remove NetworkManager
</pre>
</syntaxhighlight>

Latest revision as of 23:27, 5 August 2023

Internal

General Status

nmcli general status

Show All Connections

nmcli con[nection] show

Show All Devices

To show devices recognized by NetworkManager and their state:

nmcli dev[ice] show
nmcli dev[ice] status

Bounce Connection

nmcli con down eth0
nmcli con up eth0

Configuration Changes

Changes made with nmcli do not require a reload but do require the associated interface to be put down and then up again as follows:

nmcli dev disconnect <interface-name>
nmcli con up <interface-name>

⁠Adding a Static Ethernet Connection

nmcli connection add type ethernet con-name <connection-name> ifname <interface-name> ip4 <address> gw4 <address>

Note that a connection with the same name exists, NetworkManager will add another one, so you will end up with two connections with the same name. It is best if the existing one is either deleted, modified or edited.

Example:

mcli con del eth0
nmcli con add type ethernet con-name eth0 ifname eth0 ip4 172.30.0.4/16 gw4 172.30.0.1

Also note that the "nmcli con add" command also declare the interface as seeing the default route, irrespective of the fact a default route may already exist. To correct this behavior, modify the DEFROUTE declaration to "no" in the corresponding ifcfg-* configuration file. For more details see Linux Routing Configuration - Default Route.

Alternatively, ifcfg configuration scripts can be edited:

Linux 7 Configuring a Network Interface

Adding a Dynamic Ethernet Connection

Same as adding the static one, but without specifying the ip/gateway:

nmcli connection add type ethernet con-name <connection-name> ifname <interface-name>

Specifying a DNS Server

Configure DNS with nmcli

Configuring DNS details with nmcli has the advantage that it keeps in sync /etc/resolv.conf, and avoids complications related to having to configure NetworkManager not to manage DNS.

The procedure consists in the following steps:

1. Determine the connection name associated with the network device we want to configure DNS for:

nmcli dev status
DEVICE  TYPE      STATE      CONNECTION
eth0    ethernet  connected  eth0
...

2. Use the connection name "eth0" to query the current DNS configuration:

nmcli con show eth0 | grep ipv4.*dns

3. Modify the DNS configuration:

nmcli con mod eth0 ipv4.dns-search "ocp36.local"
nmcli con mod eth0 ipv4.dns "192.168.122.23 8.8.8.8"

Bounce the connection for the changes to take place. Be careful if you're logged into the machine over ssh, it may sever the only connection to the host.

Unmanaged by NetworkManager

Set NetworkManager "dns" processing mode to "none" and "rc-manager" to "unmanaged" in the main section of NetworkManager configuration file /etc/NetworkManager/NetworkManager.conf.

[main]
...
dns=none
rc-manager=unmanaged

Then configure the DNS server(s) in /etc/resolv.conf.


Edit the Find NetworkManager configuration file and add/modify following entry in CentOS5 it is in /etc/NetworkManager/nm-system-settings.conf Or /etc/NetworkManager/system-connections/ and edit your DSL connection file :

[ipv4] method=auto dns=8.8.8.8;4.2.2.2; ignore-auto-dns=true

Disable the Network Manager

systemctl stop NetworkManager
systemctl disable NetworkManager

If it is not going to be used, it can be removed completely.

yum -y remove NetworkManager