观天

Linux7建立DHCP服务器

Linux7建立DHCP服务器,为网络主机分配IP地址。以下是组网网络拓扑图:

建立顺序:

一、Linux安装 DHCP服务
命令:yum install -y dhcp
二、复制Linux系统自带的DHCP配置模板。
命令:cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example ./dhcpd.conf

三、配置DHCP服务的配置文件vi /etc/dhcp/dhcp.conf,添加了三个网段的配置。

命令:vi /etc/dhcp/dhcp.conf
添加:
subnet 10.10.10.0 netmask 255.255.255.0 {         /DHCP地址池
range 10.10.10.11 10.10.10.252;
option domain-name-servers 114.114.114.114;         /DNS地址
option domain-name "xiaolan";
option routers 10.10.10.254;                        /本网段网关地址
option broadcast-address 10.10.10.255;             /本网段广播地址
default-lease-time 600;                           
max-lease-time 7200;     
}
subnet 10.2.20.0 netmask 255.255.255.0 {
range 10.2.20.11 10.2.20.252;
option domain-name-servers 114.114.114.114;
option domain-name "xiaolan20";
option routers 10.2.20.254;
option broadcast-address 10.2.20.255;
default-lease-time 600;
max-lease-time 7200;
}
subnet 10.2.30.0 netmask 255.255.255.0 {
range 10.2.30.11 10.2.30.252;
option domain-name-servers 114.114.114.114;
option domain-name "xiaolan30";
option routers 10.2.30.254;
option broadcast-address 10.2.30.255;
default-lease-time 600;
max-lease-time 7200;
}

四、重启:systemctl restart dhcpd ,DHCP服务器状态查看 systemctl status dhcpd

五、配置交换机开启DHCP服务,开启DHCP中继,即可分发多网段IP。

交换机配置参考:

sys
#
sysname SW1
#
vlan batch 10 20 30
#
dhcp enable
#
vlan 10
description DHCP
#
interface Vlanif10
ip address 10.10.10.254 255.255.255.0
dhcp select relay
dhcp relay server-ip 10.10.10.10
#
interface Vlanif20
ip address 10.2.20.254 255.255.255.0
dhcp select relay
dhcp relay server-ip 10.10.10.10
#
interface Vlanif30
ip address 10.2.30.254 255.255.255.0
dhcp select relay
dhcp relay server-ip 10.10.10.10
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 10
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 20
#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 30

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

赞(8)
未经允许不得转载:观天 » Linux7建立DHCP服务器