静态路由与默认路由配置

实验原理:

路由分类

(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:          0Echo reply:                      0Unreachable:                     0Source quench:                   0Routing redirect:                0Echo request:                    0Router advert:                   0Router solicit:                  0Time exceed:                     0IP header bad:                   0Timestamp request:               0Timestamp 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:          0Echo reply:                      0Unreachable:                     0Source quench:                   0Routing redirect:                0Echo request:                    0Router advert:                   0Router solicit:                  0Time exceed:                     0IP header bad:                   0Timestamp request:               0Timestamp 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:          0Echo reply:                      0Unreachable:                     0Source quench:                   0Routing redirect:                0Echo request:                    0Router advert:                   0Router solicit:                  0Time exceed:                     0IP header bad:                   0Timestamp request:               0Timestamp reply:                 0#查看ip路由表
[LSW1]display IP routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: PublicDestinations : 8        Routes : 8        Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0192.168.10.0/24  Direct  0    0           D   192.168.10.1    Vlanif10192.168.10.1/32  Direct  0    0           D   127.0.0.1       Vlanif10192.168.12.0/24  Direct  0    0           D   192.168.12.1    Vlanif12192.168.12.1/32  Direct  0    0           D   127.0.0.1       Vlanif12192.168.30.0/24  Direct  0    0           D   192.168.30.1    Vlanif30192.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 2Interface                         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:          0Echo reply:                      0Unreachable:                     0Source quench:                   0Routing redirect:                0Echo request:                    0Router advert:                   0Router solicit:                  0Time exceed:                     0IP header bad:                   0Timestamp request:               0Timestamp 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:          0Echo reply:                      0Unreachable:                     0Source quench:                   0Routing redirect:                0Echo request:                    0Router advert:                   0Router solicit:                  0Time exceed:                     0IP header bad:                   0Timestamp request:               0Timestamp 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:          0Echo reply:                      0Unreachable:                     0Source quench:                   0Routing redirect:                0Echo request:                    0Router advert:                   0Router solicit:                  0Time exceed:                     0IP header bad:                   0Timestamp request:               0Timestamp reply:                 0Information request:             0[LSW2]display IP routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: PublicDestinations : 9        Routes : 9        Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface0.0.0.0/0   Static  60   0          RD   192.168.12.1    Vlanif12127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0192.168.12.0/24  Direct  0    0           D   192.168.12.2    Vlanif12192.168.12.2/32  Direct  0    0           D   127.0.0.1       Vlanif12192.168.80.0/24  Direct  0    0           D   192.168.80.1    Vlanif80192.168.80.1/32  Direct  0    0           D   127.0.0.1       Vlanif80192.168.81.0/24  Direct  0    0           D   192.168.81.1    Vlanif81192.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.11Ping 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) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 32/50/78 mstraceroute to 192.168.30.11, 8 hops max
(ICMP), press Ctrl+C to stop1  192.168.10.1   31 ms  32 ms  31 ms2  192.168.30.11   62 ms  47 ms  63 msPC>ping 192.168.80.11Ping 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) transmitted0 packet(s) received100.00% packet lossPC>ping 192.168.81.11Ping 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) transmitted0 packet(s) received100.00% packet loss

  将PC-30-1与PC-30-1、PC-80-1和PC-81-1通信:

PC>ping 192.168.10.11Ping 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) transmitted4 packet(s) received20.00% packet lossround-trip min/avg/max = 0/43/47 msPC>ping 192.168.80.11Ping 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) transmitted0 packet(s) received100.00% packet lossPC>ping 192.168.81.11Ping 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) transmitted0 packet(s) received100.00% packet loss

将PC-80-1与PC-10-1、PC-30-1和PC-81-1通信:

PC>ping 192.168.81.11Ping 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) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 47/59/94 msPC>ping 192.168.30.11Ping 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) transmitted0 packet(s) received100.00% packet lossPC>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) transmitted0 packet(s) received100.00% packet loss

将PC-81-1与PC-10-1、PC-30-1和PC-80-1通信: 

PC>ping 192.168.30.11Ping 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) transmitted0 packet(s) received100.00% packet lossPC>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) transmitted0 packet(s) received100.00% packet lossPC>ping 192.168.80.11Ping 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) transmitted5 packet(s) received0.00% packet lossround-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: PublicDestinations : 10       Routes : 10       Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0192.168.10.0/24  Direct  0    0           D   192.168.10.1    Vlanif10192.168.10.1/32  Direct  0    0           D   127.0.0.1       Vlanif10192.168.12.0/24  Direct  0    0           D   192.168.12.1    Vlanif12192.168.12.1/32  Direct  0    0           D   127.0.0.1       Vlanif12192.168.30.0/24  Direct  0    0           D   192.168.30.1    Vlanif30192.168.30.1/32  Direct  0    0           D   127.0.0.1       Vlanif30192.168.80.0/24  Static  60   0          RD   192.168.12.2    Vlanif12192.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         Interface192.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: PublicDestinations : 7        Routes : 7        Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface0.0.0.0/0   Static  60   0          RD   192.168.12.1    Vlanif12127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0192.168.12.0/24  Direct  0    0           D   192.168.12.2    Vlanif12192.168.12.2/32  Direct  0    0           D   127.0.0.1       Vlanif12192.168.80.0/24  Direct  0    0           D   192.168.80.1    Vlanif80192.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.11Ping 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) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 78/100/110 msPC>ping 192.168.10.11Ping 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) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 62/74/78 ms

 PC-10-1ping 其他三个PC

PC>ping 192.168.30.11Ping 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) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 31/46/63 msPC>ping 192.168.80.11Ping 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) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 62/74/94 msPC>ping 192.168.81.11Ping 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) transmitted4 packet(s) received20.00% packet lossround-trip min/avg/max = 0/93/125 msPC>

用PC-10-1 ping PC-80-1如下图所示:现在就是完整的通信过程


 这里补充一下静态路由和默认路由的区别

1.配置方式:

静态路由:需要管理员手动配置路由表中的每一条路由规则。每个网络和子网都需要指定下一跳的目标地址或出接口。
默认路由:也称为缺省路由或0.0.0.0/0 网络,是一条特殊的静态路由规则,用于指示当路由表中没有匹配的路由规则时,将数据包发送到默认网关

2.路由信息的数量
静态路由:需要手动配置每个网络之间的路由规则,因此路由表会包含多条明确的路由信息。
默认路由:只需要一条默认路由规则来处理所有未知目的地的数据包,因此路由表中的信息较少。

3.灵活性和可扩展性:
静态路由:需要手动配置和更新路由表,适用于小型网络或需要细粒度控制的情况。但在大型网络中,随着网络规模的扩大,手动配置和管理所有路由规则变得繁琐且不易维护。
默认路由:提供了一种简单的路由配置方式,特别适用于大型网络或需要简化路由管理的情况。它将所有未知目的地的数据包都发送到默认网关,减少了路由表的复杂性和管理工作。


这是示例的文件,可自取:

链接:https://pan.baidu.com/s/1YvSjBdWS0kZJkjAyC2bEdA 
提取码:lfcq

不过还是提倡自己多打几遍,多理解,多抓包!!💖💖💖💖

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/86259.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

priority_queue 模拟与用法

priority_queue 用法 priority_queue priority_queue 模拟 #include <vector> namespace sjy {//仿函数 1template <typename T>class Less{public:bool operator()(const T& x, const T& y){return x < y;}};//仿函数 2template <typename T>…

一些常见的算法

常见算法有很多种&#xff0c;以下列举了一些常见的算法&#xff1a; 堆排序算法&#xff1a;是一种利用堆这种数据结构所设计的一种排序算法。哈希算法&#xff1a;哈希算法将任意长度的二进制值映射为较短的固定长度的二进制值&#xff0c;这个小的二进制值称为哈希值&#…

stm32_标准库_中断_按键点灯|蜂鸣器

配置流程 需要对AFIO、EXTI、NVIC、GPIOB进行配置形成通路将中断连接至CPU APB2总线连接的寄存器 LED灯代码 #include "stm32f10x.h" // Device header #include "Delay.h"GPIO_InitTypeDef GIPO_InitStruct;//结构体配置GPIO EXTI_InitTypeDef EXTI_…

算法 数据流的中位数-(大顶堆小顶堆+冒泡排序)

牛客网: BM48 题目: 得到数据流的中位数 思路: (1) 冒泡排序: 每次插入元素时&#xff0c;进行冒泡排序&#xff0c;将当前值与前一值比较&#xff0c;当前值较小时与前一元素交换&#xff0c;直至不小于前一元素时结束。 (2) 大小顶堆: 设置两个堆min为大顶堆(最大值在堆顶…

WPS文件找回怎么做?文件恢复,4个方法!

“我平时习惯了用wps来记录一些工作心得或重点&#xff0c;不知道什么原因&#xff0c;有些很重要的文件莫名不见了&#xff0c;有什么方法可以帮我找回wps文件吗&#xff1f;” wps作一个常用的办公软件&#xff0c;有效的提高了我们的工作效率。在日常使用wps时&#xff0c;可…

非常详细的git-flow分支管理流程配置及使用

非常详细的git-flow分支管理流程配置及使用。 git-flow有两个涵义,一个是指软件开发领域的版本管理流程Gitflow。另一个是指git命令工具git flow。 目前业界主流的版本管理流程是Gitflow 和 trunk-based。 Gitflow流行的比较早。但是目前的流行度要低于 trunk-based模式工作…

RocketMQ 相关文档

官方文档&#xff1a;为什么选择RocketMQ | RocketMQ (apache.org) Rocketmq 5.x架构介绍文章&#xff1a;终于&#xff01;RocketMQ发布5.0版本&#xff1a;架构大重构&#xff0c;代码变更比例高达60%-腾讯云开发者社区-腾讯云 (tencent.com)

爬虫中出现OSError: [WinError 193] %1 不是有效的 Win32 应用程序。

如果出现了 OSError: [WinError 193] %1 不是有效的 Win32 应用程序。那可能是你的Chromedriver版本和Chrome版本不一致。 我是花钱买的&#xff0c;这里免费分享给大家Chrome116版本对应的ChromeDriver 资源发布了&#xff0c;如果有需要私信我要吧

debian安装qq及更新

文章目录 一、安装二、卸载QQ三、更新 一、安装 1.下载Linux QQ安装包 wget https://dldir1.qq.com/qqfile/qq/QQNT/c6032ac7/linuxqq_3.1.0-9332_amd64.deb2.安装软件包 apt install ./linuxqq_3.1.0-9332_amd64.deb3.终端启动QQ qq二、卸载QQ apt remove linuxqq三、更新…

qt功能自己创作

按钮按下三秒禁用 void MainWindow::on_pushButton_5_clicked(){// 锁定界面setWidgetsEnabled(ui->centralwidget, false);// 创建一个定时器&#xff0c;等待3秒后解锁界面QTimer::singleShot(3000, this, []() {setWidgetsEnabled(ui->centralwidget, true);;//ui-&g…

MySQL8.0版安装教程 + Workbench可视化配置教程(史上最细、一步一图解)

文章目录 一、安装MySQL1、选择版本&#xff0c;点击“Download”进行下载2、双击下载好的安装包&#xff0c;点击运行3、选择安装类型为“Custom”4、依次进行选择&#xff0c;选到MySQL Servers 8.0.33 -X64&#xff0c;点击向右的箭头5、选中MySQL Servers 8.0.33 -X64&…

Mysql004:用户管理

前言&#xff1a;本章节讲解的是mysql中的用户管理&#xff0c;包括&#xff08;管理数据用户&#xff09;、&#xff08;控制数据库的访问权限&#xff09;。 目录 1. 查询用户 2. 创建用户 3. 修改用户密码 4. 删除用户 5. 权限控制 1. 查询用户 在mysql数据库中&#xff0…

【通信误码】python实现-附ChatGPT解析

1.题目 通信误码 时间限制: 1s 空间限制: 32MB 限定语言: 不限 题目描述: 信号传播过程中会出现一些误码,不同的数字表示不同的误码ID, 取值范围为1~65535,用一个数组“记录误码出现的情况。 每个误码出现的次数代表误码频度, 请找出记录中包含频度最高误码的最小子数组长度…

OpenCV自学笔记二十二:绘图及交互

一、绘图基础 下面是关于OpenCV绘图基础函数的说明和举例&#xff1a; 1. cv2.line()&#xff1a;绘制直线 cv2.line(img, pt1, pt2, color, thickness, lineType) - img: 需要绘制直线的图像。 - pt1: 直线起始点坐标。 - pt2: 直线结束点坐标。 - color: 直线颜色&…

Java客户端_zkclient库操作Zookeeper

使用zookeeper遇到问题&#xff1a; 重复注册watchersession失效重连异常处理&#xff08;删除节点不能有子节点&#xff0c;新增节点必须有父节点等&#xff09; zkclient是Github上一个开源的Zookeeper客户端&#xff0c;在Zookeeper原生 API接口之上进行了包装&#xff0c;是…

古代有没有电子元器件?

手机&#xff0c;电脑&#xff0c;电视等等电子产品&#xff0c;无时无刻充斥在我们的生活中&#xff0c;如果有一天突然没有了这些功能多样的电子产品&#xff0c;估计大部分人都会一时之间难以适应。 这就好比正在上网&#xff0c;结果突然被人断了网&#xff0c;导致无网络连…

【学习笔记】[AGC064C] Erase and Divide Game

有点难&#x1f605;&#xff0c;看到比自己低一级的选手场切这道题就更绷不住了&#x1f607; 考虑 从低到高位 建立 trie \text{trie} trie 树&#xff0c;但是因为是对反串建立的&#xff0c;所以编号连续的点在 trie \text{trie} trie 树上的位置是分散的&#x1f605; …

基于vue3 + ant-design 自定义SVG图标iconfont的解决方案;ant-design加载本地iconfont.js不显示图标问题

基于vue3 ant-design 自定义SVG图标iconfont的解决方案&#xff1b; ant-design加载本地iconfont.js不显示图标问题 一、准备工作 1、首先去阿里巴巴矢量图标库自定义添加自己的图标&#xff1b;网站地址https://www.iconfont.cn/ 整个步骤是&#xff1a;选择图标–添加到项…

变压器(电抗器) 红外测温作业指导书

1 范围 本标准化作业指导书规定了变压器(电抗器)红外测温(一般检测)工作的准备工作、测温流程图、 现场操作方法、测温周期和标准、测温记录管理等要求。 本标准化作业指导书适用于指导变压器(电抗器)红外测温的一般性检测工作。 2 规范性引用文件 下列文件对于本文件的应用…