VLAN/单臂路由/DHCP配置方法

PC9为后来验证排除地址池下发IP地址所连(本命令不包含此端口命令) 一.基本VLAN(虚拟局域网,隔离冲突域和广播域)配置 1.sw1配置 [sw1]vlan batch 2 3 [sw1]interface e0/0/1 [sw1-Ethernet0/0/1]port link-type access [sw1-Ethernet0/0/1]port default vlan 2 [sw1-Ethernet0/0/1]q [sw1]interface e0/0/2 [sw1-Ethernet0/0/2]port link-type access [sw1-Ethernet0/0/2]port default vlan 2 [sw1-Ethernet0/0/2]q [sw1]interface e0/0/3 [sw1-Ethernet0/0/3]port link-type access [sw1-Ethernet0/0/3]port default vlan 3 [sw1-Ethernet0/0/3]q [sw1]interface e0/0/4 [sw1-Ethernet0/0/4]port link-type access [sw1-Ethernet0/0/4]port default vlan 3 [sw1-Ethernet0/0/4]q [sw1]interface e0/0/5 [sw1-Ethernet0/0/5]port link-type trunk [sw1-Ethernet0/0/5]port trunk allow-pass vlan all [sw1-Ethernet0/0/5]q [sw1]interface e0/0/6 [sw1-Ethernet0/0/6]port link-type trunk [sw1-Ethernet0/0/6]port trunk allow-pass vlan all 2.sw2配置 [sw2]vlan batch 2 3 [sw2]interface e0/0/1 [sw2-Ethernet0/0/1]port link-type access [sw2-Ethernet0/0/1]port default vlan 2 [sw2-Ethernet0/0/1]q [sw2]interface e0/0/2 [sw2-Ethernet0/0/2]port link-type access [sw2-Ethernet0/0/2]port default vlan 2 [sw2-Ethernet0/0/2]q [sw2]interface e0/0/3 [sw2-Ethernet0/0/3]port link-type access [sw2-Ethernet0/0/3]port default vlan 3 [sw2-Ethernet0/0/3]q [sw2]interface e0/0/4 [sw2-Ethernet0/0/4]port link-type access [sw2-Ethernet0/0/4]port default vlan 3 [sw2-Ethernet0/0/4]q [sw2]interface e0/0/5 [sw2-Ethernet0/0/5]port link-type trunk [sw2-Ethernet0/0/5]port trunk allow-pass vlan all 通过display vlan查看vlan配置

二.单臂路由 [R1]interface g0/0/0.1 /创建虚拟子接口 [R1-GigabitEthernet0/0/0.1]dot1q termination vid 2 /封装给vlan [R1-GigabitEthernet0/0/0.1]ip address 192.168.1.1 24 /配置ip(网关) [R1-GigabitEthernet0/0/0.1]arp broadcast enable /开启arp广播 [R1-GigabitEthernet0/0/0.1]q [R1]interface g0/0/0.2 [R1-GigabitEthernet0/0/0.2]dot1q termination vid 3 [R1-GigabitEthernet0/0/0.2]ip address 192.168.2.1 24 [R1-GigabitEthernet0/0/0.2]arp broadcast enable

三.DHCP(动态地址下发协议)的配置 [R1]ip pool xixi /创建地址池 Info: It’s successful to create an IP address pool. [R1-ip-pool-xixi]network 192.168.1.0 mask 24 /下放地址网段 [R1-ip-pool-xixi]gateway-list 192.168.1.1 /网关地址 [R1-ip-pool-xixi]dns-list 8.8.8.8 /dns服务器地址 [R1-ip-pool-xixi]q [R1]dhcp enable /启用dhcp Info: The operation may take a few seconds. Please wait for a moment.done. [R1]interface g0/0/0.1 [R1-GigabitEthernet0/0/0.1]dhcp select global /在这个口下调用dhcp协议 [R1]ip pool haha Info: It’s successful to create an IP address pool [R1-ip-pool-haha]network 192.168.2.0 mask 24 [R1-ip-pool-haha]gateway-list 192.168.2.1 [R1-ip-pool-haha]dns-list 8.8.8.8 [R1-ip-pool-haha]q [R1]dhcp enable [R1]interface g0/0/0.2 [R1-GigabitEthernet0/0/0.2]dhcp select global

在某一个地址池下排除下放地址命令 [R1-ip-pool-xixi]excluded-ip-address 起始排除地址+停止排除地址 四.单臂路由的作用 单臂路由就是在路由器以太网接口下配置若干个子接口,每个子接口对应一个VLAN,这样当路由器的以太网口连接到一个划分VLAN的二层交换机时,可以通过路由器的以太网口,实现二层交换机上多个VLAN之间的互通。

而三层交换机的VLAN之间互通,则不需要路由器的配合,可在三层交换机上直接配置VLAN虚接口,每个VLAN一个虚接口,并指定IP,通过VLAN虚接口实现交换机各个VLAN之间的互通。

经验分享 程序员 微信小程序 职场和发展