企业网络实验dhcp-snooping、ip source check,防非法dhcp服务器、自动获取ip(虚拟机充当DHCP服务器)、禁手动修改IP

文章目录

需求

  • DHCP服务器:vmware虚拟机(dhcp),IP:192.168.5.254 ,可分配192.168.5.X、192.168.10.X、192.168.11.X三个网段的IP
  • DHCP中继:华为三层交接机s5700,配置vlan 5、10、11,其中g 0/0/1为dhcp信任接口,g 0/0/10开启dhcp-snooping(防非法dhcp服务器)、ip source check(防非dhcp获取的IP,手动修改IP,数据报文丢弃处理)
  • 接入交接机当傻瓜交换机用,不作任何配置。
  • PC10:可自动不可手动IP
  • PC11:可自动可手动IP

相关配置

互通性配置

ssh 复制代码
vlan batch 5 10 to 11

int vlanif 5
ip address 192.168.5.254 24

int vlanif 10
ip address 192.168.10.254 24

int vlanif 11
ip address 192.168.11.254 24
ssh 复制代码
int g 0/0/1
port link-type access 
port default vlan 5

int g 0/0/10
port link-type access 
port default vlan 10

int g 0/0/11
port link-type access 
port default vlan 11

此时192.168.5.253、192.168.5.254、192.168.10.254、192.168.11.254,ping是互通的

配置vmware虚拟机(dhcp)分配IP服务

bash 复制代码
vim /etc/dhcp/dhcpd.conf

内容如下:

bash 复制代码
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
option domain-name "test.com";
option domain-name-servers 192.168.200.113, 192.168.200.114;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;


###网段声明   
subnet 192.168.5.0 netmask 255.255.255.0 {
  range   dynamic-bootp 192.168.5.51 192.168.5.199;  #ip地址池
  #option domain-name-servers ns1.internal.example.org;
  #option domain-name "internal.example.org";
  option routers 192.168.5.254; # 为客户端设定默认网关
  option broadcast-address 192.168.5.255; #为客户端设定广播地址
  #default-lease-time 600;
  #max-lease-time 7200;
}

###网段声明   
subnet 192.168.10.0 netmask 255.255.255.0 {
  range   dynamic-bootp 192.168.10.51 192.168.10.199;  #ip地址池
  #option domain-name-servers ns1.internal.example.org;
  #option domain-name "internal.example.org";
  option routers 192.168.10.254; # 为客户端设定默认网关
  option broadcast-address 192.168.10.255; #为客户端设定广播地址
  #default-lease-time 600;
  #max-lease-time 7200;
}

###网段声明   
subnet 192.168.11.0 netmask 255.255.255.0 {
  range   dynamic-bootp 192.168.11.51 192.168.11.199;  #ip地址池
  #option domain-name-servers ns1.internal.example.org;
  #option domain-name "internal.example.org";
  option routers 192.168.11.254; # 为客户端设定默认网关
  option broadcast-address 192.168.11.255; #为客户端设定广播地址
  #default-lease-time 600;
  #max-lease-time 7200;
}



host pc_deepin {                                #指定需要分配固定IP地址的客户机名称
  hardware ethernet 00:0C:29:25:D4:C6;   #指定网卡接口类型和MAC地址
  fixed-address 192.168.5.1;  #分配给客户端一个固定的地址
  server-name "deepin.test.com";#分配给客户端一个计算机名
}

配置dhcp relay(dhcp中继)

  • 开启开局dhcp relay
ssh 复制代码
int Vlanif5
dhcp select relay
dhcp relay server-ip 192.168.5.253
#
int Vlanif10
dhcp select relay
dhcp relay server-ip 192.168.5.253
#
int Vlanif11
dhcp select relay
dhcp relay server-ip 192.168.5.253

此时PC10、PC11均能获取到IP

配置dhcp-snooping(防非法dhcp服务器)

  • 开启开局dhcp snooping
ssh 复制代码
#
dhcp enable
#
dhcp snooping enable

-配置snooping

ssh 复制代码
int g 0/0/10
dhcp snooping enable
  • 设置信任接口
ssh 复制代码
int g 0/0/1
dhcp snooping trusted

配置ip source check(禁手动修改IP)

ssh 复制代码
int g 0/0/10
arp anti-attack check user-bind enable
ip source check user-bind enable
dhcp snooping check dhcp-chaddr enable
  • 检验:自动IP
ssh 复制代码
ipconfig /release
ipconfig /renew
ipconfig
  • 检验:手动IP

  • 查看DHCP中继user-bind
ssh 复制代码
dis dhcp snooping user-bind all

DHCP中继(核心交换机)配置文件

ssh 复制代码
#
sysname Huawei
#
vlan batch 5 10 to 11
#
cluster enable
ntdp enable
ndp enable
#
drop illegal-mac alarm
#
dhcp enable
#
dhcp snooping enable
#
diffserv domain default
#
drop-profile default
#
aaa
 authentication-scheme default
 authorization-scheme default
 accounting-scheme default
 domain default
 domain default_admin
 local-user admin password simple admin
 local-user admin service-type http
#
interface Vlanif1
#
interface Vlanif5
 ip address 192.168.5.254 255.255.255.0
 dhcp select relay
 dhcp relay server-ip 192.168.5.253
#
interface Vlanif10
 ip address 192.168.10.254 255.255.255.0
 dhcp select relay
 dhcp relay server-ip 192.168.5.253
#
interface Vlanif11
 ip address 192.168.11.254 255.255.255.0
 dhcp select relay
 dhcp relay server-ip 192.168.5.253
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 5
 dhcp snooping trusted
#
interface GigabitEthernet0/0/2
#
interface GigabitEthernet0/0/3
#
interface GigabitEthernet0/0/4
#
interface GigabitEthernet0/0/5
#
interface GigabitEthernet0/0/6
#
interface GigabitEthernet0/0/7
#
interface GigabitEthernet0/0/8
#
interface GigabitEthernet0/0/9
#
interface GigabitEthernet0/0/10
 port link-type access
 port default vlan 10
 arp anti-attack check user-bind enable
 ip source check user-bind enable
 dhcp snooping enable
 dhcp snooping check dhcp-chaddr enable
#
interface GigabitEthernet0/0/11
 port link-type access
 port default vlan 11
 dhcp snooping enable
#
interface GigabitEthernet0/0/12
#
interface GigabitEthernet0/0/13
#
interface GigabitEthernet0/0/14
#
interface GigabitEthernet0/0/15
#
interface GigabitEthernet0/0/16
#
interface GigabitEthernet0/0/17
#
interface GigabitEthernet0/0/18
#
interface GigabitEthernet0/0/19
#
interface GigabitEthernet0/0/20
#
interface GigabitEthernet0/0/21
#
interface GigabitEthernet0/0/22
#
interface GigabitEthernet0/0/23
#
interface GigabitEthernet0/0/24
#
interface NULL0
#
user-interface con 0
user-interface vty 0 4
#
return
相关推荐
正在走向自律20 分钟前
阿里云ESC服务器一次性全部迁移到另一个ESC
服务器·阿里云·云计算
gywl1 小时前
openEuler VM虚拟机操作(期末考试)
linux·服务器·网络·windows·http·centos
WTT00111 小时前
2024楚慧杯WP
大数据·运维·网络·安全·web安全·ctf
了一li2 小时前
Qt中的QProcess与Boost.Interprocess:实现多进程编程
服务器·数据库·qt
杨德杰2 小时前
QT网络(一):主机信息查询
网络·qt
日记跟新中2 小时前
Ubuntu20.04 修改root密码
linux·运维·服务器
唐小旭2 小时前
服务器建立-错误:pyenv环境建立后python版本不对
运维·服务器·python
明 庭2 小时前
Ubuntu下通过Docker部署NGINX服务器
服务器·ubuntu·docker
BUG 4042 小时前
Linux——Shell
linux·运维·服务器