1

When I change out a NIC card in my RHEL 5 box, the applicable /etc/sysconfig/network-scripts/ifcfg-eth? file is renamed ifcfg-eth?.bak and a new one is created configured with:

ONBOOT=yes
BOOTPROTO=dhcp

Q1) What script or program creates these default files?

Since I don't have a dhcp server, it just takes longer to boot up and get going.

Q2) Is there any configuration I could change so that newly detected NICs are configured with ONBOOT=no

NOTES:

  1. chkconfig --list NetworkManager shows that NetworkManager is disabled for all runlevels

  2. udev rules are saved in /etc/udev/rules.d. 60-net.rules is the only file with net in the filename.

  3. 60-net.rules contains:

    ACTION=="add", SUBSYSTEM=="net", IMPORT{program}="/lib/udev/rename_device"
    SUBSYSTEM=="net", RUN+="/etc/sysconfig/network-scripts/net.hotplug"
    
  4. rename_device doesn't seem to be the program that writes the initial file because the string ONBOOT is nowhere in the executable viewed with xxd. Also the source code online doesn't indicate that it writes this file either.

3 Answers 3

3

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

3
  • To be more specific about question 1, udev is what is generating those files. You don't want to shut it off though, it should be configured. If you do systemctl is-enabled NetworkManager and systemctl is-enabled network, you will probably find that the NetworkManager starts at boot. With Rhel 5 I can't remember if network service is on of off by default.
    – BloodyEl
    Jun 1, 2016 at 21:26
  • I think you're on the right track, but I still can't pinpoint the code that writes the file when the NIC is swapped. I've added notes for RHEL5 that might help. Jun 3, 2016 at 18:17
  • I'll can do a test for both onboot and nm_manager the way I described. I can take a look shortly. Udev is the program that manages that, and how I showed you is the proper way to configure it. The actual script is in a udev directory. I wouldn't recommend modifying the udev program itself as the changes you make will likely break with an upgrade.
    – BloodyEl
    Jun 3, 2016 at 18:27
0

On newer Linux systems, there is frequently this NetworkManager taking care of these files. There is a command line tool for it, but it is usually configured via a GUI available at the desktop of your choice.

Since RHEL 5 is really old, I would assume that you can/should use the Redhat configuration tool system-config-network. There are some master information files and some files (as the one you mention) that are generated by scripts. It is easiest to use this simple configuration tool.

0

I know you indicate it is disabled, but if NetworkManager is creating those files, there is a configuration option to tell it to stop.

The header in /etc/NetworkManager/NetworkManager.conf points you to a man page for the config file:

# Configuration file for NetworkManager.
#
# See "man 5 NetworkManager.conf" for details.

In the man page it tells you:

   no-auto-default
       Specify devices for which NetworkManager shouldn't create default
       wired connection (Auto eth0). By default, NetworkManager creates a
       temporary wired connection for any Ethernet device that is managed
       and doesn't have a connection configured. List a device in this
       option to inhibit creating the default connection for the device.
       May have the special value * to apply to all devices.

       When the default wired connection is deleted or saved to a new
       persistent connection by a plugin, the device is added to a list in
       the file /var/run/NetworkManager/no-auto-default.state to prevent
       creating the default connection for that device again.

       See the section called “Device List Format” for the syntax how to
       specify a device.

       Example:

           no-auto-default=00:22:68:5c:5d:c4,00:1e:65:ff:aa:ee
           no-auto-default=eth0,eth1
           no-auto-default=*

So if you "no-auto-default=*" to /etc/NetworkManager/NetworkManager.conf, it should hopefully stop creating those files if it's the source.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .