华为路由器静态路由和默认路由的写法
配置静态路由:
[Huawei] ip route-static <目标网络> <子网掩码> <下一跳地址>
实例:将目标网络192.168.10.0/24的流量发送到下一跳地址10.0.0.1
[Huawei] ip route-static 192.168.10.0 255.255.255.0 10.0.0.1
配置默认路由:
[Huawei] ip route-static 0.0.0.0 0.0.0.0 <下一跳地址>
实例:将未知目标网络的流量发送到默认下一跳地址203.0.113.1
[Huawei] ip route-static 0.0.0.0 0.0.0.0 203.0.113.1
静态路由和默认路由的区别
- 静态路由需要手动为每个目标网络配置路由表项。当网络规模变大时,需要手动配置大量的路由表项,而且路由表需要经常更新以适应网络拓扑的变化。而默认路由只需要配置一条路由表项,将所有未知目标网络的流量都发送到下一跳地址,这样可以简化路由表的配置和维护。
- 静态路由通常需要手动配置和更新,因此对于复杂的网络拓扑或动态变化的网络环境,静态路由可能不够灵活。而默认路由则更加简单和灵活,适用于较简单的网络环境或者那些需要快速配置的场景。
- 静态路由的路由选择是基于管理员手动配置的路由策略来决定下一跳地址。管理员可以根据具体的需求配置不同的路由策略,例如基于最短路径、最优成本等。而默认路由会将所有未知目标网络的流量发送到预设的下一跳地址,没有复杂的路由选择过程。
- 静态路由没有自动学习的能力,需要手动配置每个目标网络的路由表项。而一些路由协议(如OSPF或BGP)可以自动学习和更新路由表,根据网络的动态变化自动调整路由路径。虽然默认路由本身不具备自动学习的能力,但是当与动态路由协议结合使用时,可以从邻居路由器处自动学习到默认路由。
案例
下面来看案例,这次案例比较简单,主要看现象
设备配置如下
为LSW1配置默认路由
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sysname LSW1 [LSW1]vlan batch Sep 17 2023 16:47:30-08:00 LSW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.2 5.191.3.1 configurations have been changed. The current change number is 4, the [LSW1]undo info-center enable Info: Information center is disabled. [LSW1]vlan batch 10 30 101 Info: This operation may take a few seconds. Please wait for a moment...done. [LSW1]interface g0/0/9 [LSW1-GigabitEthernet0/0/9]port link-type access [LSW1-GigabitEthernet0/0/9]port default vlan 10 [LSW1-GigabitEthernet0/0/9]qu [LSW1]interface g0/0/13 [LSW1-GigabitEthernet0/0/13]port link-type access [LSW1-GigabitEthernet0/0/13]port default vlan 30 [LSW1-GigabitEthernet0/0/13]qu [LSW1]interface g0/0/24 [LSW1-GigabitEthernet0/0/24]port link-type access [LSW1-GigabitEthernet0/0/24]port default vlan 101 [LSW1-GigabitEthernet0/0/24]qu [LSW1]display vlan The total number of vlans is : 4 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------------------- VID Type Ports -------------------------------------------------------------------------------- 1 common UT:GE0/0/1(D) GE0/0/2(D) GE0/0/3(D) GE0/0/4(D) GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D) GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D) GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) 10 common UT:GE0/0/9(U) 30 common UT:GE0/0/13(U) 101 common UT:GE0/0/24(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 30 enable default enable disable VLAN 0030 101 enable default enable disable VLAN 0101 [LSW1]display port vlan Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------------------- GigabitEthernet0/0/1 hybrid 1 - GigabitEthernet0/0/2 hybrid 1 - GigabitEthernet0/0/3 hybrid 1 - GigabitEthernet0/0/4 hybrid 1 - GigabitEthernet0/0/5 hybrid 1 - GigabitEthernet0/0/6 hybrid 1 - GigabitEthernet0/0/7 hybrid 1 - GigabitEthernet0/0/8 hybrid 1 - GigabitEthernet0/0/9 access 10 - GigabitEthernet0/0/10 hybrid 1 - GigabitEthernet0/0/11 hybrid 1 - GigabitEthernet0/0/12 hybrid 1 - GigabitEthernet0/0/13 access 30 - GigabitEthernet0/0/14 hybrid 1 - GigabitEthernet0/0/15 hybrid 1 - GigabitEthernet0/0/16 hybrid 1 - GigabitEthernet0/0/17 hybrid 1 - GigabitEthernet0/0/18 hybrid 1 - GigabitEthernet0/0/19 hybrid 1 - GigabitEthernet0/0/20 hybrid 1 - GigabitEthernet0/0/21 hybrid 1 - GigabitEthernet0/0/22 hybrid 1 - GigabitEthernet0/0/23 hybrid 1 - GigabitEthernet0/0/24 access 101 - [LSW1]interface vlanif 10 [LSW1-Vlanif10]ip address 192.168.10.1 24 [LSW1-Vlanif10]qu [LSW1]interface vlanif 30 [LSW1-Vlanif30]ip address 192.168.30.1 24 [LSW1-Vlanif30]qu [LSW1]interface vlanif 101 [LSW1-Vlanif101]ip address 192.168.101.1 24 [LSW1-Vlanif101]qu [LSW1]display interface brief PHY: Physical *down: administratively down (l): loopback (s): spoofing (b): BFD down (e): ETHOAM down (dl): DLDP down (d): Dampening Suppressed InUti/OutUti: input utility/output utility Interface PHY Protocol InUti OutUti inErrors outErrors GigabitEthernet0/0/1 down down 0% 0% 0 0 GigabitEthernet0/0/2 down down 0% 0% 0 0 GigabitEthernet0/0/3 down down 0% 0% 0 0 GigabitEthernet0/0/4 down down 0% 0% 0 0 GigabitEthernet0/0/5 down down 0% 0% 0 0 GigabitEthernet0/0/6 down down 0% 0% 0 0 GigabitEthernet0/0/7 down down 0% 0% 0 0 GigabitEthernet0/0/8 down down 0% 0% 0 0 GigabitEthernet0/0/9 up up 0% 0% 0 0 GigabitEthernet0/0/10 down down 0% 0% 0 0 GigabitEthernet0/0/11 down down 0% 0% 0 0 GigabitEthernet0/0/12 down down 0% 0% 0 0 GigabitEthernet0/0/13 up up 0% 0% 0 0 GigabitEthernet0/0/14 down down 0% 0% 0 0 GigabitEthernet0/0/15 down down 0% 0% 0 0 GigabitEthernet0/0/16 down down 0% 0% 0 0 GigabitEthernet0/0/17 down down 0% 0% 0 0 GigabitEthernet0/0/18 down down 0% 0% 0 0 GigabitEthernet0/0/19 down down 0% 0% 0 0 GigabitEthernet0/0/20 down down 0% 0% 0 0 GigabitEthernet0/0/21 down down 0% 0% 0 0 GigabitEthernet0/0/22 down down 0% 0% 0 0 GigabitEthernet0/0/23 down down 0% 0% 0 0 GigabitEthernet0/0/24 up up 0% 0% 0 0 [LSW1]display ip interface brief *down: administratively down ^down: standby (l): loopback (s): spoofing The number of interface that is UP in Physical is 4 The number of interface that is DOWN in Physical is 2 The number of interface that is UP in Protocol is 4 The number of interface that is DOWN in Protocol is 2 Interface IP Address/Mask Physical Protocol MEth0/0/1 unassigned down down NULL0 unassigned up up(s) Vlanif1 unassigned down down Vlanif10 192.168.10.1/24 up up Vlanif30 192.168.30.1/24 up up Vlanif101 192.168.101.1/24 up up [LSW1]display IP interface vlanif 10 Vlanif10 current state : UP Line protocol current state : UP The Maximum Transmit Unit : 1500 bytes input packets : 0, bytes : 0, multicasts : 0 output packets : 0, bytes : 0, multicasts : 0 Directed-broadcast packets: received packets: 0, sent packets: 0 forwarded packets: 0, dropped packets: 0 Internet Address is 192.168.10.1/24 Broadcast address : 192.168.10.255 TTL being 1 packet number: 0 TTL invalid packet number: 0 ICMP packet input number: 0 Echo reply: 0 Unreachable: 0 Source quench: 0 Routing redirect: 0 Echo request: 0 Router advert: 0 Router solicit: 0 Time exceed: 0 IP header bad: 0 Timestamp request: [LSW1]display IP interface vlanif 30 Vlanif30 current state : UP Line protocol current state : UP The Maximum Transmit Unit : 1500 bytes input packets : 0, bytes : 0, multicasts : 0 output packets : 0, bytes : 0, multicasts : 0 Directed-broadcast packets: received packets: 0, sent packets: 0 forwarded packets: 0, dropped packets: 0 Internet Address is 192.168.30.1/24 Broadcast address : 192.168.30.255 TTL being 1 packet number: 0 TTL invalid packet number: 0 ICMP packet input number: 0 Echo reply: 0 Unreachable: 0 Source quench: 0 Routing redirect: 0 Echo request: 0 Router advert: 0 Router solicit: 0 Time exceed: 0 IP header bad: 0 Timestamp request: [LSW1]display IP interface vlanif 101 Vlanif101 current state : UP Line protocol current state : UP The Maximum Transmit Unit : 1500 bytes input packets : 0, bytes : 0, multicasts : 0 output packets : 0, bytes : 0, multicasts : 0 Directed-broadcast packets: received packets: 0, sent packets: 0 forwarded packets: 0, dropped packets: 0 Internet Address is 192.168.101.1/24 Broadcast address : 192.168.101.255 TTL being 1 packet number: 0 TTL invalid packet number: 0 ICMP packet input number: 0 Echo reply: 0 Unreachable: 0 Source quench: 0 Routing redirect: 0 Echo request: 0 Router advert: 0 Router solicit: 0 Time exceed: 0 IP header bad: 0 Timestamp request: 0 Timestamp reply: 0 [LSW1]display IP routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 8 Routes : 8 Destination/Mask Proto Pre Cost Flags NextHop Interface 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.10.0/24 Direct 0 0 D 192.168.10.1 Vlanif10 192.168.10.1/32 Direct 0 0 D 127.0.0.1 Vlanif10 192.168.30.0/24 Direct 0 0 D 192.168.30.1 Vlanif30 192.168.30.1/32 Direct 0 0 D 127.0.0.1 Vlanif30 192.168.101.0/24 Direct 0 0 D 192.168.101.1 Vlanif101 192.168.101.1/32 Direct 0 0 D 127.0.0.1 Vlanif101
同理,为LSW2配置默认路由
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sysname LSW2 [LSW2]vlan batch Sep 17 2023 16:55:00-08:00 LSW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.2 5.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095. ^ Error:Incomplete command found at '^' position. [LSW2]undo info-center enable Info: Information center is disabled. [LSW2]vlan batch 80 81 102 Info: This operation may take a few seconds. Please wait for a moment...done. [LSW2]interface g0/0/9 [LSW2-GigabitEthernet0/0/9]port link-type access [LSW2-GigabitEthernet0/0/9]qu [LSW2]interface g0/0/15 [LSW2-GigabitEthernet0/0/15]port link-type access [LSW2-GigabitEthernet0/0/15]port default vlan 80 [LSW2-GigabitEthernet0/0/15]qu [LSW2]interface g0/0/17 [LSW2-GigabitEthernet0/0/17]port link-type access [LSW2-GigabitEthernet0/0/17]port default vlan 81 [LSW2-GigabitEthernet0/0/17]qu [LSW2]interface g0/0/24 [LSW2-GigabitEthernet0/0/24]port link-type access [LSW2-GigabitEthernet0/0/24]port default vlan 102 [LSW2-GigabitEthernet0/0/24]qu [LSW2]display vlan The total number of vlans is : 4 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------------------- VID Type Ports -------------------------------------------------------------------------------- 1 common UT:GE0/0/1(D) GE0/0/2(D) GE0/0/3(D) GE0/0/4(D) GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D) GE0/0/9(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D) GE0/0/13(D) GE0/0/14(D) GE0/0/16(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D) GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) 80 common UT:GE0/0/15(U) 81 common UT:GE0/0/17(U) 102 common UT:GE0/0/24(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 80 enable default enable disable VLAN 0080 81 enable default enable disable VLAN 0081 102 enable default enable disable VLAN 0102 [LSW2]display port vlan Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------------------- GigabitEthernet0/0/1 hybrid 1 - GigabitEthernet0/0/2 hybrid 1 - GigabitEthernet0/0/3 hybrid 1 - GigabitEthernet0/0/4 hybrid 1 - GigabitEthernet0/0/5 hybrid 1 - GigabitEthernet0/0/6 hybrid 1 - GigabitEthernet0/0/7 hybrid 1 - GigabitEthernet0/0/8 hybrid 1 - GigabitEthernet0/0/9 access 1 - GigabitEthernet0/0/10 hybrid 1 - GigabitEthernet0/0/11 hybrid 1 - GigabitEthernet0/0/12 hybrid 1 - GigabitEthernet0/0/13 hybrid 1 - GigabitEthernet0/0/14 hybrid 1 - GigabitEthernet0/0/15 access 80 - GigabitEthernet0/0/16 hybrid 1 - GigabitEthernet0/0/17 access 81 - GigabitEthernet0/0/18 hybrid 1 - GigabitEthernet0/0/19 hybrid 1 - GigabitEthernet0/0/20 hybrid 1 - GigabitEthernet0/0/21 hybrid 1 - GigabitEthernet0/0/22 hybrid 1 - GigabitEthernet0/0/23 hybrid 1 - GigabitEthernet0/0/24 access 102 - [LSW2]display port vlan Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------------------- GigabitEthernet0/0/1 hybrid 1 - GigabitEthernet0/0/2 hybrid 1 - GigabitEthernet0/0/3 hybrid 1 - GigabitEthernet0/0/4 hybrid 1 - GigabitEthernet0/0/5 hybrid 1 - GigabitEthernet0/0/6 hybrid 1 - GigabitEthernet0/0/7 hybrid 1 - GigabitEthernet0/0/8 hybrid 1 - GigabitEthernet0/0/9 access 1 - GigabitEthernet0/0/10 hybrid 1 - GigabitEthernet0/0/11 hybrid 1 - GigabitEthernet0/0/12 hybrid 1 - GigabitEthernet0/0/13 hybrid 1 - GigabitEthernet0/0/14 hybrid 1 - GigabitEthernet0/0/15 access 80 - GigabitEthernet0/0/16 hybrid 1 - GigabitEthernet0/0/17 access 81 - GigabitEthernet0/0/18 hybrid 1 - GigabitEthernet0/0/19 hybrid 1 - GigabitEthernet0/0/20 hybrid 1 - GigabitEthernet0/0/21 hybrid 1 - GigabitEthernet0/0/22 hybrid 1 - GigabitEthernet0/0/23 hybrid 1 - GigabitEthernet0/0/24 access 102 - [LSW2]interface vlanif 80 [LSW2-Vlanif80]ip address 192.168.80.1 24 [LSW2-Vlanif80]qu [LSW2]interface vlanif 81 [LSW2-Vlanif81]ip address 192.168.81.1 24 [LSW2-Vlanif81]qu [LSW2]interface vlanif 102 [LSW2-Vlanif102]ip address 192.168.102.1 24 [LSW2-Vlanif102]qu [LSW2]display interface brief PHY: Physical *down: administratively down (l): loopback (s): spoofing (b): BFD down (e): ETHOAM down (dl): DLDP down (d): Dampening Suppressed InUti/OutUti: input utility/output utility Interface PHY Protocol InUti OutUti inErrors outErrors GigabitEthernet0/0/1 down down 0% 0% 0 0 GigabitEthernet0/0/2 down down 0% 0% 0 0 GigabitEthernet0/0/3 down down 0% 0% 0 0 GigabitEthernet0/0/4 down down 0% 0% 0 0 GigabitEthernet0/0/5 down down 0% 0% 0 0 GigabitEthernet0/0/6 down down 0% 0% 0 0 GigabitEthernet0/0/7 down down 0% 0% 0 0 GigabitEthernet0/0/8 down down 0% 0% 0 0 GigabitEthernet0/0/9 down down 0% 0% 0 0 GigabitEthernet0/0/10 down down 0% 0% 0 0 GigabitEthernet0/0/11 down down 0% 0% 0 0 GigabitEthernet0/0/12 down down 0% 0% 0 0 GigabitEthernet0/0/13 down down 0% 0% 0 0 GigabitEthernet0/0/14 down down 0% 0% 0 0 GigabitEthernet0/0/15 up up 0% 0% 0 0 GigabitEthernet0/0/16 down down 0% 0% 0 0 GigabitEthernet0/0/17 up up 0% 0% 0 0 GigabitEthernet0/0/18 down down 0% 0% 0 0 GigabitEthernet0/0/19 down down 0% 0% 0 0 GigabitEthernet0/0/20 down down 0% 0% 0 0 GigabitEthernet0/0/21 down down 0% 0% 0 0 GigabitEthernet0/0/22 down down 0% 0% 0 0 GigabitEthernet0/0/23 down down 0% 0% 0 0 GigabitEthernet0/0/24 up up 0% 0% 0 0 [LSW2]display ip interface brief *down: administratively down ^down: standby (l): loopback (s): spoofing The number of interface that is UP in Physical is 4 The number of interface that is DOWN in Physical is 2 The number of interface that is UP in Protocol is 4 The number of interface that is DOWN in Protocol is 2 Interface IP Address/Mask Physical Protocol MEth0/0/1 unassigned down down NULL0 unassigned up up(s) Vlanif1 unassigned down down Vlanif80 192.168.80.1/24 up up Vlanif81 192.168.81.1/24 up up Vlanif102 192.168.102.1/24 up up [LSW2]display IP interface vlanif 80 Vlanif80 current state : UP Line protocol current state : UP The Maximum Transmit Unit : 1500 bytes input packets : 0, bytes : 0, multicasts : 0 output packets : 0, bytes : 0, multicasts : 0 Directed-broadcast packets: received packets: 0, sent packets: 0 forwarded packets: 0, dropped packets: 0 Internet Address is 192.168.80.1/24 Broadcast address : 192.168.80.255 TTL being 1 packet number: 0 TTL invalid packet number: 0 ICMP packet input number: 0 Echo reply: 0 Unreachable: 0 Source quench: 0 Routing redirect: 0 Echo request: 0 Router advert: 0 Router solicit: 0 Time exceed: 0 IP header bad: 0 Timestamp request: [LSW2]display IP interface vlanif 81 Vlanif81 current state : UP Line protocol current state : UP The Maximum Transmit Unit : 1500 bytes input packets : 0, bytes : 0, multicasts : 0 output packets : 0, bytes : 0, multicasts : 0 Directed-broadcast packets: received packets: 0, sent packets: 0 forwarded packets: 0, dropped packets: 0 Internet Address is 192.168.81.1/24 Broadcast address : 192.168.81.255 TTL being 1 packet number: 0 TTL invalid packet number: 0 ICMP packet input number: 0 Echo reply: 0 Unreachable: 0 Source quench: 0 Routing redirect: 0 Echo request: 0 Router advert: 0 Router solicit: 0 Time exceed: 0 IP header bad: 0 Timestamp request: 0 Timestamp reply: 0 [LSW2]display IP interface vlanif 102 Vlanif102 current state : UP Line protocol current state : UP The Maximum Transmit Unit : 1500 bytes input packets : 0, bytes : 0, multicasts : 0 output packets : 0, bytes : 0, multicasts : 0 Directed-broadcast packets: received packets: 0, sent packets: 0 forwarded packets: 0, dropped packets: 0 Internet Address is 192.168.102.1/24 Broadcast address : 192.168.102.255 TTL being 1 packet number: 0 TTL invalid packet number: 0 ICMP packet input number: 0 Echo reply: 0 Unreachable: 0 Source quench: 0 Routing redirect: 0 Echo request: 0 Router advert: 0 Router solicit: 0 Time exceed: 0 IP header bad: 0 Timestamp request: 0 Timestamp reply: 0 [LSW2]display IP routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 8 Routes : 8 Destination/Mask Proto Pre Cost Flags NextHop Interface 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.80.0/24 Direct 0 0 D 192.168.80.1 Vlanif80 192.168.80.1/32 Direct 0 0 D 127.0.0.1 Vlanif80 192.168.81.0/24 Direct 0 0 D 192.168.81.1 Vlanif81 192.168.81.1/32 Direct 0 0 D 127.0.0.1 Vlanif81 192.168.102.0/24 Direct 0 0 D 192.168.102.1 Vlanif102 192.168.102.1/32 Direct 0 0 D 127.0.0.1 Vlanif102
配置路由器RTA端口
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sysname RTA #配置连接交换机LSW1的端口g0/0/1及对应的ip地址 [RTA]interface g0/0/1 [RTA-GigabitEthernet0/0/1]ip address 192.168.101.2 24 [RTA-GigabitEthernet0/0/1] Sep 17 2023 17:06:09-08:00 RTA %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/1 has entered the UP state. [RTA-GigabitEthernet0/0/1]qu [RTA]interface g0/0/2 [RTA-GigabitEthernet0/0/2]ip address 192.168.102.2 24 Sep 17 2023 17:06:56-08:00 RTA %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/2 has entered the UP state. [RTA-GigabitEthernet0/0/2]qu #配置环回接口 IP 地址,模拟校园网上的一台主机。 # 环回接口 Loopback 用于模拟在路由器后的一个IP 网段。Loopback 接口作为一个逻辑接口并不真实存在,并且该接口永远不会 DOWN,正是由于这个特性,使得 Loopback 接口常用于: 网络测试、协议的 RouerID、建立基于Loopback 的邻接关系、作为SNMP traps 消息的源地址等 [RTA]interface loopback 0 [RTA-LoopBack0]ip address 10.1.1.10 23 [RTA-LoopBack0]qu [RTA]display interface brief PHY: Physical *down: administratively down (l): loopback (s): spoofing (b): BFD down ^down: standby (e): ETHOAM down (d): Dampening Suppressed InUti/OutUti: input utility/output utility Interface PHY Protocol InUti OutUti inErrors outErrors GigabitEthernet0/0/0 down down 0% 0% 0 0 GigabitEthernet0/0/1 up up 0% 0% 0 0 GigabitEthernet0/0/2 up up 0% 0% 0 0 LoopBack0 up up(s) 0% 0% 0 0 NULL0 up up(s) 0% 0% 0 0 [RTA]display ip interface brief *down: administratively down ^down: standby (l): loopback (s): spoofing The number of interface that is UP in Physical is 4 The number of interface that is DOWN in Physical is 1 The number of interface that is UP in Protocol is 4 The number of interface that is DOWN in Protocol is 1 Interface IP Address/Mask Physical Protocol GigabitEthernet0/0/0 unassigned down down GigabitEthernet0/0/1 192.168.101.2/24 up up GigabitEthernet0/0/2 192.168.102.2/24 up up LoopBack0 10.1.1.10/23 up up(s) NULL0 unassigned up up(s) [RTA]display IP interface g0/0/1 GigabitEthernet0/0/1 current state : UP Line protocol current state : UP The Maximum Transmit Unit : 1500 bytes input packets : 0, bytes : 0, multicasts : 0 output packets : 0, bytes : 0, multicasts : 0 Directed-broadcast packets: received packets: 0, sent packets: 0 forwarded packets: 0, dropped packets: 0 ARP packet input number: 0 Request packet: 0 Reply packet: 0 Unknown packet: 0 Internet Address is 192.168.101.2/24 Broadcast address : 192.168.101.255 TTL being 1 packet number: 0 TTL invalid packet number: 0 ICMP packet input number: 0 Echo reply: 0 Unreachable: 0 Source quench: 0 Routing redirect: 0 Echo request: 0 Router advert: [RTA]display IP interface g0/0/2 GigabitEthernet0/0/2 current state : UP Line protocol current state : UP The Maximum Transmit Unit : 1500 bytes input packets : 0, bytes : 0, multicasts : 0 output packets : 0, bytes : 0, multicasts : 0 Directed-broadcast packets: received packets: 0, sent packets: 0 forwarded packets: 0, dropped packets: 0 ARP packet input number: 0 Request packet: 0 Reply packet: 0 Unknown packet: 0 Internet Address is 192.168.102.2/24 Broadcast address : 192.168.102.255 TTL being 1 packet number: 0 TTL invalid packet number: 0 ICMP packet input number: 0 Echo reply: 0 Unreachable: 0 Source quench: 0 Routing redirect: 0 Echo request: 0 Router advert: 0 Router solicit: 0 [RTA]display IP routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 13 Routes : 13 Destination/Mask Proto Pre Cost Flags NextHop Interface 10.1.0.0/23 Direct 0 0 D 10.1.1.10 LoopBack0 10.1.1.10/32 Direct 0 0 D 127.0.0.1 LoopBack0 10.1.1.255/32 Direct 0 0 D 127.0.0.1 LoopBack0 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.101.0/24 Direct 0 0 D 192.168.101.2 GigabitEthernet 0/0/1 192.168.101.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1 192.168.101.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1 192.168.102.0/24 Direct 0 0 D 192.168.102.2 GigabitEthernet 0/0/2 192.168.102.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/2 192.168.102.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/2 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 在PC-10-1 ping其他主机 PC>ping 192.168.30.11 Ping 192.168.30.11: 32 data bytes, Press Ctrl_C to break From 192.168.30.11: bytes=32 seq=1 ttl=127 time=62 ms From 192.168.30.11: bytes=32 seq=2 ttl=127 time=31 ms From 192.168.30.11: bytes=32 seq=3 ttl=127 time=32 ms From 192.168.30.11: bytes=32 seq=4 ttl=127 time=31 ms From 192.168.30.11: bytes=32 seq=5 ttl=127 time=47 ms --- 192.168.30.11 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 31/40/62 ms PC>ping 192.168.80.11 Ping 192.168.80.11: 32 data bytes, Press Ctrl_C to break Request timeout! Request timeout! Request timeout! Request timeout! Request timeout! --- 192.168.80.11 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss PC>ping 192.168.81.11 Ping 192.168.81.11: 32 data bytes, Press Ctrl_C to break Request timeout! Request timeout! Request timeout! Request timeout! Request timeout! --- 192.168.81.11 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss PC>ping 10.1.1.10 Ping 10.1.1.10: 32 data bytes, Press Ctrl_C to break Request timeout! Request timeout! Request timeout! Request timeout! Request timeout! --- 10.1.1.10 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss 在PC-30-1上ping其他主机 PC>ping 192.168.10.11 Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break From 192.168.10.11: bytes=32 seq=1 ttl=127 time=31 ms From 192.168.10.11: bytes=32 seq=2 ttl=127 time=47 ms From 192.168.10.11: bytes=32 seq=3 ttl=127 time=47 ms From 192.168.10.11: bytes=32 seq=4 ttl=127 time=31 ms From 192.168.10.11: bytes=32 seq=5 ttl=127 time=31 ms --- 192.168.10.11 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 31/37/47 ms PC>ping 192.168.80.11 Ping 192.168.80.11: 32 data bytes, Press Ctrl_C to break Request timeout! Request timeout! Request timeout! Request timeout! Request timeout! --- 192.168.80.11 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss PC>ping 192.168.81.11 Ping 192.168.81.11: 32 data bytes, Press Ctrl_C to break Request timeout! Request timeout! Request timeout! Request timeout! Request timeout! --- 192.168.81.11 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss PC>ping 10.1.1.10 Ping 10.1.1.10: 32 data bytes, Press Ctrl_C to break Request timeout! Request timeout! Request timeout! Request timeout! Request timeout! --- 10.1.1.10 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss 在PC-80-1上ping其他主机 PC>ping 192.168.81.11 Ping 192.168.81.11: 32 data bytes, Press Ctrl_C to break From 192.168.81.11: bytes=32 seq=1 ttl=127 time=62 ms From 192.168.81.11: bytes=32 seq=2 ttl=127 time=47 ms From 192.168.81.11: bytes=32 seq=3 ttl=127 time=47 ms From 192.168.81.11: bytes=32 seq=4 ttl=127 time=47 ms From 192.168.81.11: bytes=32 seq=5 ttl=127 time=31 ms --- 192.168.81.11 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 31/46/62 ms PC>ping 192.168.10.11 Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break Request timeout! Request timeout! Request timeout! Request timeout! Request timeout! --- 192.168.10.11 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss PC>ping 192.168.30.11 Ping 192.168.30.11: 32 data bytes, Press Ctrl_C to break Request timeout! Request timeout! Request timeout! Request timeout! Request timeout! --- 192.168.30.11 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss PC>ping 10.1.1.10 Ping 10.1.1.10: 32 data bytes, Press Ctrl_C to break Request timeout! Request timeout! Request timeout! Request timeout! Request timeout! --- 10.1.1.10 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss 在PC-81-1上ping其他主机 PC>ping 192.168.80.11 Ping 192.168.80.11: 32 data bytes, Press Ctrl_C to break From 192.168.80.11: bytes=32 seq=1 ttl=127 time=47 ms From 192.168.80.11: bytes=32 seq=2 ttl=127 time=47 ms From 192.168.80.11: bytes=32 seq=3 ttl=127 time=31 ms From 192.168.80.11: bytes=32 seq=4 ttl=127 time=31 ms From 192.168.80.11: bytes=32 seq=5 ttl=127 time=47 ms --- 192.168.80.11 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 31/40/47 ms PC>ping 192.168.10.11 Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break Request timeout! Request timeout! Request timeout! Request timeout! Request timeout! --- 192.168.10.11 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss PC>ping 192.168.30.11 Ping 192.168.30.11: 32 data bytes, Press Ctrl_C to break Request timeout! Request timeout! Request timeout! Request timeout! Request timeout! --- 192.168.30.11 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss PC>ping 10.1.1.10 Ping 10.1.1.10: 32 data bytes, Press Ctrl_C to break Request timeout! Request timeout! Request timeout! Request timeout! Request timeout! --- 10.1.1.10 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss
至此,我们可以看到不同交换机还不能实现vlan的相互通信
现在在交换机和路由器上都配置默认路由
<LSW1>sys Enter system view, return user view with Ctrl+Z. # 配置默认路由,简化路由配置 # 默认路由的目的网络为0.0.0.0,子网掩码为0.0.0.0,下一跳地址为 192.168.102.2。 #也可以配置到每个网络的静态路由 [LSW1]ip route-static 0.0.0.0 0.0.0.0 192.168.101.2 [LSW1]display IP routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 9 Routes : 9 Destination/Mask Proto Pre Cost Flags NextHop Interface 0.0.0.0/0 Static 60 0 RD 192.168.101.2 Vlanif101 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.10.0/24 Direct 0 0 D 192.168.10.1 Vlanif10 192.168.10.1/32 Direct 0 0 D 127.0.0.1 Vlanif10 192.168.30.0/24 Direct 0 0 D 192.168.30.1 Vlanif30 192.168.30.1/32 Direct 0 0 D 127.0.0.1 Vlanif30 192.168.101.0/24 Direct 0 0 D 192.168.101.1 Vlanif101 192.168.101.1/32 Direct 0 0 D 127.0.0.1 Vlanif101
在LSW2上配置默认路由
<
LSW2>sys Enter system view, return user view with Ctrl+Z. [LSW2]ip route-static 0.0.0.0 0.0.0.0 192.168.102.2 [LSW2]display IP routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 9 Routes : 9 Destination/Mask Proto Pre Cost Flags NextHop Interface 0.0.0.0/0 Static 60 0 RD 192.168.102.2 Vlanif102 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.80.0/24 Direct 0 0 D 192.168.80.1 Vlanif80 192.168.80.1/32 Direct 0 0 D 127.0.0.1 Vlanif80 192.168.81.0/24 Direct 0 0 D 192.168.81.1 Vlanif81 192.168.81.1/32 Direct 0 0 D 127.0.0.1 Vlanif81 192.168.102.0/24 Direct 0 0 D 192.168.102.1 Vlanif102 192.168.102.1/32 Direct 0 0 D 127.0.0.1 Vlanif102 在路由器RTA上配置静态和默认路由 <RTA>sys Enter system view, return user view with Ctrl+Z. [RTA]ip route-static 192.168.10.0 24 192.168.101.1 [RTA]ip route-static 192.168.30.0 24 192.168.101.1 [RTA]ip route-static 0.0.0.0 0.0.0.0 192.168.102.1 #也可以配置静态路由 #[RTA]ip route-static 192.168.80.0 24 192.168.102.1 #[RTA]ip route-static 192.168.81.0 24 192.168.102.1 [RTA]display IP routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 16 Routes : 16 Destination/Mask Proto Pre Cost Flags NextHop Interface 0.0.0.0/0 Static 60 0 RD 192.168.102.1 GigabitEthernet 0/0/2 10.1.0.0/23 Direct 0 0 D 10.1.1.10 LoopBack0 10.1.1.10/32 Direct 0 0 D 127.0.0.1 LoopBack0 10.1.1.255/32 Direct 0 0 D 127.0.0.1 LoopBack0 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.10.0/24 Static 60 0 RD 192.168.101.1 GigabitEthernet 0/0/1 192.168.30.0/24 Static 60 0 RD 192.168.101.1 GigabitEthernet 0/0/1 192.168.101.0/24 Direct 0 0 D 192.168.101.2 GigabitEthernet 0/0/1 192.168.101.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1 192.168.101.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1 192.168.102.0/24 Direct 0 0 D 192.168.102.2 GigabitEthernet 0/0/2 192.168.102.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/2 192.168.102.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/2 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 现在PC-10-1可以ping通其他主机 PC>ping 192.168.80.11 Ping 192.168.80.11: 32 data bytes, Press Ctrl_C to break From 192.168.80.11: bytes=32 seq=1 ttl=125 time=78 ms From 192.168.80.11: bytes=32 seq=2 ttl=125 time=94 ms From 192.168.80.11: bytes=32 seq=3 ttl=125 time=62 ms From 192.168.80.11: bytes=32 seq=4 ttl=125 time=47 ms From 192.168.80.11: bytes=32 seq=5 ttl=125 time=78 ms --- 192.168.80.11 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 47/71/94 ms PC>ping 192.168.81.11 Ping 192.168.81.11: 32 data bytes, Press Ctrl_C to break From 192.168.81.11: bytes=32 seq=1 ttl=125 time=78 ms From 192.168.81.11: bytes=32 seq=2 ttl=125 time=94 ms From 192.168.81.11: bytes=32 seq=3 ttl=125 time=78 ms From 192.168.81.11: bytes=32 seq=4 ttl=125 time=78 ms From 192.168.81.11: bytes=32 seq=5 ttl=125 time=93 ms --- 192.168.81.11 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 78/84/94 ms PC>ping 10.1.1.10 Ping 10.1.1.10: 32 data bytes, Press Ctrl_C to break From 10.1.1.10: bytes=32 seq=1 ttl=254 time=78 ms From 10.1.1.10: bytes=32 seq=2 ttl=254 time=47 ms From 10.1.1.10: bytes=32 seq=3 ttl=254 time=31 ms From 10.1.1.10: bytes=32 seq=4 ttl=254 time=31 ms From 10.1.1.10: bytes=32 seq=5 ttl=254 time=47 ms --- 10.1.1.10 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 31/46/78 ms PC-80-1也可以ping通其他主机 PC>ping 192.168.10.11 Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break Request timeout! From 192.168.10.11: bytes=32 seq=2 ttl=125 time=47 ms From 192.168.10.11: bytes=32 seq=3 ttl=125 time=63 ms From 192.168.10.11: bytes=32 seq=4 ttl=125 time=78 ms From 192.168.10.11: bytes=32 seq=5 ttl=125 time=78 ms --- 192.168.10.11 ping statistics --- 5 packet(s) transmitted 4 packet(s) received 20.00% packet loss round-trip min/avg/max = 0/66/78 ms PC>ping 192.168.30.11 Ping 192.168.30.11: 32 data bytes, Press Ctrl_C to break Request timeout! From 192.168.30.11: bytes=32 seq=2 ttl=125 time=94 ms From 192.168.30.11: bytes=32 seq=3 ttl=125 time=63 ms From 192.168.30.11: bytes=32 seq=4 ttl=125 time=93 ms From 192.168.30.11: bytes=32 seq=5 ttl=125 time=94 ms --- 192.168.30.11 ping statistics --- 5 packet(s) transmitted 4 packet(s) received 20.00% packet loss round-trip min/avg/max = 0/86/94 ms PC>ping 10.1.1.10 Ping 10.1.1.10: 32 data bytes, Press Ctrl_C to break From 10.1.1.10: bytes=32 seq=1 ttl=254 time=47 ms From 10.1.1.10: bytes=32 seq=2 ttl=254 time=31 ms From 10.1.1.10: bytes=32 seq=3 ttl=254 time=47 ms From 10.1.1.10: bytes=32 seq=4 ttl=254 time=31 ms From 10.1.1.10: bytes=32 seq=5 ttl=254 time=47 ms --- 10.1.1.10 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 31/40/47 ms PC-30-1也可以ping通其他主机 PC>ping 192.168.10.11 Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break Request timeout! From 192.168.10.11: bytes=32 seq=2 ttl=127 time=32 ms From 192.168.10.11: bytes=32 seq=3 ttl=127 time=47 ms From 192.168.10.11: bytes=32 seq=4 ttl=127 time=46 ms From 192.168.10.11: bytes=32 seq=5 ttl=127 time=47 ms --- 192.168.10.11 ping statistics --- 5 packet(s) transmitted 4 packet(s) received 20.00% packet loss round-trip min/avg/max = 0/43/47 ms PC>ping 192.168.80.11 Ping 192.168.80.11: 32 data bytes, Press Ctrl_C to break From 192.168.80.11: bytes=32 seq=1 ttl=125 time=47 ms From 192.168.80.11: bytes=32 seq=2 ttl=125 time=63 ms From 192.168.80.11: bytes=32 seq=3 ttl=125 time=78 ms From 192.168.80.11: bytes=32 seq=4 ttl=125 time=62 ms From 192.168.80.11: bytes=32 seq=5 ttl=125 time=94 ms --- 192.168.80.11 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 47/68/94 ms PC>ping 192.168.81.11 Ping 192.168.81.11: 32 data bytes, Press Ctrl_C to break From 192.168.81.11: bytes=32 seq=1 ttl=125 time=110 ms From 192.168.81.11: bytes=32 seq=2 ttl=125 time=78 ms From 192.168.81.11: bytes=32 seq=3 ttl=125 time=62 ms From 192.168.81.11: bytes=32 seq=4 ttl=125 time=79 ms From 192.168.81.11: bytes=32 seq=5 ttl=125 time=78 ms --- 192.168.81.11 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 62/81/110 ms PC-81-1能ping通其他主机 PC>ping 192.168.10.11 Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break Request timeout! From 192.168.10.11: bytes=32 seq=2 ttl=125 time=47 ms From 192.168.10.11: bytes=32 seq=3 ttl=125 time=94 ms From 192.168.10.11: bytes=32 seq=4 ttl=125 time=62 ms From 192.168.10.11: bytes=32 seq=5 ttl=125 time=78 ms --- 192.168.10.11 ping statistics --- 5 packet(s) transmitted 4 packet(s) received 20.00% packet loss round-trip min/avg/max = 0/70/94 ms PC>ping 192.168.30.11 Ping 192.168.30.11: 32 data bytes, Press Ctrl_C to break From 192.168.30.11: bytes=32 seq=1 ttl=125 time=94 ms From 192.168.30.11: bytes=32 seq=2 ttl=125 time=62 ms From 192.168.30.11: bytes=32 seq=3 ttl=125 time=63 ms From 192.168.30.11: bytes=32 seq=4 ttl=125 time=78 ms From 192.168.30.11: bytes=32 seq=5 ttl=125 time=63 ms --- 192.168.30.11 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 62/72/94 ms PC>ping 192.168.80.11 Ping 192.168.80.11: 32 data bytes, Press Ctrl_C to break From 192.168.80.11: bytes=32 seq=1 ttl=127 time=31 ms From 192.168.80.11: bytes=32 seq=2 ttl=127 time=47 ms From 192.168.80.11: bytes=32 seq=3 ttl=127 time=31 ms From 192.168.80.11: bytes=32 seq=4 ttl=127 time=47 ms From 192.168.80.11: bytes=32 seq=5 ttl=127 time=47 ms --- 192.168.80.11 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 31/40/47 ms PC>ping 10.1.1.10 Ping 10.1.1.10: 32 data bytes, Press Ctrl_C to break From 10.1.1.10: bytes=32 seq=1 ttl=254 time=31 ms From 10.1.1.10: bytes=32 seq=2 ttl=254 time=31 ms From 10.1.1.10: bytes=32 seq=3 ttl=254 time=47 ms From 10.1.1.10: bytes=32 seq=4 ttl=254 time=47 ms From 10.1.1.10: bytes=32 seq=5 ttl=254 time=31 ms --- 10.1.1.10 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 31/37/47 ms