如何在RHEL7中永久禁用NIC接口?"ifconfig -a“禁用后不应该显示接口?
有什么想法吗?
发布于 2018-03-11 19:37:29
这可以通过简单的缺乏配置来实现。如何完成这一任务将取决于您是使用NetworkManager还是传统的ifupdown。您想要的只是在NIC上没有IP地址,而您可以通过不提供IP地址来实现这一点。我将给出一个传统网络的解决方案,因为我对NetworkManager有自己的看法。
每个网卡的配置都存储在/etc/sysconfig/network-scripts/中,文件名为ifcfg-eth0。这些是您将逐行配置选项放在其中的文件。下面是一个NIC的例子,它不会尝试通过DHCP获得IP,或者通过"address=“字段静态地分配给它一个IP (没有列出,因为我们没有给它地址)
在进行这些修改之前,您将希望使用现有的配置来降低NIC。这可以通过ifdown eth0实现。我假设您想要的NIC是eth0,但是您还没有指定要禁用哪一个。名字可以有多种形式,所以要根据口味来调整。
DEVICE="eth0"
BOOTPROTO=none # note here that "none" will disable DHCP
NM_CONTROLLED="no" #This prevents NetworkManager from controlling this interface, honoring only the config elements in this file
PERSISTENT_DHCLIENT=1 #Irrelevant in the absence of DHCP
ONBOOT="yes" # You could change this to "no" to prevent the interface from coming up even at layer 2
TYPE=Ethernet
DEFROUTE=yes #Irrelevant in the absence of DHCP
PEERDNS=yes #Irrelevant in the absence of DHCP
PEERROUTES=yes #Irrelevant in the absence of DHCP
IPV4_FAILURE_FATAL=yes #Irrelevant if you're not even giving it an IPv4 address
IPV6INIT=no # Change this to "no" to prevent from getting an IPv6 address
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME="eth0"在完成该配置之后,您可以发出ifup eth0来查看您的配置是否实现了您希望的配置。
https://serverfault.com/questions/901103
复制相似问题