A. You have to put NM_UNMANAGED to TRUE in a file in /etc/udev/rules.d in order to ensure "No default connection will be created and automatic activation will not be attempted".
That's a great question. I took a look at it on Fedora, so there might be a change in directory name.
This is what i found in the documentation.
man NetworkManager
UDEV PROPERTIES
udev(7) device manager is used for the network device discovery. The following property influences how
NetworkManager manages the devices:
NM_UNMANAGED
No default connection will be created and automatic activation will not be attempted when this property of a
device is set to a true value ("1" or "true"). You will still be able to attach a connection to the device
manually or observe externally added configuration such as addresses or routes.
In RHEL, the system rules should be in
ls /usr/lib/udev/rules.d/
And the default files dealing with that are in:
/usr/lib/udev/rules.d/
At the top of /usr/lib/udev/rules.d/85-nm-unmanaged.rules, it says:
head /usr/lib/udev/rules.d/85-nm-unmanaged.rules
Do not modify this file, it will get overwritten on updates.
To override or extend the rules place a file in /etc/udev/rules.d
The /etc/udev/rules.d folder is likely empty at the moment.
Examples.
The key to managing startup files for new network interfaces is to select the right group, or "envelope".
Example 1. Settings for new pci Network Interface Cards.
1. Select a test device.
When I put a new card in my virtual machine, it gives me a name such as: ens11
2. Get information to define a group.
Find the device class file:
find /sys/class -name "ens*"
This happens to be in /sys/class/net with other NIC's:
ls /sys/class/net
Get information about device (or the device tree with "-a"):
udevadm info /sys/class/net/ens11
udevadm info -a /sys/class/net/ens11 | more
This is how it looks on my screen:
[root@s1 ~]# udevadm info /sys/class/net/ens11
P: /devices/pci0000:00/0000:00:0b.0/net/ens11
E: DEVPATH=/devices/pci0000:00/0000:00:0b.0/net/ens11
E: ID_BUS=pci
...
E: ID_NET_NAME_SLOT=ens11
E: ID_PATH=pci-0000:00:0b.0
E: ID_PCI_CLASS_FROM_DATABASE=Network controller
...
E: USEC_INITIALIZED=2939943
I will use ID_PATH=pci-0000:00:0b.0 to group the devices I want to change. I will control individual buses with individual files.
3. Make a file in /etc/udev/rules.d/
cat /etc/udev/rules.d/pci_bus_0b.rules
#state down ( They are up by default. )
ENV{ID_PATH}=="pci-0000:00:0b.0", ENV{NM_UNMANAGED}="0", ENV{ONBOOT}="1"
#state up
#ENV{ID_PATH}=="pci-0000:00:0b.0", ENV{NM_UNMANAGED}="0", ENV{ONBOOT}="0"
4. Restart the devices and network.
Make sure there are no other important operations happening at the same time.
I had a virtual machine running on an internal hard drive without issue, but USB-connected hard drives went for a bit of a spin.
A much slower alternative could be to reboot.
udevadm trigger
# You should see the changes already:
udevadm info /sys/class/net/wlp0s8f7u4
systemctl restart NetworkManager
ip a
Example 2. Wireless lan usb Network Interface Card. (Wlan)
1. Select a test device.
When I plug in my usb wireless adapter, it gives me a name such as: wlp0s8f7u4
2. Get information to define a group.
Find the device file class
find /sys/class -name "wlp*"
This happens to be in /sys/class/net with other NIC's:
ls /sys/class/net
Get information about device (or the device tree with "-a"):
udevadm info /sys/class/net/wlp0s8f7u4
udevadm info -a /sys/class/net/wlp0s8f7u4 | more
This is how it looks on my screen:
[root@s1 ~]# udevadm info /sys/class/net/wlp0s8f7u4
P: /devices/pci0000:00/0000:00:08.7/usb1/1-4/1-4:1.0/net/wlp0s8f7u4
E: DEVPATH=/devices/pci0000:00/0000:00:08.7/usb1/1-4/1-4:1.0/net/wlp0s8f7u4
E: DEVTYPE=wlan
E: ID_BUS=usb
E: ID_MODEL=802.11_n_WLAN
...
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/wlp0s8f7u4
E: TAGS=:systemd:
E: USEC_INITIALIZED=4672793558
I will use "DEVTYPE=wlan" to group the devices I want to change.
3. Make a file in /etc/udev/rules.d/
cat /etc/udev/rules.d/Wireless_lan.rules
# State down
ENV{DEVTYPE}=="wlan", ENV{NM_UNMANAGED}="0", ENV{ONBOOT}="1"
# State up
#ENV{DEVTYPE}=="wlan", ENV{NM_UNMANAGED}="0", ENV{ONBOOT}="0"
4. Restart the devices and network.
Make sure there are no other important operations happening at the same time.
I had a virtual machine running on an internal hard drive without issue, but USB-connected hard drives went for a bit of a spin.
A much slower alternative could be to reboot.
udevadm trigger
# You should see the changes already:
udevadm info /sys/class/net/wlp0s8f7u4
systemctl restart NetworkManager
ip a
References:
Rules:
man 7 udev
Udev attributes: Arch Linux wiki
List of environvant variables:
(courtesy of Lekensteyn on the Unix forum):
grep -hrPo 'ENV{\K[^}]*(?=}=[^=])' /{etc,lib}/udev/rules.d | sort -u