静态路由与默认路由配置

实验原理:

路由分类

(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,一经查实,立即删除!

相关文章

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

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

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模式工作…

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…

古代有没有电子元器件?

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

基于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 规范性引用文件 下列文件对于本文件的应用…

积木报表 JimuReport v1.6.2-GA5版本发布—高危SQL漏洞安全加固版本

项目介绍 一款免费的数据可视化报表&#xff0c;含报表和大屏设计&#xff0c;像搭建积木一样在线设计报表&#xff01;功能涵盖&#xff0c;数据报表、打印设计、图表报表、大屏设计等&#xff01; Web 版报表设计器&#xff0c;类似于excel操作风格&#xff0c;通过拖拽完成报…

Linux复习-安装与熟悉环境(一)

这里写目录标题 虚拟机ubuntu系统配置镜像Linux命令vi编辑器3个模式光标命令vi模式切换命令vi拷贝与粘贴命令vi保存和退出命令vi的查找命令vi替换命令 末行模式复制、粘贴、剪切gcc编译器 虚拟机 VMware16 官网下载&#xff1a;vmware官网 网盘下载&#xff1a; 链接&#xff…

Pytorch 深度学习实践 day01(背景)

准备 线性代数&#xff0c;概率论与数理统计&#xff0c;Python理解随机变量和分布之间的关系 人类智能和人工智能 人类智能分为推理和预测 推理&#xff1a;通过外界信息的输入&#xff0c;来进行的推测 预测&#xff1a;例如&#xff0c;看到一个真实世界的实体&#xff…

idea更改java项目名

做了一个普通的java项目&#xff08;使用socket进行网络通信的练手项目&#xff09;&#xff0c;需要更改项目名&#xff0c;更改过程记录在这里。 修改项目名可能会出现很多错误&#xff0c;建议先备份当前项目 1.在idea里&#xff0c;右键项目名——》选择Refactor——》选择…

容器技术所涉及Linux内核关键技术

目录 一、容器技术前世今生 1.1 1979年 — chroot 1.2 2000年 — FreeBSD Jails 1.3 2001年 — Linux VServer 1.4 2004年 — Solaris容器 1.5 2005年 — OpenVZ 1.6 2006年 — Process容器 1.7 2007年 — Control Groups 1.8 2008年 — LXC 1.9 2011年 — Warden 1…

Nginx 代理 MySQL 连接

文章目录 Nginx 代理 MySQL 连接1. 前言2. 部署 Nginx&#xff0c;MySQL3. ngx_stream_core_module 配置方式3.1 stream3.2 server3.3 listen3.4 配置示例 4. 限制访问 IP4.1 allow4.2 deny4.3 配置示例 5. 综合案例 Nginx 代理 MySQL 连接 原文地址&#xff1a;https://mp.wei…

如何用好免费的ChatGPT

如何用好免费的ChatGPT 前言ChatGPT使用入口在线体验地址&#xff1a;点我体验 ChatGPT介绍ChatGPT初级使用技巧初级使用技巧&#xff1a;清晰明了的问题表达 ChatGPT中级使用语法中级使用语法&#xff1a;具体化问题并提供背景信息 ChatGPT高级使用高级使用&#xff1a;追问、…

JMeter:断言之响应断言

一、断言的定义 断言用于验证取样器请求或对应的响应数据是否返回了期望的结果。可以是看成验证测试是否预期的方法。 对于接口测试来说&#xff0c;就是测试Request/Response&#xff0c;断言即可以针对Request进行&#xff0c;也可以针对Response进行。但大部分是对Respons…

推动统一供应链“度量衡”,上汽大通突破传统拥抱SaaS生态

中国汽车市场规模已连续14年位居世界第一&#xff0c;目前占世界汽车份额31%。近年来&#xff0c;物联网、人工智能、电池等技术的快速发展&#xff0c;也为中国从汽车大国逐步迈向汽车强国注入巨大动力。在新一轮的汽车产业变革中&#xff0c;构建一个更智能、更高效协同的供应…

[Linux入门]---git命令行的基本使用

文章目录 1.git使用gitee仓库创建git使用测试ignore文件 1.git使用 git是一款对文件进行版本控制的软件&#xff0c;gitee、github是基于git软件搭建的网站&#xff0c;是可以对代码进行托管的平台&#xff1b;github是国外的网站&#xff0c;访问慢&#xff0c;不稳定&#xf…

RobotFramework+Eclispe环境安装篇

【软件测试面试突击班】如何逼自己一周刷完软件测试八股文教程&#xff0c;刷完面试就稳了&#xff0c;你也可以当高薪软件测试工程师&#xff08;自动化测试&#xff09; 环境安装是学习任何一个新东西的第一步&#xff0c;这一步没走舒坦&#xff0c;那后面就没有心情走下去了…