一、创建实验环境
1、路由器R1\R2 交换机SW1\SW2 PC1\PC2
#配置端口IP地址
R1 #interface gigabitethernet0/0/1
undo shutdown
ip address 192.168.2.1 255.255.255.0

      #interface gigabitethernet0/0/2
       undo shutdown
       ip address 192.168.4.1 255.255.255.0

      #interface gigabitethernet0/0/0
       undo shutdown
       ip address 192.168.1.1 255.255.255.0

   #配置静态路由和优先级
       ip route-staeic 192.168.3.0 255.255.255.0 192.168.2.2 preference 110
       ip route-staeic 192.168.3.0 255.255.255.0 192.168.4.2 preference 120

R2 #interface gigabitethernet0/0/0
undo shutdown
ip address 192.168.2.2 255.255.255.0

      #interface gigabitethernet0/0/2
       undo shutdown
       ip address 192.168.4.2 255.255.255.0

      #interface gigabitethernet0/0/1
       undo shutdown
       ip address 192.168.3.1 255.255.255.0

    #配置静态路由和优先级
       ip route-staeic 192.168.1.0 255.255.255.0 192.168.2.1 preference 110
       ip route-staeic 192.168.1.0 255.255.255.0 192.168.4.1 preference 120

    #查看静态路由表 dis ip routing  路由表只会显示优先级高的静态路由,如果优先级高的线路坏了
     那么优先级低的路由表才会出现在路由表中,它们是不会同时出现在路由表中的