栏目分类:
子分类:
返回
文库吧用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
文库吧 > IT > 前沿技术 > 物联网 > 通讯技术

计算机网络静态配置(ip,静态路由)

通讯技术 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

计算机网络静态配置(ip,静态路由)

静态路由:

路由器和路由器之间的链路 --- 骨干链路(总线链路),一般不放置用户

路由器获取未知网段的方法:静态路由/动态路由
静态路由:由网络管理员手写的路由条目
动态路由:所有路由器上运行相同的一种的动态路由协议,之后通过路由器之间的沟通,协商最终生成的路由条目

 首先给出地址要求:PC1能ping通PC2

192.168.1.0/24 为pc1和R1之间的广播地址,192.168.2.0/24为R1和R2之间的广播地址,192.168.3.0/24为R1和R4之间的广播地址,192.168.4.0/24为R2和R3之间的广播地址,192.168.5.0/24为R4和R3之间的广播地址,192.168.6.0/24为R3和PC2之间的广播地址。

(图中用不同色段区分)

注意静态地址的配置时以要连接的网段和到达的最近的以联通端口(以R1为例:R1要联通PC2的网段192.168.6.0/24,此时R1可以选择的可联通的最近端口为:R2的G0/0/0口:ip地址为192.168.2.2和R4的G0/0/1口:ip地址为192.168.3.2)

开始配置接口的地址地段(以R1为例子):

//先配置ip地址
system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]interface  g0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.1.1 24
Nov  7 2021 11:17:58-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R1-GigabitEthernet0/0/0]q
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]ip address 192.168.2.1 24
[R1-GigabitEthernet0/0/1]q
[R1]interface g0/0/2
[R1-GigabitEthernet0/0/2]ip address 192.168.3.1 24
Nov  7 2021 11:19:00-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/2 has entered the UP state. 
[R1-GigabitEthernet0/0/2]q
//然后配置静态地址
[R1]ip route-static 192.168.4.0 ?
  INTEGER<0-32>     Length of IP address mask
  IP_ADDR  IP address mask
[R1]ip route-static 192.168.4.0 24 ?
  IP_ADDR  Gateway address
  Cellular          Cellular interface
  GigabitEthernet   GigabitEthernet interface
  NULL              NULL interface
  vpn-instance      Destination VPN-Instance for Gateway address
[R1]ip route-static 192.168.4.0 24 192.168.2.2
[R1]ip route-static 192.168.6.0 24 192.168.2.2
[R1]ip route-static 192.168.5.0 24 192.168.2.2
[R1]

然后依次去配置其他路由器的地址(静态地址配置为先要联通的网段,然后是掩码,和端口)。

查看ip静态路由(以R1为例):

pre --- 优先级 --- 当两条路由条目的目标网段相同时,仅加载优先级高的路由条目到路由器中
 优先级数值越小,优先级反而越高(0-255)
 [华为设备:直连路由优先级默认为0,静态路由优先级默认为60] 

注意要进行保存操作!!!(save)

PC1的ip地址为192.168.1.10, PC2的ip地址为192.168.6.10,在配置完成后PC1进行ping操作:

在配置中可能会产生换回路由,导致宕机,两个路由器瘫痪(但是数据有TTL(存活时间)前文ip报文中有介绍)TTL初始值:64,128,255(如果ttl在(0-64则为64,65-128则为128,129-255为255))

关于静态路由的拓展配置: 1.负载均衡:

当路由器访问同一个目标具有多条开销相似!!!的路径后,设备可以将流量拆分后延多条路径同时传输,以达到叠加带宽的效果。

Destination/Mask    Proto           Pre          Cost      Flags         NextHop         Interface
192.168.6.0/24          Static          60           0          RD           192.168.4.2     GigabitEthernet
                                  Static          60           0          RD           192.168.5.2     GigabitEthernet

此时去往192.168.6.0/24网段有两条路径,均为直达(且都只各经过一个路由器转发),数据会拆分到达。如果强行去写负载均衡(两条路开销不一样情况下),则会导致路由环路!!!

2环回接口:

路由器配置的虚拟接口,一般用于实验配置路由(现实接口不可行时,配置虚拟接口)

配置如图的路由器


sysy	
sys
Nov  9 2021 13:44:14-08:00 Huawei %%01IFPDT/4/IF_STATE(l)[0]:Interface GigabitEt
hernet0/0/0 has turned into UP state.
sys	
system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sysna	
[Huawei]sysname  R1
[R1]inter	
[R1]interface  loo	
[R1]interface  LoopBack 0
[R1-LoopBack0]ip ad	
[R1-LoopBack0]ip address  192.168.1.0 24
Error: The specified IP address is invalid.
[R1-LoopBack0]ip address 192.168.1.1 24
[R1-LoopBack0]q
[R1]inter	
[R1]interface  loo	
[R1]interface  LoopBack  1
[R1-LoopBack1]ip add	
[R1-LoopBack1]ip address  192.168.2.1 24
[R1-LoopBack1]q
[R1]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
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
    192.168.1.0/24  Direct  0    0           D   192.168.1.1     LoopBack0
    192.168.1.1/32  Direct  0    0           D   127.0.0.1       LoopBack0
  192.168.1.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
    192.168.2.0/24  Direct  0    0           D   192.168.2.1     LoopBack1
    192.168.2.1/32  Direct  0    0           D   127.0.0.1       LoopBack1
  192.168.2.255/32  Direct  0    0           D   127.0.0.1       LoopBack1
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

 此时R1的环回地址和接口地址分别为:

 这个时候loopback0可以当做192.168.1.0/24内任意的网段用,继续去配置静态路由

[R1]ip route-static 192.168.3.0 24 12.0.0.2
[R1]ip route-static 192.168.4.0 24 12.0.0.2

此时去在R1的路由器去pingR2的192.168.3.1

3.手工汇总


当路由器可以访问多个连续的子网时,若均通过相同的下一跳,可以将这些网段进行汇总计算,
之后仅编写到达汇总网段的静态路由(以达成减少路由条目,提高转发效率)

根据上图的数据可以去进行数据的汇总,192.168.1.0/24和192.168.2.0/24汇总为192.168.0.0/22,但是此时会产生一条R1没有的网段192.168.3.0/24和192.168.0.0/24,如果尝试去ping这两个网段,则会是产生路由黑洞。(前十条为ping192.168.1.1此时有回包,后五条为ping192.168.0.1此时数据包没有回复,产生路由黑洞)

4.路由黑洞


在汇总中,若包含网络内实际不存在的网段时,可能使流量有去无回,造成链路资源浪费
eg:192.168.1.0/24和192.168.2.0/24汇总为192.168.0.0/22(此时192.168.0.0/24不存在)
            合理的子网划分可以减少黑洞产生
如果为192.168.0.0/24和192.168.1.0/24汇总为192.168.0.0/23(此时没有产生多余网段)
如果为192.168.0.0/24,192.168.1.0/24,192.168.2.0/24汇总为192.168.0.0/22,此时会产生黑洞网段为192.168.3.0/24


                           
5.缺省路由  

(一般家用路由器使用缺省路由来连接运营商的路由器)
一条不限定目标的路由条目;查表时,若本地所有路由均未匹配,则将匹配缺省路由

[R1]ip route-static 0.0.0.0 0  12.0.0.2
[R1]disp	
[R1]display   ip  r	
[R1]display   ip  rd-filter
[R1]display   ip  routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 14       Routes : 14       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   Static  60   0          RD   12.0.0.2        GigabitEthernet
0/0/0
       12.0.0.0/24  Direct  0    0           D   12.0.0.1        GigabitEthernet
0/0/0
       12.0.0.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
     12.0.0.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
    192.168.1.0/24  Direct  0    0           D   192.168.1.1     LoopBack0
    192.168.1.1/32  Direct  0    0           D   127.0.0.1       LoopBack0
  192.168.1.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
    192.168.2.0/24  Direct  0    0           D   192.168.2.1     LoopBack1
    192.168.2.1/32  Direct  0    0           D   127.0.0.1       LoopBack1
  192.168.2.255/32  Direct  0    0           D   127.0.0.1       LoopBack1
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

如果路由黑洞和缺省路由相遇,会产生环路!!!

此时R2ping192.168.0.1,发出5个包,都显示超时丢包,但是在抓包显示后,都是在TTL置零以后,丢弃包。

原理显示:因为R1有汇总192.168.0.0/22,但是没有配置 192.168.0.0网段,由于R1配置一个缺省路由0.0.0.0,此时数据又转发给R2,R2又再次转发给R1,如此循环产生环路。

 

6.空接口路由:

在黑洞路由器上配置一条到达汇总网段指向空接口的路由。
    空接口:虚拟接口,null0口,路由器的一个虚拟接口,如果一条路由的出接口为空接口,则代表将该流量丢弃。
    路由器匹配原则:精准匹配(最长掩码匹配)原则   匹配最长的掩码

        原因:因为192.168.0.1匹配汇总192.168.0.0/22,信息无法丢弃,路由器R1只有192.168.1.0/24和192.168.2.0,所以信息不匹配,此时只能匹配192.168.0.0/22 null0,所以只能从null0丢弃。 但是如果发生192.168.1.1,此时匹配192.168.1.0/24和null0,根据最长匹配原则,匹配192.1681.0/24

[R1]ip route-static 192.168.0.0 22 null0
7.浮动静态路由(--备份)


通过修改默认的优先级来做到备份 

[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]ip add	
[R1-GigabitEthernet0/0/0]ip address   12.0.0.1  24
Nov  9 2021 21:04:31-08:00 R1 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R1-GigabitEthernet0/0/0]inter g0/0/1
[R1-GigabitEthernet0/0/1]ip add	
[R1-GigabitEthernet0/0/1]ip address 21.0.0.1  24
Nov  9 2021 21:04:54-08:00 R1 %%01IFNET/4/LINK_STATE(l)[3]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 
[R1-GigabitEthernet0/0/1]q
[R1]inter	
[R1]interface l 0
[R1-LoopBack0]ip add	
[R1-LoopBack0]ip address   192.168.1.1 24
[R1-LoopBack0]q
[R1]ip rou	
[R1]ip route
[R1]ip route-static  192.168.2.0 24  12.0.0.2
[R1]ip route-static 192.168.2.0 24 21.0.0.2 p	
[R1]ip route-static 192.168.2.0 24 12.0.0.2  preference ?
  INTEGER<1-255>  Preference value range
[R1]ip route-static 192.168.2.0 24 12.0.0.2  preference 80
Info: Succeeded in modifying route.
[R1]disp	
[R1]display   ip r	
[R1]display   ip rd-filter
[R1]display   ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 14       Routes : 14       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       12.0.0.0/24  Direct  0    0           D   12.0.0.1        GigabitEthernet
0/0/0
       12.0.0.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
     12.0.0.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       21.0.0.0/24  Direct  0    0           D   21.0.0.1        GigabitEthernet
0/0/1
       21.0.0.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
     21.0.0.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
    192.168.1.0/24  Direct  0    0           D   192.168.1.1     LoopBack0
    192.168.1.1/32  Direct  0    0           D   127.0.0.1       LoopBack0
  192.168.1.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
    192.168.2.0/24  Static  80   0          RD   12.0.0.2        GigabitEthernet
0/0/0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

[R1]display ip routing-table protocol  static      //查看静态路由协议的显示

 优先级为越大越小(1-255)

此时键入shutdown,删除指令,*down为手动关闭

[R1-GigabitEthernet0/0/0]shutdown 
Nov  9 2021 21:23:07-08:00 R1 %%01IFPDT/4/IF_STATE(l)[0]:Interface GigabitEthern
et0/0/0 has turned into DOWN state.
[R1-GigabitEthernet0/0/0]
[R1-GigabitEthernet0/0/0]
Nov  9 2021 21:23:07-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the DOWN state. 
[R1-GigabitEthernet0/0/0]dis	
[R1-GigabitEthernet0/0/0]discard
[R1-GigabitEthernet0/0/0]display  ip   inter	
[R1-GigabitEthernet0/0/0]display  ip   interface   b
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              12.0.0.1/24          *down      down      
GigabitEthernet0/0/1              21.0.0.1/24          up         up        
GigabitEthernet0/0/2              unassigned           down       down      
LoopBack0                         192.168.1.1/24       up         up(s)     
NULL0                             unassigned           up         up(s) 

此时去往192.168.2.1路由段的道路只有21.0.0.1,优先级为120。

Routing Tables: Public
         Destinations : 11       Routes : 11       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       21.0.0.0/24  Direct  0    0           D   21.0.0.1        GigabitEthernet
0/0/1
       21.0.0.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
     21.0.0.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
    192.168.1.0/24  Direct  0    0           D   192.168.1.1     LoopBack0
    192.168.1.1/32  Direct  0    0           D   127.0.0.1       LoopBack0
  192.168.1.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
    192.168.2.0/24  Static  120  0          RD   21.0.0.2        GigabitEthernet
0/0/1
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

ping -a 192.168.1.1 192.168.2.1

(用192.168.1.1去ping192.168.2.1) 

转载请注明:文章转载自 www.wk8.com.cn
本文地址:https://www.wk8.com.cn/it/852633.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 wk8.com.cn

ICP备案号:晋ICP备2021003244-6号