Linux DHCP服务如何启动与停止

939
2025/3/28 6:32:41
栏目: 智能运维
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在Linux系统中,DHCP服务通常由isc-dhcp-server包提供。要启动和停止DHCP服务,请按照以下步骤操作:

  1. 打开终端。

  2. 首先,确保已经安装了isc-dhcp-server包。如果没有安装,请使用以下命令安装:

    对于基于Debian的系统(如Ubuntu):

    sudo apt-get update
    sudo apt-get install isc-dhcp-server
    

    对于基于RPM的系统(如CentOS、Fedora):

    sudo yum install dhcp
    
  3. 启动DHCP服务:

    对于基于Debian的系统:

    sudo systemctl start isc-dhcp-server
    

    对于基于RPM的系统:

    sudo systemctl start dhcpd
    
  4. 要检查DHCP服务的状态,请运行以下命令:

    对于基于Debian的系统:

    sudo systemctl status isc-dhcp-server
    

    对于基于RPM的系统:

    sudo systemctl status dhcpd
    
  5. 如果需要停止DHCP服务,请运行以下命令:

    对于基于Debian的系统:

    sudo systemctl stop isc-dhcp-server
    

    对于基于RPM的系统:

    sudo systemctl stop dhcpd
    
  6. 若要使DHCP服务在系统启动时自动运行,请运行以下命令:

    对于基于Debian的系统:

    sudo systemctl enable isc-dhcp-server
    

    对于基于RPM的系统:

    sudo systemctl enable dhcpd
    

请注意,根据您的Linux发行版和配置,DHCP服务可能使用不同的名称(如dhcp、dhcpd或isc-dhcp-server)。请根据实际情况调整上述命令。

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: linux ll命令有啥注意事项