路由器(Router)是连接两个或多个网络的硬件设备,在网络间起网关的作用,是读取每一个数据包中的地址然后决定如何传送的专用智能性的网络设备,路由器最主要的功能为实现信息的转送。 使用路由器作DHCP服务器 一个大中型校园网络中,有一台路由器,1000台终端设备,用户的计算机通过以太网交换机连接到路由器上,通过路由器访问其他网络,这些设备手动分配IP地址工作很繁琐,可以通路由器给PC设备自动分配IP地址。 下面演示使用DHCP中继来给电脑终端自动分配IP地址的配置方法,DHCP中继是用于在DHCP服务器与电脑终端之间转发DHCP报文,主要用于DHCP服务器与电脑终端不在同一个网段时。 路由器R1配置 <Huawei>system-view <Huawei> sysname R1 1-启用DHCP服务 [R1]dhcp enable 2-端口配置(配置IP,作为管理IP地址) [R1]interface GigabitEthernet 0/0/0 [R1-GigabitEthernet0/0/0]ip address 192.168.99.1 24 [R1-GigabitEthernet0/0/0]q 3-建立地址池,有几个VLAN创建几个地址池: [R1]ip pool vlan10 [R1-ip-pool-vlan10]network 192.168.10.0 mask 255.255.255.0;配置网段 [R1-ip-pool-vlan10]gateway-list 192.168.10.254;PC网关 [R1-ip-pool-vlan10]dns-list 8.8.8.8 114.114.114.114;DNS服务器 [R1]ip pool vlan20 [R1-ip-pool-vlan20]gateway-list 192.168.20.254 [R1-ip-pool-vlan20]network 192.168.20.0 mask 255.255.255.0 [R1-ip-pool-vlan20]dhcp server lease day 3 [R1-ip-pool-vlan20]dns-list 8.8.8.8 [R1-ip-pool-vlan20]q [R1] 4-在网关所在接口,开启DHCP功能 [R1]interface GigabitEthernet 0/0/0 [R1-GigabitEthernet0/0/0]dhcp select global //全局地址池配置 5-配置路由 [R1]ip route-static 192.168.10.0 24 192.168.99.2 [R1]ip route-static 192.168.20.0 24 192.168.99.2 [R1] 交换机SW1配置 <Huawei>sys [Huawei]sysname SW1 [SW1]undo info-center enable [SW1]vlan batch 10 20 1-配置交换机管理IP [SW1]interface Vlanif 1 [SW1-Vlanif1]ip address 192.168.99.2 24 [SW1-Vlanif1]q 2-启用DHCP [SW1]dhcp enable 3-配置VLAN [SW1]int Vlanif 10 [SW1-Vlanif10]ip address 192.168.10.254 24 [SW1-Vlanif10]dhcp select relay //配置DHCP中继 [SW1-Vlanif10]dhcp relay server-ip 192.168.99.1 [SW1-Vlanif10]q [SW1] [SW1]int vlan20 [SW1-Vlanif20]ip address 192.168.20.254 24 [SW1-Vlanif20]dhcp select relay [SW1-Vlanif20]dhcp relay server-ip 192.168.99.1 [SW1-Vlanif20]q [SW1] 4-配置相应的接口类型 [SW1]interface GigabitEthernet 0/0/1 [SW1-GigabitEthernet0/0/1]port link-type trunk [SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20 [SW1-GigabitEthernet0/0/1]q [SW1] [SW1]interface GigabitEthernet 0/0/2 [SW1-GigabitEthernet0/0/2]port link-type trunk [SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan 20 [SW1-GigabitEthernet0/0/2]q [SW1] 交换机SW3配置 <Huawei>system-view [Huawei]undo info-center enable [Huawei]sysname SW3 [SW3]dhcp enable [SW3]vlan batch 10 20 [SW3]interface Vlanif 1 [SW3-Vlanif1]ip address 192.168.99.3 24 [SW3-Vlanif1]q [SW3]interface GigabitEthernet 0/0/2 [SW3-GigabitEthernet0/0/2]port link-type trunk [SW3-GigabitEthernet0/0/2]port trunk allow-pass vlan 20 [SW3-GigabitEthernet0/0/2]q [SW3]interface GigabitEthernet 0/0/10 [SW3-GigabitEthernet0/0/10]port link-type access [SW3-GigabitEthernet0/0/10]port default vlan 20 [SW3-GigabitEthernet0/0/10]q [SW3]interface GigabitEthernet 0/0/14 [SW3-GigabitEthernet0/0/14]port link-type access [SW3-GigabitEthernet0/0/14]port default vlan 20 [SW3-GigabitEthernet0/0/14]q [SW3] [SW3] 交换机SW2配置 <Huawei>system-view [Huawei]undo info-center enable [Huawei]sysname SW2 [SW2]vlan 10 [SW2]interface GigabitEthernet 0/0/12 [SW2-GigabitEthernet0/0/12]port link-type access [SW2-GigabitEthernet0/0/12]port default vlan 10 [SW2-GigabitEthernet0/0/12]q [SW2] [SW2]interface GigabitEthernet 0/0/1 [SW2-GigabitEthernet0/0/1]port link-type trunk [SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20 [SW2-GigabitEthernet0/0/1]q [SW2] 5-测试 本文可以帮助您基本地设置和管理您的路由器。 |
温馨提示:喜欢本站的话,请收藏一下本站!