DHCP 安裝

DHCP

[TOC]linux

CentOS7

安裝

sudo yum install -y dhcp

爲本機設置靜態IP
/etc/sysconfig/network-scripts/ifcfg-enp0s31f6bash

# Generated by dracut initrd
NAME="enp0s31f6"
DEVICE="enp0s31f6"
ONBOOT=yes
NETBOOT=yes
UUID="9133cbd4-e29f-4548-8d42-d967a9e87e6a"
IPV6INIT=yes
BOOTPROTO=static
TYPE=Ethernet

IPADDR=192.168.1.100
PREFIX=23
GATEWAY=192.168.1.1
DNS1=10.248.2.5

重啓網絡服務器

sudo systemctl restart network.service

修改配置文件

/etc/dhcp/dhcpd.conf網絡

option domain-name "myDHCP"                 # dhcp的主機名
option domain-name-servers 114.114.114.114; # DNS服務器

subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.101 192.168.1.254;
    option routers 192.168.1.1; 
    default-lease-time 600;
    max-lease-time 7200;
}

host Client_C {  #有一個主機,叫Client_C
    hardware ethernet 08:00:27:5e:04:27; # MAC地址是08:...:27的網卡
    fixed-address 192.168.1.123;         # 分配給它192.168.1.123的IP
}

range 192.168.1.101 192.168.1.254: 分配給客戶機的IP從192.168.100.100開始到192.168.100.254
option routers 192.168.1.1: 設置網關
default-lease-time 600: 默認租約時間
max-lease-time 7200: 最大租約時間dom

開機啓動

sudo systemctl enable dhcpd.service
sudo systemctl start dhcpd.service

Ubuntu 14.04

爲本機設置靜態IP
/etc/network/interfaceside

# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 10.248.2.5

重啓網絡oop

sudo /etc/init.d/networking restart

安裝

sudo apt-get install -y isc-dhcp-Server

修改配置文件

修改 /etc/default/dhcp-serverrest

INTERFACES="eth0"

INTERFACES="eth0" 若是有多塊網卡 指定從 eth0 獲取code

修改 /etc/dhcp/dhcpd.confrouter

default-lease-time 600;
max-lease-time 7200;
subnet 192.168.1.1 netmask 255.255.255.0 {
range 192.168.1.101 192.168.1.254;
option subnet-mask 255.255.255.0;
option routers 192.168.1.100;
option broadcast-address 192.168.1.255;
filename "pxelinux.0";
next-Server 192.168.1.100;
}

filename "pxelinux.0";next-Server 192.168.1.100; 會去讀取下一個server的 pxelinux.0 程序

啓動 DHCP service.

sudo /etc/init.d/isc-dhcp-server start
相關文章
相關標籤/搜索