How to disable NetworkManager in RHEL5-6-7

本文详细介绍了如何在Red Hat Enterprise Linux (RHEL) 5、6和7中禁用NetworkManager服务,并确保其在重启后不再启动。此外,还提供了完全禁用NetworkManager并避免错误消息的步骤,如Connection activation failed。文章涵盖了编辑配置文件以防止NetworkManager接管接口控制的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

How to disable NetworkManager in RHEL?.

环境

  • Red Hat Enterprise Linux (RHEL) 5.
  • Red Hat Enterprise Linux (RHEL) 6.
  • Red Hat Enterprise Linux (RHEL) 7.
  • NetworkManager service.

问题

  • Disabling NetworkManager

    • What steps are needed to disable the NetworkManager service?
    • What is needed to ensure it does not start again on a subsequent reboot?
  • Disabled NetworkManager but still seeing errors (need to fully disable)

    • Trouble configuring networking with NetworkManager and need to disable.
    • Disabled NetworkManager but still seeing errors about it and "Connection activation failed"

决议

FOR RHEL5 and RHEL6.

Disabling NetworkManager.

The steps below will disable network manager and allow the interface to be managed by the network service instead.

  • Stop the NetworkManager service:

    Raw

    # service NetworkManager stop
    
  • Disable it permanently so that the NetworkManager service will not be started on next boot:

    Raw

    # chkconfig NetworkManager off
    
  • Confirm if the NetworkManager service has been disabled:

    Raw

    # chkconfig --list|grep NetworkManager
    
  • Add below parameter in /etc/sysconfig/network-scripts/ifcfg-ethX to ensure NetworkManagerdoes not take control of the interface in case if it is accidentally activated.

    Raw

    NM_CONTROLLED="no"
    

    Note: Be sure to change the NM_CONTROLLED="yes" to "no" or the network service may complain about "Connection activation failed" when it cannot find an interface to start.

Switching to the "network" service

Once NetworkManager is disabled, the interface can be configured for use with the network service.

  • Set the correct IP address by editing the file: /etc/sysconfig/network-scripts/ifcfg-eth0

    Raw

    IPADDR=......  
    NETMASK=.....  
    GATEWAY=.....  
    ONBOOT=yes  
    BOOPROTO=static
    NM_CONTROLLED=no
    
  • Set the DNS servers to be used by editing the file : /etc/resolv.conf

    Raw

    nameserver 10.x.x.1
    nameserver I0.x.x.2
    
  • Restart the network service

    Raw

    # chkconfig network on
    # service network restart
    

FOR RHEL7

Disabling NetworkManager.

  • Stop the NetworkManager service:

    Raw

    # systemctl stop NetworkManager
    
  • To disable the service permanently:

    Raw

    # systemctl disable NetworkManager
    
  • Add below parameter in /etc/sysconfig/network-scripts/ifcfg-enXXX to ensure NetworkManagerdoes not take control of the interface in case if it is accidentally activated.

    Raw

    NM_CONTROLLED="no"
    

Switching to the "network" service

Once NetworkManager is disabled, the interface can be configured for use with the network service.

  • Set the correct IP address by editing the file: /etc/sysconfig/network-scripts/ifcfg-enXXX

    Raw

    IPADDR=......  
    NETMASK=.....  
    GATEWAY=.....  
    ONBOOT=yes  
    BOOPROTO=static
    NM_CONTROLLED=no
    
  • Restart the network service

    Raw

    # systemctl restart network.service
    

根源

  • The NetworkManager service may not be needed for server environments as it may override changes made to network configuration files, which may be undesirable.

  • If the NetworkManager services is not needed or not working as expected, then the network service can be used instead.

诊断步骤

  • The NetworkManager service seems to be taking over the ifcfg script files and changing them to incorrect information.

  • Check on if the NetworkManager service is enabled or running to see if it should be disabled:

    Raw

    # chkconfig --list | grep NetworkManager
    # service NetworkManager status
    
  • If NetworkManager is disabled, but when starting the network service there are errors and messages regarding:

    • NetworkManager
    • "Connection activation failed"
  • Check to be sure that at least one working ifcfg-ethX file in /etc/sysconfig/network-scripts does not contain "NM_CONTROLED=yes" .

<think>好的,我现在需要帮助用户解决NetworkManager-wait-online.service启动失败的问题。首先,用户提到了TNS相关的错误,但根据他们的提问,实际的问题是关于NetworkManager-wait-online.service的。我需要先确认这两个问题是否有直接关联,或者用户可能混淆了不同的错误信息。 首先,TNS错误通常与Oracle数据库的网络配置有关,如监听器问题。而NetworkManager-wait-online.service属于系统网络管理服务,负责等待网络连接就绪。这两个问题可能不相关,但用户可能在同一个系统中遇到多个网络问题。不过根据用户最后的提问,他们更关注的是解决NetworkManager-wait-online.service的启动失败,所以应聚焦于此。 接下来,我需要回忆关于systemd服务管理的知识。NetworkManager-wait-online.service的作用是在系统启动时等待网络连接完全建立,通常由NetworkManager管理。如果该服务启动失败,可能导致其他依赖网络的服务无法正常启动。 可能的原因包括: 1. 网络配置错误,导致NetworkManager无法正确获取IP地址或连接网络。 2. 服务超时,系统在等待网络就绪时超时。 3. NetworkManager本身的问题,如未正确安装或配置。 4. 系统启动时的其他依赖项问题。 解决方案方面,首先应检查服务的状态和日志,使用systemctl status命令查看详细错误信息。用户可能需要运行sudo systemctl status NetworkManager-wait-online.service来获取状态。此外,查看日志可以使用journalctl -u NetworkManager-wait-online.service --since today。 如果发现超时问题,可能需要调整服务的等待时间。这可以通过创建override.conf文件来修改服务的超时设置,例如将TimeoutStartSec延长。 另外,如果用户不需要等待网络就绪,可以考虑禁用该服务,但需注意可能影响依赖它的其他服务。禁用命令是sudo systemctl disable NetworkManager-wait-online.service。 同时,检查网络配置是否正确,比如DHCP是否启用,网卡配置是否有误。如果有静态IP配置,需要确认设置是否正确。重启NetworkManager服务也可能有帮助:sudo systemctl restart NetworkManager。 此外,用户提到的Oracle TNS错误可能与网络繁忙有关,引用中的建议是增加dispatchers和shared servers,这可能与数据库配置相关,但如果是独立的网络问题,可能需要检查网络带宽或连接稳定性。 需要确保用户分清楚这两个问题的关联性。如果用户同时遇到数据库连接问题和NetworkManager服务问题,可能需要分别处理。但根据用户的问题,重点在后者。 总结处理步骤: 1. 检查服务状态和日志。 2. 调整服务超时设置。 3. 检查网络配置。 4. 重启相关服务。 5. 必要时禁用服务或排除其他问题。 在回答时,需要逐步引导用户执行这些步骤,并解释每个步骤的目的。同时,提醒用户备份配置文件,避免误操作。最后,生成相关问题以帮助用户深入理解可能的原因和解决方案。</think>### NetworkManager-wait-online.service启动失败解决方案 #### 1. 查看服务状态与日志 首先通过以下命令查看服务状态和详细日志: ```bash sudo systemctl status NetworkManager-wait-online.service journalctl -u NetworkManager-wait-online.service --since today ``` 日志中可能显示超时、网络接口配置错误或依赖服务未启动等问题[^1]。 #### 2. 延长服务超时时间 如果日志显示超时错误(TimeoutStartSec),可修改服务配置: ```bash sudo systemctl edit NetworkManager-wait-online.service ``` 在编辑器中添加以下内容: ```ini [Service] TimeoutStartSec=300 # 将超时时间延长至5分钟 ``` #### 3. 检查网络配置 - 确认网卡配置正确(如`/etc/network/interfaces`或`/etc/sysconfig/network-scripts/`下的配置文件) - 检查DHCP是否正常分配IP地址: ```bash ip addr show dhclient -v ``` - 如果使用静态IP,需确保网关和DNS配置有效 #### 4. 重启相关服务 ```bash sudo systemctl restart NetworkManager sudo systemctl daemon-reload ``` #### 5. 禁用服务(可选) 如果不需要等待网络就绪: ```bash sudo systemctl disable NetworkManager-wait-online.service ``` 注意:可能影响依赖网络就绪状态的服务(如Docker、NFS等) #### 6. 排查网络硬件问题 - 检查网线/无线连接状态 - 测试网络接口: ```bash ethtool <网卡名称> ping -c4 8.8.8.8 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值