代码示例:IP dhcp snooping配置

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

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

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

  1. 如下:(无用的部分已经删除了)  
  2. clock timezone WST 8  
  3. switch 1 provision ws-c3750g-48ts  
  4. system mtu routing 1500  
  5. ip subnet-zero  
  6. ip dhcp excluded-address 192.168.1.1 (保留地址)  
  7. !  
  8. ip dhcp pool test                            (启动DHCP)  
  9. network 192.168.1.0 255.255.255.0  
  10. default-router 192.168.1.1   
  11. dns-server 192.168.1.1   
  12. !  
  13. ip dhcp snooping vlan 1                (指定DHCP snooping防护的vlan)  
  14. ip dhcp snooping information option allow-untrusted  
  15. ip dhcp snooping database flash:snooping   (指定数据库路径)   
  16. ip dhcp snooping                      (启动DHCP snooping)  
  17. !  
  18. !  
  19. interface GigabitEthernet1/0/1  
  20. !  
  21. interface GigabitEthernet1/0/31 (正常的端口)  
  22. switchport mode access  
  23. spanning-tree portfast  
  24. !  
  25. interface GigabitEthernet1/0/32  
  26. !  
  27. interface GigabitEthernet1/0/42  
  28. !  
  29. interface GigabitEthernet1/0/43   (启用IP DHCP snooping端口)  
  30. switchport mode access  
  31. switchport port-security  
  32. spanning-tree portfast  
  33. ip verify source   

             

(启用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. interface GigabitEthernet1/0/44  
  3. !  
  4. interface GigabitEthernet1/0/45  
  5. switchport mode access  
  6. switchport port-security  
  7. switchport port-security violation restrict  
  8. spanning-tree portfast  
  9. ip verify source port-security      
  10. (启用后此端口无法DHCP注册地址,分析原因由于port-security的安全限制无法注册MAC)  
  11. (ip verify source port-security是配合启动IP soure binding使用  
  12. ip source binding 001b.a111.5e11 vlan 1 192.168.1.200 interface Gi1/0/45,注意ip source binding和动态DHCP不能同时用)  
  13. !  
  14. interface GigabitEthernet1/0/46  
  15. !   

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

  1. clock timezone WST 8  
  2. switch 1 provision ws-c3750g-48ts  
  3. system mtu routing 1500  
  4. ip subnet-zero  
  5. !  
  6. ip dhcp snooping vlan 1                (指定DHCP snooping防护的vlan)  
  7. ip dhcp snooping information option allow-untrusted  
  8. ip dhcp snooping database flash:snooping   (指定数据库路径)  
  9. ip dhcp snooping database write-delay 15   
  10. ip dhcp snooping                      (启动DHCP snooping)  
  11. !  
  12. !  
  13. !  
  14. interface GigabitEthernet1/0/45   (启动IP Source Guard的端口)  
  15. switchport mode access  
  16. switchport port-security  
  17. switchport port-security violation restrict  
  18. spanning-tree portfast  
  19. ip verify source port-security      
  20. (ip verify source port-security是配合启动IP soure binding使用  
  21. ip source binding 000A.E439.5F55 vlan 1 192.168.1.200 interface Gi1/0/45,说明ip source binding和动态DHCP不能同时用)  
  22. !  
  23. !  
  24. interface Vlan1  
  25. ip address 192.168.1.1 255.255.255.0  
  26. !  
  27. ip classless  
  28. ip http server  
  29. ip http secure-server  
  30. !  
  31. !  
  32. ip source binding 000A.E439.5F55 vlan 1 192.168.1.200 interface Gi1/0/45  
  33. !  
  34. control-plane  
  35. !  
  36. !  
  37.  
  38. 注意使用如下命令查看工作状态:  
  39. Switch#sh ip ver source               
  40. Switch#sh ip dhcp binding   
  41. Switch#sh ip dhcp snooping binding  

#p#3、启动dai

  1. ip subnet-zero  
  2. ip dhcp excluded-address 192.168.1.1  
  3. !  
  4. ip dhcp pool test  
  5. network 192.168.1.0 255.255.255.0  
  6. default-router 192.168.1.1   
  7. dns-server 192.168.1.1   
  8. lease infinite  
  9. !  
  10. ip dhcp snooping vlan 1                             (需要DHCP为基础)  
  11. ip dhcp snooping information option allow-untrusted  
  12. ip dhcp snooping database flash:snooping(指定snooping 数据保存位置)  
  13. ip dhcp snooping                                   (启动DHCP snooping)  
  14. ip arp inspection vlan 1                         (启动DAI)  
  15. ip arp inspection validate src-mac dst-mac ip    (检测项目)  
  16. !  
  17. !  
  18. !  
  19. interface GigabitEthernet1/0/31  
  20. switchport mode access  
  21. ip arp inspection trust          (如果设置trust可以改IP,设置untrust不可以改IP,因为DAI检测)  
  22. spanning-tree portfast  
  23. !  
  24. interface GigabitEthernet1/0/32  
  25. !  
  26. nterface GigabitEthernet1/0/44  
  27. !  
  28. interface GigabitEthernet1/0/45  
  29. switchport mode access  
  30. switchport port-security  
  31. switchport port-security violation restrict  
  32. spanning-tree portfast  
  33. ip verify source port-security  
  34. !  
  35. !  
  36. Switch#sh ip arp inspection  

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

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

  1. system mtu routing 1500  
  2. ip subnet-zero  
  3. ip dhcp excluded-address 192.168.1.1  
  4. !  
  5. ip dhcp pool test  
  6. host 192.168.1.18 255.255.255.0 (分给用户的IP)  
  7. client-identifier 0101.0bf5.395e.55(用户端mac)  
  8. client-name test  
  9. !  
  10. ip dhcp pool go  
  11. network 192.168.1.0 255.255.255.0 (启动网内DHCP)  
  12. !  
  13.  
  14. Switch#sh ip dhcp binding   
  15. IP address    Client-ID/                Lease expiration        Type  
  16.                   Hardware address  
  17. 192.168.1.18     0101.0bf5.395e.55    Infinite             Manual 

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

责任编辑:佟健 来源: hi.baidu.com
相关推荐

2010-09-03 11:21:57

2010-08-31 10:25:31

2010-09-26 14:52:22

DHCP Snoopi

2010-09-01 09:31:15

2010-08-31 17:01:31

dhcp snoopi

2010-09-27 10:40:21

DHCP Snoopi

2010-09-02 14:39:34

2010-09-27 12:42:31

静态IP dhcp s

2010-08-30 17:27:43

DHCP Snoopi

2010-09-01 15:32:02

DHCP Snoopi

2011-03-09 15:01:30

DHCP-snoopiDHCP

2010-08-31 10:17:14

2010-09-27 12:37:55

3750配置DHCP

2010-09-01 09:26:08

2010-09-01 15:42:39

DHCP SnoopiARP

2010-08-31 16:57:13

DHCP SNOOPI

2010-09-01 16:11:46

显示DHCP snoo

2010-08-30 09:15:37

DHCP Snoopi

2010-09-06 14:46:43

2010-09-01 16:03:51

DHCP Snoopi
点赞
收藏

51CTO技术栈公众号