静态路由与默认路由配置

news2024/11/18 11:42:21

实验原理:

路由分类

(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

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

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

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

相关文章

分布式搜索引擎01

1.初识elasticsearch 1.1.了解ES 1.1.1.elasticsearch的作用 elasticsearch是一款非常强大的开源搜索引擎,具备非常多强大功能,可以帮助我们从海量数据中快速找到需要的内容 例如: 在GitHub搜索代码 在电商网站搜索商品 在百度搜索答案 在打车软件搜索附近的车 1.1.2.ELK…

程序员的快乐如此简单

最近在GitHub上发起了一个关于Beego框架的小插件的开源仓库&#xff0c;这一举动虽然看似微小&#xff0c;但其中的快乐和意义却是无法用言语表达的。 Beego是一个开源的Go语言Web框架&#xff0c;它采用了MVC架构模式&#xff0c;并集成了很多常用的功能和中间件。小插件是指…

Linux chmod命令——修改权限信息

我们可以使用chmod命令&#xff0c;修改文件、文件夹的权限信息。注意&#xff0c;只有文件、文件夹的所属用户或root用户可以修改。 chmod [-R] 权限 文件或文件夹 -R&#xff0c;对文件夹内的全部内容应用同样的操作 例如&#xff1a; chmod urwx,grx,ox hello.txt &…

工业余能资源评价方法 标准学习

声明 本文是学习GB-T 1028-2018 工业余能资源评价方法. 而整理的学习笔记,分享出来希望更多人受益,如果存在侵权请及时联系我们 1 范围 本标准界定了工业余能相关术语&#xff0c;规定了工业余能的分类和评价方法。 本标准适用于工业余能资源的评价。 2 术语和定义 下列术…

oracle执行计划中,同一条语句块,在不同情况下执行计划不一样问题。子查询,union 导致索引失效。

场景&#xff1a; 需要获取部分数据集(视图)的业务时间最大值&#xff0c;希望只通过一条语句获取多个的最大值。 则使用select (视图1业务时间最大值),(视图2业务时间最大值),(视图3业务时间最大值) from dual 程序执行过程中&#xff0c;发现语句执行较慢&#xff0c;则进行s…

描述符——配置描述符

描述符定义 描述符实现 /*** brief USB configuration descriptor.*/ typedef struct __attribute__ ((packed)) {uint8_t bLength ; /**< Size of this descriptor in bytes. */uint8_t bDescriptorType ; /**< CONFIGURATION Descriptor Type. */ui…

使用ElementUI完成登入注册的跨域请求,结合vue-cli搭建的SPA项目,减少冗余代码提升开发效率

目录 一、跨域的概述 ( 1 ) 讲述 ( 2 ) 特点 如何跨域: 二、ElementUI ( 1 ) 导入 ( 2 ) 搭建 ( 3 ) 页面 三、数据交互 ( 1 ) 安装相关模块 安装模块 引用模块 ( 2 ) axios的get请求 ( 3 ) axios的post请求 四、注册功能 带来的收获 一、跨域的概述 …

安卓实现网格布局的效果

文章目录 页面子项布局 Activity适配器 运行结果其他文章 页面 RecyclerView是Android开发中常用的列表控件之一&#xff0c;可以用于展示大量数据以及实现各种布局效果。本文章使用RecyclerView的GridLayoutManager来实现网格布局&#xff0c;显示指定列数。 首先&#xff0c…

25. 图论 - 路径和算法

文章目录 拓展:顶点和边的互换最短路径问题Dijkstra算法Hi, 你好。我是茶桁。 在充分了解图的概念,构成以及种类之后,我们要开始进入稍微有点难度的部分了。这节课,咱们来了解一下路径和Dijkstra算法。 拓展:顶点和边的互换 在这节课正式开始之前,我们对上一节课稍微扩…

Java笔记:认识运行时数据区

1. 运行时数据区概述 1.1 JVM运行时数据区规范 JVM虚拟机组成&#xff1a;方法区(类信息)、堆(伊甸园、老年代、永久代:new的对象等)、虚拟机栈、程序计数器、本地方法栈1.方法区和堆是内存共享的 2.虚拟机栈、本地方法栈、程序计数器是内存不共享的3.方法区&#xff1a;类信息…

描述符——接口描述符

描述符定义 描述符实现 /*** brief USB interface descriptor.*/ typedef struct __attribute__ ((packed)) {uint8_t bLength ; /**< Size of this descriptor in bytes. */uint8_t bDescriptorType ; /**< INTERFACE Descriptor Type. */uint8_t bIn…

MySQL数据库——索引(3)-索引语法(创建索引、查看索引、删除索引、案例演示),SQL性能分析(SQL执行频率,慢查询日志)

目录 索引语法 创建索引 查看索引 删除索引 案例演示 SQL性能分析 SQL执行频率 慢查询日志 索引语法 创建索引 CREATE [ UNIQUE | FULLTEXT ] INDEX index_name ON table_name (index_col_name,... ) ; 查看索引 SHOW INDEX FROM table_name ; 删除索引 DROP INDEX …

AD拼板技巧

AD拼板设置 如图&#xff0c;有一个需要拼板的PCB&#xff0c;想要在生产是拼接生产&#xff0c;节省材料。 操作如下&#xff1a; 1、全选如下&#xff0c;按复制CtrlC。 2、把输入法调整至英文&#xff0c;按快捷键E&#xff08;先&#xff09;&#xff0c; A&#xff08;后…

开发工具MobaXterm(终极终端)

MobaXterm 又名 MobaXVT&#xff0c;是一款增强型终端、X 服务器和 Unix 命令集(GNU/ Cygwin)工具箱。 常用SSH客户端介绍&#xff1a; SSH 为 Secure Shell 的缩写&#xff0c;是目前较可靠&#xff0c;专为远程登录会话和其他网络服务提供安全性的协议。利用 SSH 协议可以有…

【1993. 树上的操作】

来源&#xff1a;力扣&#xff08;LeetCode&#xff09; 描述&#xff1a; 给你一棵 n 个节点的树&#xff0c;编号从 0 到 n - 1 &#xff0c;以父节点数组 parent 的形式给出&#xff0c;其中 parent[i] 是第 i 个节点的父节点。树的根节点为 0 号节点&#xff0c;所以 par…

C++中的Template

模板的概念 建立通用的模具&#xff0c;大大提高复用性 模板不可直接使用 函数模板 函数模板语法 函数模板作用&#xff1a; 建立一个通用函数&#xff0c;其函数返回值类型和形参类型可以不具体制定&#xff0c;用一个虚拟的类型来代表。 语法&#xff1a; template&l…

小程序社区团购demo

概述 实现了用户登录或者手机号&#xff0c;加入团长&#xff0c;邀请团长&#xff0c;各种佣金明细等页面 详细 需求&#xff1a; 根据市场信息反馈&#xff0c;社区团购比较火&#xff0c;有流量的用户可以推广页面 实现了功能&#xff1a; 实现了用户微信登录自动获取…

vue之 h() 函数

前言 Vue推荐在绝大数情况下使用模板来创建HTML&#xff0c;然后一些特殊的场景&#xff0c;你真的需要JavaScript的完全编程的能力&#xff0c;这个时候你可以使用渲染函数 &#xff0c;它比模板更接近编译器&#xff1b; h()函数是什么 Vue在生成真实的DOM之前&#xff0c…

如何用好免费的ChatGPT

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

Vue中如何进行表格排序与过滤

Vue中如何进行表格排序与过滤 在Vue.js中&#xff0c;表格是一个常见的数据展示方式。很多时候&#xff0c;我们需要对表格中的数据进行排序和过滤&#xff0c;以提供更好的用户体验。本文将介绍如何在Vue中实现表格的排序和过滤功能&#xff0c;并提供相关的代码示例。 准备工…