静态路由及默认路由

拓扑图

 

静态路由及默认路由_第1张图片

场景,通过配置,使R1,R2,R3之间互联互通

1、配置R1,R2,R3设备名称和IP地址

R1配置

system-view

sysname r1

interface serial 4/0/0

ip address 10.0.12.1 24

description this port connect to r2-s4/0/0 //与路由器2serial接口进行连接通信

quit

inteface gigabitethernet 0/0/0

ip address 10.0.13.1 24

description this port connect to r3-g0/0/0 //与路由器3接口进行连接通信

interface loopback 0 //进入回环接口地址

ip address 10.0.1.1 24

 

配置完成后检查配置是否生效

display current-configuration

R2的配置

system-view

sysname r2

interface serial 4/0/0

ip address 10.0.12.2 24

description this port connect to r1-s4/0/0

quit

interface serial 4/0/1

ip address 10.0.23.2 24

desciption this port connect to r3-s4/0/1

quit

interface loopback 0

ipaddress 10.0.2.2 24

display current-configuration

R3的配置

system-view

sysname r3

interface serial 4/0//1

ip address 10.0.23.3 24

description this port connect to r2-s4/0/1

quit

interface gigabitethernet 0/0/0

ip address 10.0.13.3 24

description this port connect to r1-g0/0/0

quit

interface loopback 0

ip address 10.0.3.3 24

dis current-configuration

配置完成后各端口下IP地址及信息

R1 serial 4/0/0 10.0.12.1 int gi 0/0/0 10.0.13.1 loopback 10.0.1.1

R2 serial 4/0/0 10.0.12.2 serial 4/0/1 10.0.23.2 loopback 10.0.2.2

R3 serial 4/0/1 10.0.23.3 int gi 0/0/0 10.0.13.3 loopback 10.0.3.3

R1 S4/0/0-----R2 S4/0/0 R1 int gi 0/0/0 --------R3 int gi 0/0/0

R3 S4/0/1-----R2 S4/0/1 R3 int gi 0/0/0-----R1 int gi 0/0/0

R2 S4/0/0-----R1 S4/0/0 R2 S4/0/1 --------R3 S4/0/1

 

基础配置完记得保存

在缺省下,save y

 

2、网络配置好后,看各网络的连通性

1、R1-R2 在R1上pingR2的地址 ping 10.0.12.2

2、R1-R3 在R1上pingR3的地址 ping 10.0.13.3

3、R2-R3 在R2上pingR3的地址 ping 10.0.23.3

3、R2上网络贯通性

此时 R2上ping 10.0.13.3 和10.0.3.3 是不通的,

加过路由之后,网络变通,

ip route-static 10.0.13.0 24 10.0.23.3

ip route-static 10.0.3.0 2 24 10.0.23.3

形成第二条路由,并设置优先级

先在R1上设置 R1和R3之间路由通路,后设置路由路径,从R2 serial 4/0/0到 R1上,然后在到R3

[r1] ip route-static 10.0.3.0 24 10.0.13.3 //这一点有点不明白,希望后期能整明白

[r2] ip route-static 10.0.13.0 24 serial 4/0/0 preference 80

[r2] ip route-static 10.0.3.0 24 serial 4/0/0 preference 80

[r3] ip route-static 10.0.12.0 24 10.0.13.1 //R3上配置路由到13.1

加上路由后,验证是否路由通 |

[r2] ping 10.0.13.3 |

[r2] ping 10.0.3.3 |

分别看路径,看看路径如何走的 |

tracert 10.0.13.3 tracert 10.0.3.3 //思考,为何如此走 !!

验证第二条路由是否通的

断开R2-R3之间连接,登录进去R2后,输入以下命令

interface serial 4/0/1

shutdown //启动端口 undo shutdown

此时在看到R3是否是通的

[r2] ping 10.0.13.3

[r2] ping 10.0.3.3

分别看路径,看看路径如何走的

tracert 10.0.13.3 tracert 10.0.3.3

4、在R1上配置路由,实现网络互通

先在R2上打开关闭的端口

测试R1到R3的连通性

ping 10.0.23.3 =>测试结果为不通

=> R1缺少到10.0.23.3的路由

加上路由 ip route-static 0.0.0.0 0.0.0.0 10.0.13.3

此时在测试R1到R3直接连通性

ping 10.0.23.3 => 已通

R1上备用路由配置

[r1] ip route-static 0.0.0.0 0.0.0.0 10.0.12.2 preference 80

[r3] ip route-static 10.0.12.0 24 10.0.23.2 preference 80

检查路由配置是否生效 display ip routing-table

关闭R1-R3之间链路,检查此时路由,对比有何不同。

 

思考:

1.华为路由器下ping参数,和win下有很多不同

2.默认情况下发出去的ping数据包,源地址多少

3.此时所有网段是否已通

4.如果只实现互通,那种配置方式是最简洁的配置?

5.配置静态路由时,可以使用参数,“下一条的IP地址”,也可使用参数“接口标识”,有何不同?

 

解答(个人理解):

1、 使用ping ?可以看到各种参数,可一一对照理解

2、我们使用ping -i 可以指定出去的网口。默认走优先级最高

3、

目前不太理解,以后求解。先把路由记录下来

R1 serial 4/0/0 10.0.12.1 int gi 0/0/0 10.0.13.1 loopback 10.0.1.1

R2 serial 4/0/0 10.0.12.2 serial 4/0/1 10.0.23.2 loopback 10.0.2.2

R3 serial 4/0/1 10.0.23.3 int gi 0/0/0 10.0.13.3 loopback 10.0.3.3

 

R1

dis ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 16       Routes : 16       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   Static  60   0          RD   10.0.13.3       GigabitEthernet
0/0/0
       10.0.1.0/24  Direct  0    0           D   10.0.1.1        LoopBack0
       10.0.1.1/32  Direct  0    0           D   127.0.0.1       LoopBack0
     10.0.1.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
       10.0.3.0/24  Static  60   0          RD   10.0.13.0       GigabitEthernet
0/0/0
      10.0.12.0/24  Direct  0    0           D   10.0.12.1       Serial4/0/0
      10.0.12.1/32  Direct  0    0           D   127.0.0.1       Serial4/0/0
      10.0.12.2/32  Direct  0    0           D   10.0.12.2       Serial4/0/0
    10.0.12.255/32  Direct  0    0           D   127.0.0.1       Serial4/0/0
      10.0.13.0/24  Direct  0    0           D   10.0.13.1       GigabitEthernet
0/0/0
      10.0.13.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
    10.0.13.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
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

R2

dis ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 17       Routes : 17       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.0.2.0/24  Direct  0    0           D   10.0.2.2        LoopBack0
       10.0.2.2/32  Direct  0    0           D   127.0.0.1       LoopBack0
     10.0.2.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
       10.0.3.0/24  Static  60   0          RD   10.0.23.3       Serial4/0/1
      10.0.12.0/24  Direct  0    0           D   10.0.12.2       Serial4/0/0
      10.0.12.1/32  Direct  0    0           D   10.0.12.1       Serial4/0/0
      10.0.12.2/32  Direct  0    0           D   127.0.0.1       Serial4/0/0
    10.0.12.255/32  Direct  0    0           D   127.0.0.1       Serial4/0/0
      10.0.13.0/24  Static  60   0          RD   10.0.23.3       Serial4/0/1
      10.0.23.0/24  Direct  0    0           D   10.0.23.2       Serial4/0/1
      10.0.23.2/32  Direct  0    0           D   127.0.0.1       Serial4/0/1
      10.0.23.3/32  Direct  0    0           D   10.0.23.3       Serial4/0/1
    10.0.23.255/32  Direct  0    0           D   127.0.0.1       Serial4/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
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

R3

dis ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 15       Routes : 15       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.0.3.0/24  Direct  0    0           D   10.0.3.3        LoopBack0
       10.0.3.3/32  Direct  0    0           D   127.0.0.1       LoopBack0
     10.0.3.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
      10.0.12.0/24  Static  60   0          RD   10.0.13.1       GigabitEthernet
0/0/0
      10.0.13.0/24  Direct  0    0           D   10.0.13.3       GigabitEthernet
0/0/0
      10.0.13.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
    10.0.13.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
      10.0.23.0/24  Direct  0    0           D   10.0.23.3       Serial4/0/1
      10.0.23.2/32  Direct  0    0           D   10.0.23.2       Serial4/0/1
      10.0.23.3/32  Direct  0    0           D   127.0.0.1       Serial4/0/1
    10.0.23.255/32  Direct  0    0           D   127.0.0.1       Serial4/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
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

4、最近路径

5、目前不知,等待以后补充

 

 

你可能感兴趣的:(路由器,交换机)