实验题·DHCP中继---Linux

实验题·DHCP中继

实验环境

image-20200706192525331

需求分析

Cloud1 使用虚拟机CentOS 7.6 来做DHCP中继

实验步骤

设置二层交换机sw2

vlan batch 10 20 100 #创建vlan

interface Ethernet0/0/1 #进接口

port link-type access #配access口

port default vlan 10 

interface Ethernet0/0/2

port link-type access

port default vlan 20

interface Ethernet0/0/3

port link-type access

port default vlan 100

interface GigabitEthernet0/0/1

port link-type trunk

port trunk allow-pass vlan all 

设置三层交换机sw1

vlan batch 10 20 100 #创建vlan

dhcp enable #开启dhcp服务

interface Vlanif10 #进接口

ip address 192.168.10.1 255.255.255.0 #配置IP地址

dhcp select relay #dhcp中继

dhcp relay server-ip 192.168.100.100 #去IP地址去获取

interface Vlanif20

ip address 192.168.20.1 255.255.255.0

dhcp select relay

dhcp relay server-ip 192.168.100.100

interface Vlanif100

ip address 192.168.100.1 255.255.255.0

dhcp select relay

dhcp relay server-ip 192.168.100.100

设置CentOS 7.6 DHCP中继服务

[root@localhost ~]# setenforce 0 #关闭核心防护

[root@localhost ~]# systemctl stop firewalld #关闭防火墙

[root@localhost ~]# yum -y install dhcp* #安装dhcp

[root@localhost ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

[root@localhost ~]# vi /etc/dhcp/dhcpd.conf

......

option domain-name "zhaobin";
option domain-name-servers 8.8.8.8;

......

subnet 192.168.10.0 netmask 255.255.255.0 {
  range 192.168.10.111 192.168.10.222;
  option routers 192.168.10.1;
}
subnet 192.168.20.0 netmask 255.255.255.0 {
  range 192.168.20.111 192.168.20.222;
  option routers 192.168.20.1;
}
subnet 192.168.100.0 netmask 255.255.255.0 {
  range 192.168.100.111 192.168.100.222;
  option routers 192.168.100.1;
}

......

[root@localhost ~]# systemctl start dhcpd

去华为模拟器里面在PC1、PC2去获取IP地址

image-20200706193853775

猜你喜欢

转载自blog.csdn.net/weixin_47153668/article/details/107166261