Search This Blog

2014-01-08

Network Manager

For the longest time I couldn't figure out what the purpose of NM_CONTROLLED=no in /etc/sysconfig/network-scripts actually meant. What is Network Manager, and what is it's purpose?

We have desktop distributions of Linux mainly in part for introducing NetworkManager. The purpose of this feature is to easily manage network connectivity in a single location and provide a more dynamic configuration for network interfaces. To make that easier to understand think about it with an example. If I'm sitting at home, and I have just plugged in a wired network to my laptop I would likely want this interface to take priority over the wirless interface I'm currently connected to. NetworkManager does that, network manager also monitors various other aspects of network connectivity and will perform actions based on certain statuses it sees.

NetworkManager also attempts to be the centralized location for all network statuses so that all applications can check it to see what the status of the network is and to take action themselves when network connectivity dies, whether that be to work in offline mode or perform some other task.

NetworkManager doesn't always provide the most useful functionality when it comes to infrastructure servers though where network connectivity is generally desired to be static and unchanging in most scenarios. In this case we can either disable NetworkManager or install a [ackages in the OS that doesn't include NetworkManager by default.

Disabling NetworkManager

Check if Network Manager is installed/enabled at boot
chkconfig --list NetworkManager
If it is on and running stop it
service NetworkManager stop 
Prevent it from booting on startup
chkconfig NetworkManager off
Change configs to use network service to startup on boot instead
NM_CONTROLLED=no
ONBOOT=yes
Restart networking
service network start
Ensure traditional network service is enabled on boot
chkconfig network on

Using Network Manager

Now network manager isn't completely useless on server machines. You can use it to generate connection profiles.

Let's say we have an interface with no configuration on it.

We can run the "nmcli" commandline tool in order to configure this instead of going in an futzing with configuration files manually

This will create us a connection called $connName with the specified parameters we want

nmcli connection add con-name $connName ifname $ethernetName type ethernet ip4 $ipAddress/$subnet gw4 $defaultGateway


We can then add DNS information to this interface as well:

nmcli connection modify $connName ipv4.dns "$ipDns1 $ipDns2"


This will create a configuration file under "/etc/sysconfig/network-scripts/ifcfg-$connName"

You can list contents of connections by using

nmcli -p connection show $connName

The output of nmcli is tab-completed so if you have more than 1 connection type you can tab it out

References:
http://www.redhat.com/magazine/003jan05/features/networkmanager/
https://access.redhat.com/site/documentation/en-US/Red_Hat_OpenStack/3/html/Installation_and_Configuration_Guide/Disabling_Network_Manager.html

No comments:

Post a Comment