下面我们主要讲解了IP dhcp snooping的内容。包括:3750配置DHCP服务,配置DHCP snooping、静态IP dhcp snooping和IP Source Guard、启动dai、DHCP设置,分配固定IP

前面的文章中我们也讲解过dhcp snooping的有关知识,对于它的理解,配置以及相关的调制,应用我们都介绍过了。这里我们再来对IP dhcp snooping的具体配置以及案例分析进行一下介绍,希望对大家能够有所帮助。

代码示例:IP dhcp snooping配置(dhcp snooping配置实例)  IP snooping 第1张

1、3750配置DHCP服务,配置DHCP snooping

  1. 如下:(无用的部分已经删除了)
  2. clocktimezoneWST8
  3. switch1provisionws-c3750g-48ts
  4. systemmturouting1500
  5. ipsubnet-zero
  6. ipdhcpexcluded-address192.168.1.1(保留地址)
  7. !
  8. ipdhcppooltest(启动DHCP)
  9. network192.168.1.0255.255.255.0
  10. default-router192.168.1.1
  11. dns-server192.168.1.1
  12. !
  13. ipdhcpsnoopingvlan1(指定DHCPsnooping防护的vlan)
  14. ipdhcpsnoopinginformationoptionallow-untrusted
  15. ipdhcpsnoopingdatabaseflash:snooping(指定数据库路径)
  16. ipdhcpsnooping(启动DHCPsnooping)
  17. !
  18. !
  19. interfaceGigabitEthernet1/0/1
  20. !
  21. interfaceGigabitEthernet1/0/31(正常的端口)
  22. switchportmodeaccess
  23. spanning-treeportfast
  24. !
  25. interfaceGigabitEthernet1/0/32
  26. !
  27. interfaceGigabitEthernet1/0/42
  28. !
  29. interfaceGigabitEthernet1/0/43(启用IPDHCPsnooping端口)
  30. switchportmodeaccess
  31. switchportport-security
  32. spanning-treeportfast
  33. ipverifysource

(启用IP地址效验,此端口用户不能自己设置地址,只能通过DHCP获得,但没有mac层安全控制。
测试发现,假如g1/0/43口的用户分得地址=192.168.1.2,g1/0/42用户故意修改IP为192.168.1.2,也会影响 g1/0/43的用户,虽然g1/0/42修改IP不能访问网络,但g1/0/43会提示IP冲突,所以必须结合DAI才能保护mac层)

  1. !
  2. interfaceGigabitEthernet1/0/44
  3. !
  4. interfaceGigabitEthernet1/0/45
  5. switchportmodeaccess
  6. switchportport-security
  7. switchportport-securityviolationrestrict
  8. spanning-treeportfast
  9. ipverifysourceport-security
  10. (启用后此端口无法DHCP注册地址,分析原因由于port-security的安全限制无法注册MAC)
  11. (ipverifysourceport-security是配合启动IPsourebinding使用
  12. ipsourcebinding001b.a111.5e11vlan1192.168.1.200interfaceGi1/0/45,注意ipsourcebinding和动态DHCP不能同时用)
  13. !
  14. interfaceGigabitEthernet1/0/46
  15. !

#p#2、静态IP dhcp snooping和IP Source Guard

  1. clocktimezoneWST8
  2. switch1provisionws-c3750g-48ts
  3. systemmturouting1500
  4. ipsubnet-zero
  5. !
  6. ipdhcpsnoopingvlan1(指定DHCPsnooping防护的vlan)
  7. ipdhcpsnoopinginformationoptionallow-untrusted
  8. ipdhcpsnoopingdatabaseflash:snooping(指定数据库路径)
  9. ipdhcpsnoopingdatabasewrite-delay15
  10. ipdhcpsnooping(启动DHCPsnooping)
  11. !
  12. !
  13. !
  14. interfaceGigabitEthernet1/0/45(启动IPSourceGuard的端口)
  15. switchportmodeaccess
  16. switchportport-security
  17. switchportport-securityviolationrestrict
  18. spanning-treeportfast
  19. ipverifysourceport-security
  20. (ipverifysourceport-security是配合启动IPsourebinding使用
  21. ipsourcebinding000A.E439.5F55vlan1192.168.1.200interfaceGi1/0/45,说明ipsourcebinding和动态DHCP不能同时用)
  22. !
  23. !
  24. interfaceVlan1
  25. ipaddress192.168.1.1255.255.255.0
  26. !
  27. ipclassless
  28. iphttpserver
  29. iphttpsecure-server
  30. !
  31. !
  32. ipsourcebinding000A.E439.5F55vlan1192.168.1.200interfaceGi1/0/45
  33. !
  34. control-plane
  35. !
  36. !
  37. 注意使用如下命令查看工作状态:
  38. Switch#shipversource
  39. Switch#shipdhcpbinding
  40. Switch#shipdhcpsnoopingbinding

#p#3、启动dai

  1. ipsubnet-zero
  2. ipdhcpexcluded-address192.168.1.1
  3. !
  4. ipdhcppooltest
  5. network192.168.1.0255.255.255.0
  6. default-router192.168.1.1
  7. dns-server192.168.1.1
  8. leaseinfinite
  9. !
  10. ipdhcpsnoopingvlan1(需要DHCP为基础)
  11. ipdhcpsnoopinginformationoptionallow-untrusted
  12. ipdhcpsnoopingdatabaseflash:snooping(指定snooping数据保存位置)
  13. ipdhcpsnooping(启动DHCPsnooping)
  14. iparpinspectionvlan1(启动DAI)
  15. iparpinspectionvalidatesrc-macdst-macip(检测项目)
  16. !
  17. !
  18. !
  19. interfaceGigabitEthernet1/0/31
  20. switchportmodeaccess
  21. iparpinspectiontrust(如果设置trust可以改IP,设置untrust不可以改IP,因为DAI检测)
  22. spanning-treeportfast
  23. !
  24. interfaceGigabitEthernet1/0/32
  25. !
  26. nterfaceGigabitEthernet1/0/44
  27. !
  28. interfaceGigabitEthernet1/0/45
  29. switchportmodeaccess
  30. switchportport-security
  31. switchportport-securityviolationrestrict
  32. spanning-treeportfast
  33. ipverifysourceport-security
  34. !
  35. !
  36. Switch#shiparpinspection

#p#4、DHCP设置,分配固定IP

有时我们需要控制IP分配,可以使用下面方法!

  1. systemmturouting1500
  2. ipsubnet-zero
  3. ipdhcpexcluded-address192.168.1.1
  4. !
  5. ipdhcppooltest
  6. host192.168.1.18255.255.255.0(分给用户的IP)
  7. client-identifier0101.0bf5.395e.55(用户端mac)
  8. client-nametest
  9. !
  10. ipdhcppoolgo
  11. network192.168.1.0255.255.255.0(启动网内DHCP)
  12. !
  13. Switch#shipdhcpbinding
  14. IPaddressClient-ID/LeaseexpirationType
  15. Hardwareaddress
  16. 192.168.1.180101.0bf5.395e.55InfiniteManual

时间仓促,没能进行很好的测试,希望大家能够讨论,给与指正!

转载请说明出处
知优网 » 代码示例:IP dhcp snooping配置(dhcp snooping配置实例)

发表评论

您需要后才能发表评论