争怎路由网/路由器百科/内容

路由器做DHCP服务器设置命令

路由器百科2024-11-21 阅读

前面讲过了三层交换机如何配置DHCP,现在用路由器配置其实更简单

拓扑图如下:

其中172.16.0.0网段我还是采用/24的配置方式。因为我配置的大环境用不了太多IP地址

Router(config)#service dhcp//开启dhcp服务 Router(config)#ip dhcp pool sub//配置名为sub的地址池 Router(dhcp-config)#network 172.16.4.0 255.255.255.0//设置为/24的网段 Router(dhcp-config)#default-router 172.16.4.1 Router(dhcp-config)#dns-server 172.16.4.2 Router(config)#ip dhcp excluded-address 172.16.4.1 172.16.4.2 Router(config)#interface GigabitEthernet0/1 Router(config-if)#ip address 172.16.4.1 255.255.255.0//端口IP一定要注意为/24

配置结果:

顺便再做个NAT使其连接外部网络

自定义的地址池为:201.4.4.10-201.4.4.100

命令如下:

Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ip nat pool sub 201.4.4.10 201.4.4.100 netmask 255.255.255.0 Router(config)#ip nat inside source list 1 pool sub Router(config)#access-list 1 permit 172.16.4.0 255.255.255.0 Router(config)#int g 0/1 Router(config-if)#ip nat inside Router(config-if)#int g0/0 Router(config-if)#ip nat outside Router(config-if)#ebd. Router(config-if)#end Router#show ip nat statistics//查看nat配置 Total translations: 0 (0 static, 0 dynamic, 0 extended) Outside Interfaces: GigabitEthernet0/0 Inside Interfaces: GigabitEthernet0/1 Hits: 0 Misses: 1 Expired translations: 0 Dynamic mappings: -- Inside Source access-list 1 pool sub refCount 0 pool sub: netmask 255.255.255.0 start 201.4.4.10 end 201.4.4.100 type generic, total addresses 91 , allocated 0 (0%), misses 0 Router#

路由协议就选rip了

不要忘记配置静态路由!

测试如下:



……

相关阅读