实验原理:
路由分类
(1)根据目的网络的不同,路由可以划分为:
特定网络路由:目的网络为目的主机所在网络的IP地址,其子网掩码表示的前缀长度为32位(对于IPv4地址),或128位(对于IPv6地 址)。采用特定网络路由可以减少路由表中路由的数量,便于路由的查找和维护。
特定主机路由:目的网络为目的主机的IP地址,其子网掩码表示 的前缀长度为32位(对于IPv4地址),或128位(对于IPv6地址)。采用特定主机路由可使网络管理人员更方便地控制网络和测试网络,同时也可在需要考虑某种安全问题时采用这种特定主机路由。在对网络的连接或路由表进行排错时,指明到某一台主机的特殊路由就十分有用了。
默认路由(Default Route):也被称为缺省路由。默认路由是一 种特殊的路由,是匹配所有目的地的路由,在路由表中未找到匹配的路 由时才使用该路由。默认路由可以减小路由表所占用的空间和搜索路由 表所用的时间,可以简化网络的配置。如果路由表中没有默认路由,且 IP分组的目的地址不在路由表中,则路由器丢弃该分组,并向源端返回 一个ICMP报文,报告该目的地址或网络不可达。在路由表中,默认路由 以目的网络为0.0.0.0、子网掩码也为0.0.0.0的路由形式出现。通常情 况下,通过手工方式配置默认路由,但有些时候,也可以使路由选择协议生成默认路由。通过手工方式配置的默认路由被称为静态默认路由。 可以不配置默认路由,若配置,则只能配置一条默认路由。
(2)根据路由是否随网络状态的变化而变化,路由可以划分为:
静态路由:路由不随网络状态的变化而变化。其特点是简单和开 销较小,但不能及时适应网络状态的变化,需要人工配置。当网络发生 故障或者拓扑发生变化后,必须手工修改配置。与动态路由相比,静态 路由使用更少的带宽,并且不占用CPU资源来计算和分析路由的更新。 静态路由可以有多条。
静态路由在不同网络环境中有不同的目的:
•当网络结构比较简单时,只需配置静态路由就可以使网络正常工作。
•在复杂网络环境中,配置静态路由可以改进网络的性能,并可节省带宽。
动态路由:路由随网络状态的变化而变化。其特点是能较好地适 应网络状态的变化,但实现较为复杂,开销比较大。动态路由适用于较 复杂的大网络。动态路由由路由选择协议依据某种路由选择算法计算得到。
(3)根据目的网络与路由器是否直接相连,路由可以划分为:
直连路由:路由器与目的网络直接相连,可以直接交付分组,不 需要再通过其他路由器进行转发。
间接路由:路由器与目的网络不是直接相连,至少经过一个路由 器才能到达目的网络,需要将分组转发给下一跳路由器。
(4)根据目的地址类型的不同,路由还可以分为:
单播路由:路由的目的地址是一个单播IP地址。
组播路由:路由的目的地址是一个组播IP地址。
路由选择协议
路由表由路由选择协议建立和维护。路由选择协议依据某种路由算 法进行路由选择,并将计算得到的路由写入路由表。互联网采用的路由 选择协议主要是自适应的(即动态的)分布式路由选择协议。
互联网被划分为许多较小的自治系统(Autonomous System, AS)。互联网采用分层次的路由选择。互联网的路由选择协议划分为两大类:
(1)内部网关协议IGP(Interior Gateway Protocol):在一个 自治系统内部使用的路由选择协议,与互联网中其他自治系统选用什么 路由选择协议无关。目前这类路由选择协议使用得最多,如RIP和OSPF 协议等。
(2)外部网关协议EGP(External Gateway Protocol):自治系 统之间使用的路由选择协议,目前使用最多的外部网关协议是BGP-4
案例:
PC配置如下
LSW1的配置
#批量创建vlan 10,30和12
[LSW1]vlan batch 10 30 12
Info: This operation may take a few seconds. Please wait for a moment...done.
#将g0/0/9加入vlan10
[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
#将g0/0/13加入vlan30
[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
#将端口g0/0/24为trunk
[LSW1]interface g0/0/24
[LSW1-GigabitEthernet0/0/24]port link-type trunk
[LSW1-GigabitEthernet0/0/24]port trunk allow-pass vlan all
[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) GE0/0/24(U)
10 common UT:GE0/0/9(U)
TG:GE0/0/24(U)
12 common TG:GE0/0/24(U)
30 common UT:GE0/0/13(U)
TG: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
12 enable default enable disable VLAN 0012
30 enable default enable disable VLAN 0030
#查看端口类型及所属vlan
[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 trunk 1 1-4094
[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 12
[LSW1-Vlanif12]ip address 192.168.12.1 24
[LSW1-Vlanif12]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
#查看vlanif端口ip配置
[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: 0
Timestamp reply: 0
[LSW1]display IP inter 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: 0
Timestamp reply: 0
[LSW1]display IP inter vlanif 12
Vlanif12 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.12.1/24
Broadcast address : 192.168.12.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
#查看ip路由表
[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.12.0/24 Direct 0 0 D 192.168.12.1 Vlanif12
192.168.12.1/32 Direct 0 0 D 127.0.0.1 Vlanif12
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
LSW2的配置
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname LSW2
[LSW2]vlan batch
Sep 17 2023 15:45:01-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.80
Info: This operation may take a few seconds. Please wait for a moment...done.
[LSW2]
[LSW2]undo info-center enable
Info: Information center is disabled.
[LSW2]vlan batch 80 81 12
Info: This operation may take a few seconds. Please wait for a moment...done.
[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 trunk
[LSW2-GigabitEthernet0/0/24]port trunk allow-pass vlan all
[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) GE0/0/24(U)
12 common TG:GE0/0/24(U)
80 common UT:GE0/0/15(U)
TG:GE0/0/24(U)
81 common UT:GE0/0/17(U)
TG:GE0/0/24(U)
VID Status Property MAC-LRN Statistics Description
--------------------------------------------------------------------------------
1 enable default enable disable VLAN 0001
12 enable default enable disable VLAN 0012
80 enable default enable disable VLAN 0080
81 enable default enable disable VLAN 0081
[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 hybrid 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 trunk 1 1-4094
[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]interface vlanif 12
[LSW2-Vlanif12]ip address 192.168.12.2 24
[LSW2-Vlanif12]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 5
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 2
Interface IP Address/Mask Physical Protocol
MEth0/0/1 unassigned down down
NULL0 unassigned up up(s)
Vlanif1 unassigned up down
Vlanif12 192.168.12.2/24 up up
Vlanif80 192.168.80.1/24 up up
Vlanif81 192.168.81.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 : 503, bytes : 30180, multicasts : 0
output packets : 597, bytes : 34388, 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: 0
Timestamp reply: 0
[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 12
Vlanif12 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.12.2/24
Broadcast address : 192.168.12.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
Information request: 0
[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.12.1 Vlanif12
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.12.0/24 Direct 0 0 D 192.168.12.2 Vlanif12
192.168.12.2/32 Direct 0 0 D 127.0.0.1 Vlanif12
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
将PC-10-1与PC-30-1、PC-80-1和PC-81-1通信:
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=78 ms
From 192.168.30.11: bytes=32 seq=2 ttl=127 time=32 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=47 ms
From 192.168.30.11: bytes=32 seq=5 ttl=127 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 = 32/50/78 ms
traceroute to 192.168.30.11, 8 hops max
(ICMP), press Ctrl+C to stop
1 192.168.10.1 31 ms 32 ms 31 ms
2 192.168.30.11 62 ms 47 ms 63 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-30-1与PC-30-1、PC-80-1和PC-81-1通信:
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=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=47 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
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
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-80-1与PC-10-1、PC-30-1和PC-81-1通信:
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=94 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=62 ms
From 192.168.81.11: bytes=32 seq=5 ttl=127 time=47 ms
--- 192.168.81.11 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 47/59/94 ms
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 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-81-1与PC-10-1、PC-30-1和PC-80-1通信:
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 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.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=63 ms
From 192.168.80.11: bytes=32 seq=3 ttl=127 time=63 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 = 47/53/63 ms
在交换机LSW1中配置静态路由
<LSW1>sys
Enter system view, return user view with Ctrl+Z.
#目的网络为192.168.80.0,子网掩码为255.255.255.0,下一跳地址为192.168.12.2
[LSW1]ip route-static 192.168.80.0 24 192.168.12.2
#与上面同理
[LSW1]ip route-static 192.168.81.0 24 192.168.12.2
[LSW1]display IP routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 10 Routes : 10
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.12.0/24 Direct 0 0 D 192.168.12.1 Vlanif12
192.168.12.1/32 Direct 0 0 D 127.0.0.1 Vlanif12
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.80.0/24 Static 60 0 RD 192.168.12.2 Vlanif12
192.168.81.0/24 Static 60 0 RD 192.168.12.2 Vlanif12
[LSW1]display IP routing-table 192.168.80.0
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.80.0/24 Static 60 0 RD 192.168.12.2 Vlanif12
用PC-10-1 ping PC-80-1,对LSW1的0/0/24抓包
而用PC-80-1 ping PC-10-1 ,对LSW2的0/0/24抓包,与上图对比可以看出
数据包需要通过来回两个方向的传输才能完成一个完整的通信。
如果只在一侧上配置了路由,则只能实现单向的通信,即只能从具备路由功能的终端 PC-10-1到达另一个不具备路由功能的终端 PC-80-1。当由终端PC-80-1向其它网络的主机发送数据时,就会出现路由不可达的情况。所以需要在另一端配置回程路由
<LSW2>sys
Enter system view, return user view with Ctrl+Z.
#目的地址是0.0.0.0 子网掩码是0.0.0.0 下一跳地址是192.168.12.1
[LSW2]ip route-static 0.0.0.0 0.0.0.0 192.168.12.1
#查看交换机IP路由表
[LSW2]display IP routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 Static 60 0 RD 192.168.12.1 Vlanif12
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.12.0/24 Direct 0 0 D 192.168.12.2 Vlanif12
192.168.12.2/32 Direct 0 0 D 127.0.0.1 Vlanif12
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
有了回程路由,接下来再用PC-10-1 ping PC-80-1就可以ping通了,同样PC-80-1也可以ping PC-10-1了
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=126 time=110 ms
From 192.168.80.11: bytes=32 seq=2 ttl=126 time=78 ms
From 192.168.80.11: bytes=32 seq=3 ttl=126 time=110 ms
From 192.168.80.11: bytes=32 seq=4 ttl=126 time=109 ms
From 192.168.80.11: bytes=32 seq=5 ttl=126 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 = 78/100/110 ms
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=126 time=78 ms
From 192.168.10.11: bytes=32 seq=2 ttl=126 time=78 ms
From 192.168.10.11: bytes=32 seq=3 ttl=126 time=62 ms
From 192.168.10.11: bytes=32 seq=4 ttl=126 time=78 ms
From 192.168.10.11: bytes=32 seq=5 ttl=126 time=78 ms
--- 192.168.10.11 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 62/74/78 ms
PC-10-1ping 其他三个PC
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=47 ms
From 192.168.30.11: bytes=32 seq=2 ttl=127 time=62 ms
From 192.168.30.11: bytes=32 seq=3 ttl=127 time=63 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=31 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/46/63 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=126 time=94 ms
From 192.168.80.11: bytes=32 seq=2 ttl=126 time=62 ms
From 192.168.80.11: bytes=32 seq=3 ttl=126 time=62 ms
From 192.168.80.11: bytes=32 seq=4 ttl=126 time=62 ms
From 192.168.80.11: bytes=32 seq=5 ttl=126 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 = 62/74/94 ms
PC>ping 192.168.81.11
Ping 192.168.81.11: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.81.11: bytes=32 seq=2 ttl=126 time=125 ms
From 192.168.81.11: bytes=32 seq=3 ttl=126 time=94 ms
From 192.168.81.11: bytes=32 seq=4 ttl=126 time=93 ms
From 192.168.81.11: bytes=32 seq=5 ttl=126 time=63 ms
--- 192.168.81.11 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 0/93/125 ms
PC>
用PC-10-1 ping PC-80-1如下图所示:现在就是完整的通信过程
这里补充一下静态路由和默认路由的区别
1.配置方式:
静态路由:需要管理员手动配置路由表中的每一条路由规则。每个网络和子网都需要指定下一跳的目标地址或出接口。
默认路由:也称为缺省路由或0.0.0.0/0 网络,是一条特殊的静态路由规则,用于指示当路由表中没有匹配的路由规则时,将数据包发送到默认网关
2.路由信息的数量:
静态路由:需要手动配置每个网络之间的路由规则,因此路由表会包含多条明确的路由信息。
默认路由:只需要一条默认路由规则来处理所有未知目的地的数据包,因此路由表中的信息较少。
3.灵活性和可扩展性:
静态路由:需要手动配置和更新路由表,适用于小型网络或需要细粒度控制的情况。但在大型网络中,随着网络规模的扩大,手动配置和管理所有路由规则变得繁琐且不易维护。
默认路由:提供了一种简单的路由配置方式,特别适用于大型网络或需要简化路由管理的情况。它将所有未知目的地的数据包都发送到默认网关,减少了路由表的复杂性和管理工作。
这是示例的文件,可自取:
链接:https://pan.baidu.com/s/1YvSjBdWS0kZJkjAyC2bEdA
提取码:lfcq
不过还是提倡自己多打几遍,多理解,多抓包!!💖💖💖💖