Linux 禁用特定接口的网络管理器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5321380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:16:23  来源:igfitidea点击:

Disable network manager for a particular interface

linuxnetworkingconfiguration-filesconfigure

提问by Souvik

I would like to disable network manager service for particular interface(s). "/etc/init.d/NetworkManager stop" is not going to serve my purpose since will stop the service. Please let me know how to achieve this. Please suggest commands/code only - I am not interested in graphical configuration. If there is some rpm/patch available already please refer it to me. Can we configure network manager in such a way so that it will not detect any new network card plugged into the system?

我想禁用特定接口的网络管理器服务。“/etc/init.d/NetworkManager stop”不会达到我的目的,因为会停止服务。请让我知道如何实现这一目标。请仅建议命令/代码 - 我对图形配置不感兴趣。如果已经有一些 rpm/patch 可用,请将其参考给我。我们能否以这样的方式配置网络管理器,使其不会检测到任何插入系统的新网卡?

Thanks in advance,

提前致谢,

Souvik

苏维克

回答by Souvik

I realise this question is a bit old, but it came up when I was trying to Google the answer to this myself. What eventually worked for me was:

我意识到这个问题有点老了,但是当我自己尝试用谷歌搜索这个问题的答案时它出现了。最终对我有用的是:

  1. Add the interface to /etc/network/interfaces. For mine:
  1. 将接口添加到/etc/network/interfaces. 对于我的:
    iface eth1 inet static
        address 192.168.168.1
        netmask 255.255.255.0
        gateway 192.168.168.1
  1. Restart networking: sudo /etc/init.d/networking restart
  2. Restart Network Manager: sudo service network-manager restart
  1. 重启网络: sudo /etc/init.d/networking restart
  2. 重新启动网络管理器: sudo service network-manager restart

Network Manager should ignore any interfaces it finds in /etc/network/interfaces. At this point obviously you're on your own for managing this interface with ifconfigor something similar.

网络管理器应该忽略它在 中找到的任何接口/etc/network/interfaces。在这一点上,显然您需要自己管理这个界面ifconfig或类似的东西。

回答by bjesus

Put this in your NetworkManager.conf (usually at /etc/NetworkManager/):

把它放在你的 NetworkManager.conf(通常在 /etc/NetworkManager/)中:

[main]
plugins=keyfile

[keyfile]
unmanaged-devices=mac:xx:xx:xx:xx:xx:xx

of course, adjust the mac address to the device your want to ignore.

当然,将mac地址调整为您要忽略的设备。

回答by Oliver Hernandez

On my RHEL 6.5 system, I had to edit the configuration file for the particular adapter (/etc/sysconfig/network-scripts/ifcfg-eth0) and add the following line:

在我的 RHEL 6.5 系统上,我必须编辑特定适配器的配置文件 (/etc/sysconfig/network-scripts/ifcfg-eth0) 并添加以下行:

NM_CONTROLLED=no

NM_CONTROLLED=否

The 2nd part of your question, "Can we configure network manager in such a way so that it will not detect any new network card plugged into the system?", I think is handled in the /etc/NetworkManager/NetworkManager.conf file with the line:

您问题的第二部分,“我们能否以这样的方式配置网络管理器,使其不会检测到插入系统的任何新网卡?”,我认为是在 /etc/NetworkManager/NetworkManager.conf 文件中处理的该行:

no-auto-default=00:80:A4:0A:3C:20,

no-auto-default=00:80:A4:0A:3C:20,

Set this property of course to the value of the MAC address for your adapter. More info on this option can be read here.

当然,将此属性设置为适配器的 MAC 地址的值。可以在此处阅读有关此选项的更多信息。

回答by Derek Gorczynski

NetworkManager will notattempt to control a given interface if you set the interface to unmanagedusing the nmclicommand.

如果您将接口设置为使用该命令,NetworkManager 将不会尝试控制给定的接口。unmanagednmcli

nmcli dev set wlp2s0 managed no

You can verify the interface is no longer managed with the following:

您可以使用以下方法验证接口不再受管理:

nmcli dev status

Output example:

输出示例:

DEVICE             TYPE      STATE         CONNECTION      
wlp2s0             wifi      unmanaged     --