DHCP端口设置命令剖析

网络 网络管理
文章中,我们针对DHCP端口的一些配置内容进行了讲解和介绍。希望本文所提供的代码以及命令能够给大家一些帮助。

在一些DHCP服务器的配置中,少不了端口的设置。这个也是对于路由器和交换机配置来说非常核心的问题了。用一台cisco 3560来做DHCP服务器,有时候要启多个DHCP来工作。那么我们应该怎么做呢。

首先我们要把交换端口关闭掉,换成L3的接口。配置上IP地址。再来设置DHCP地址池。我们要让端口f0/1上来的主机分配0网段的IP地址,让f0/2上来的主机分配1网段,那么,我们就应该配置好地址池后,在接口下用到ip help-address 来给客户端的查询指定一个服务地址。详细见配置。以下配置在真实3560上得到通过。

  1. Switch#sh run            首先我们看下运行中的配置清单  
  2. Switch#sh running-config   
  3. Building configuration...  
  4.  
  5. Current configuration : 1326 bytes  
  6. !  
  7. version 12.2  
  8. no service pad  
  9. service timestamps debug uptime  
  10. service timestamps log uptime  
  11. no service password-encryption  
  12. !  
  13. hostname Switch  
  14. !  
  15. !  
  16. no aaa new-model  
  17. system mtu routing 1500  
  18. ip subnet-zero  
  19. no ip domain-lookup  
  20. !  
  21. !  
  22. !  
  23. !  
  24. !  
  25. !  
  26. !  
  27. !           
  28. !           
  29. spanning-tree mode pvst  
  30. spanning-tree extend system-id  
  31. !           
  32. vlan internal allocation policy ascending  
  33. !           
  34. !           
  35. !           
  36. !           
  37. interface FastEthernet0/1  
  38. shutdown   
  39. !           
  40. interface FastEthernet0/2  
  41. !           
  42. interface FastEthernet0/3  
  43. !           
  44. interface FastEthernet0/4  
  45. !           
  46. interface FastEthernet0/5  
  47. !           
  48. interface FastEthernet0/6  
  49. !           
  50. interface FastEthernet0/7  
  51. !           
  52. interface FastEthernet0/8  
  53. !           
  54. interface FastEthernet0/9  
  55. !           
  56. interface FastEthernet0/10  
  57. !           
  58. interface FastEthernet0/11  
  59. !           
  60. interface FastEthernet0/12  
  61. !           
  62. interface FastEthernet0/13  
  63. !           
  64. interface FastEthernet0/14  
  65. !           
  66. interface FastEthernet0/15  
  67. !           
  68. interface FastEthernet0/16  
  69. !           
  70. interface FastEthernet0/17  
  71. !           
  72. interface FastEthernet0/18  
  73. !           
  74. interface FastEthernet0/19  
  75. !           
  76. interface FastEthernet0/20  
  77. !           
  78. interface FastEthernet0/21  
  79. !           
  80. interface FastEthernet0/22  
  81. !           
  82. interface FastEthernet0/23  
  83. no switchport  
  84. ip address 192.168.100.1 255.255.255.0  
  85. !           
  86. interface FastEthernet0/24  
  87. !           
  88. interface GigabitEthernet0/1  
  89. !           
  90. interface GigabitEthernet0/2  
  91. !           
  92. interface Vlan1  
  93. no ip address  
  94. !           
  95. ip classless  
  96. ip http server  
  97. ip http secure-server  
  98. !           
  99. !           
  100. !           
  101. control-plane  
  102. !           
  103. !           
  104. line con 0  
  105. line vty 0 4  
  106. login      
  107. line vty 5 15  
  108. login      
  109. !           
  110. end       

 
        #p#

 

  1. Switch#conf t  
  2. Switch(config)#int fa 0/1                                                                 进入F0/1  
  3. Switch(config-if)#no switchport                                                       关闭L2端口  
  4. Switch(config-if)#ip add 10.0.0.1 255.255.255.0                            配置IP地址  
  5. Switch(config-if)#no sh                                                                   打开端口  
  6. Switch(config-if)#exi  
  7. Switch(config)#int fa 0/2  
  8. Switch(config-if)#no sw  
  9. Switch(config-if)#no switchport   
  10. Switch(config-if)#no sh  
  11. Switch(config-if)#ip add 10.0.1.1 255.255.255.0  
  12. Switch(config-if)#no sh  
  13. Switch(config-if)#exi  
  14. Switch(config)#ip dhcp pool ccna                                                   设置DHCP组  
  15. Switch(dhcp-config)#network 10.0.0.0 255.255.255.0                   地址池  
  16. Switch(dhcp-config)#default-router 10.0.0.254                              缺省路由(网关)  
  17. Switch(dhcp-config)#dns-server 202.103.24.68                             DNS地址设置  
  18. Switch(dhcp-config)#lease 365                                                       地址租期  
  19. Switch(dhcp-config)#exi  
  20. Switch(config)#ip dhcp pool ccnp  
  21. Switch(dhcp-config)#network 10.0.1.0 255.255.255.0  
  22. Switch(dhcp-config)#default-router 10.0.1.254  
  23. Switch(dhcp-config)#dns-server 202.103.24.68  
  24. Switch(dhcp-config)#lease 365  
  25. Switch(dhcp-config)#exi  
  26. Switch(config)#ip dhcp excluded-address 10.0.0.1                          不参与分配的地址  
  27. Switch(config)#ip dhcp excluded-address 10.0.0.254  
  28. Switch(config)#ip dhcp excluded-address 10.0.1.254  
  29. Switch(config)#ip dhcp excluded-address 10.0.1.1   
  30. Switch(config)#exi  
  31. Switch(config)#int fa 0/1  
  32. Switch(config-if)#ip helper-address 10.0.0.1                          指定帮助地址,它将默认转发给8个UDP服务  
  33. Switch(config-if)#exi  
  34. Switch(config)#int fa 0/2  
  35. Switch(config-if)#ip helper-address 10.0.1.1  
  36. Switch(config-if)#exi  
  37. Switch#sh run  
  38. Switch#sh running-config   
  39. Building configuration... 

#p#

  1. Current configuration : 1864 bytes  
  2. !  
  3. version 12.2  
  4. no service pad  
  5. service timestamps debug uptime  
  6. service timestamps log uptime  
  7. no service password-encryption  
  8. !  
  9. hostname Switch  
  10. !  
  11. !  
  12. no aaa new-model  
  13. system mtu routing 1500  
  14. ip subnet-zero  
  15. no ip domain-lookup  
  16. ip dhcp excluded-address 10.0.0.1  
  17. ip dhcp excluded-address 10.0.0.254  
  18. ip dhcp excluded-address 10.0.1.254  
  19. ip dhcp excluded-address 10.0.1.1  
  20. !  
  21. ip dhcp pool ccna  
  22.    network 10.0.0.0 255.255.255.0  
  23.    default-router 10.0.0.254   
  24.    dns-server 202.103.24.68   
  25.    lease 365  
  26. !           
  27. ip dhcp pool ccnp  
  28.    network 10.0.1.0 255.255.255.0  
  29.    default-router 10.0.1.254   
  30.    dns-server 202.103.24.68   
  31.    lease 365  
  32. !           
  33. !           
  34. !           
  35. !           
  36. !           
  37. !           
  38. !           
  39. !           
  40. !           
  41. spanning-tree mode pvst  
  42. spanning-tree extend system-id  
  43. !           
  44. vlan internal allocation policy ascending  
  45. !           
  46. !           
  47. !           
  48. !           
  49. interface FastEthernet0/1  
  50. no switchport  
  51. ip address 10.0.0.1 255.255.255.0  
  52. ip helper-address 10.0.0.1  
  53. !           
  54. interface FastEthernet0/2  
  55. no switchport  
  56. ip address 10.0.1.1 255.255.255.0  
  57. ip helper-address 10.0.1.1  
  58. !           
  59. interface FastEthernet0/3  
  60. !           
  61. interface FastEthernet0/4  
  62. !           
  63. interface FastEthernet0/5  
  64. !           
  65. interface FastEthernet0/6  
  66. !           
  67. interface FastEthernet0/7  
  68. !           
  69. interface FastEthernet0/8  
  70. !           
  71. interface FastEthernet0/9  
  72. !           
  73. interface FastEthernet0/10  
  74. !           
  75. interface FastEthernet0/11  
  76. !           
  77. interface FastEthernet0/12  
  78. !           
  79. interface FastEthernet0/13  
  80. !           
  81. interface FastEthernet0/14  
  82. !           
  83. interface FastEthernet0/15  
  84. !           
  85. interface FastEthernet0/16  
  86. !           
  87. interface FastEthernet0/17  
  88. !           
  89. interface FastEthernet0/18  
  90. !           
  91. interface FastEthernet0/19  
  92. !           
  93. interface FastEthernet0/20  
  94. !           
  95. interface FastEthernet0/21  
  96. !           
  97. interface FastEthernet0/22  
  98. !           
  99. interface FastEthernet0/23  
  100. no switchport  
  101. ip address 192.168.100.1 255.255.255.0  
  102. !           
  103. interface FastEthernet0/24  
  104. !           
  105.        
  106. Switch#sh arp   
  107. Protocol Address          Age (min) Hardware Addr   Type   Interface  
  108. Internet 10.0.0.2                0   001a.4b58.42a9 ARPA   FastEthernet0/1  
  109. Internet 10.0.1.1                -   001e.4a0a.2042 ARPA   FastEthernet0/2  
  110. Internet 10.0.0.1                -   001e.4a0a.2041 ARPA   FastEthernet0/1  
  111. Internet 192.168.100.1           -   001e.4a0a.2043 ARPA   FastEthernet0/23 

根据上面的配置,现在我们只要连接到f0/1口上,那么客户端分配到的地址将是0网段的地址 ,如果连接到f 0/2口上,那么客户端将分配到1网段的地址。

help-address的说明:

help-address 缺省转发的8个udp服务:time37 , tacacs49 , dns53 , boot/dhcp服务器67 , boot/dhcp客户端68 , tftp69 , netbios名字服务137, netbios数据报服务138 
 

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

2010-09-26 14:46:51

DHCP端口设置

2010-09-29 15:28:44

DHCP端口

2010-08-30 17:40:49

DHCP端口

2010-07-27 15:24:44

2010-08-23 17:13:25

设置DHCP协议

2010-08-26 10:22:25

2010-07-20 15:28:34

2010-08-30 20:00:00

命令行DHCP

2010-08-25 21:03:38

命令行DHCP

2010-08-23 10:54:12

DHCP备份Linux DHCP

2010-08-26 10:45:59

DHCP端口

2010-09-06 13:50:01

PPPOEDHCP

2010-09-29 14:30:54

路由DHCP设置

2010-09-01 09:38:29

设置DHCP服务器

2010-08-26 16:16:17

DHCP服务器

2010-08-26 16:43:53

设置DHCP

2010-09-29 16:00:22

思科路由DHCP设置

2010-08-26 21:34:19

2010-09-27 11:53:01

DHCP Relay设

2010-01-06 16:05:10

交换机端口设置
点赞
收藏

51CTO技术栈公众号