8

I reckon there's a similar question on this site ( How to permanently disable a network interface? ), but the answers were mainly for Ubuntu and the methods described in there didn't help.

I'm trying to bring down a enp1s0f2 interface, but it keeps coming back on reboot.

I've tried the commands "ifconfig (interface) down", "ifdown (interface)", and editing /etc/network/interfaces to add the following lines:

"iface (interface) inet manual" and "iface (interface) inet6 manual"

Supposedly so that NetworkManager or whatever else is managing it, doesn't load it on startup, but to no avail.

How can I permanently disable this interface on Debian?

Is there a clean method that doesn't involve disabling all device systemctl services one by one? It would be a shame if at any point I needed the interface again that I had to remember all services involved and re-enable them again, plus, there must be a simpler straight method, right?

2 Answers 2

6

You can tell NetworkManager to ignore the interface, as documented in the keyfile section of NetworkManager.conf:

keyfile section

This section contains keyfile-plugin-specific options, and is normally only used when you are not using any other distro-specific plugin.

[...]

unmanaged-devices

Set devices that should be ignored by NetworkManager.

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

Example:

unmanaged-devices=interface-name:em4
unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4;interface-name:eth2

Add a file in /etc/NetworkManager/conf.d called for example local-ignore-enp1s0f2.conf with this additional content:

[keyfile]
unmanaged-devices=interface-name:enp1s0f2

You might still have to delete an entry it already created with something like:

nmcli connection show 

and once the name identified:

nmcli connection delete id 'some unwanted connection'
ip link set enp1s0f2 down

Then reload the configuration:

nmcli connection reload

or:

systemctl reload network-manager

If you want to check it worked without rebooting, here's a trick using a network namespace (which could also have been used instead in some script probably in udev to make the interface automatically "disappear"):

ip netns add hiddenplace
ip link set enp1s0f2 netns hiddenplace

Now remove the namespace which will bring back the interface and trigger any auto-detection:

ip netns delete hiddenplace
1
  • I tried this method but apparently something is raising it up at boot time, when I reboot it says "Raise network interfaces", then it enables it, I'm not sure if it has to do with ifupdown (it's set to not managed on /etc/network/interfaces) or if some startup script brings it up
    – The AFOH
    Aug 29, 2020 at 15:50
0

You can set both its IPv4 and IPv6 addresses to "Disabled" in NetworkManager which will essentially disable the interface.

Then there's this "Connect automatically with Priority" which can unchecked - which probably does the same.

You must log in to answer this question.

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