拓扑如下(其中,R1 E2/0连接loopbackE2/1连接VPCS1):
这是我们刚刚启动后,windows下的路由状态,在这里我只截取了相关参数,:
C:\>route print
Active Routes:
Network Destination    Netmask      Gateway         Interface        Metric
      0.0.0.0            0.0.0.0        10.16.19.1      10.16.19.115       20
      0.0.0.0            0.0.0.0        192.3.3.1         192.3.3.3         30
Default Gateway:        10.16.19.1
======================================================
Ok,我们如何将loopback接口作为默认路由呢(即如何将192.3.3.1作为默认路由)?
先学习个命令route,以下是系统给出的解释,我就加个注释而已!!!
C:\>route prinet
Manipulates network routing tables.
ROUTE [-f] [-p] [command [destination]
                  [MASK netmask]  [gateway] [METRIC metric]  [IF interface]
 
  -f           Clears the routing tables of all gateway entries.  If this is
               used in conjunction with one of the commands, the tables are
               cleared prior to running the command.    //清除路由
  -p           When used with the ADD command, makes a route persistent across
               boots of the system. By default, routes are not preserved
               when the system is restarted. Ignored for all other commands,
               which always affect the appropriate persistent routes. This
               option is not supported in Windows 95.   //永久添加
  command      One of these:
                 PRINT     Prints  a route                   //查看
                 ADD       Adds    a route                 //增加
                 DELETE    Deletes a route                   //删除
                 CHANGE    Modifies an existing route       //变更网关和跳数
  destination     Specifies the host.
  MASK         Specifies that the next parameter is the 'netmask' value.
  netmask      Specifies a subnet mask value for this route entry.
               If not specified, it defaults to 255.255.255.255.
  gateway      Specifies gateway.
  interface    the interface number for the specified route.
  METRIC       specifies the metric, ie. cost for the destination.
 
All symbolic names used for destination are looked up in the network database
file NETWORKS. The symbolic names for gateway are looked up in the host name
database file HOSTS.
 
If the command is PRINT or DELETE. Destination or gateway can be a wildcard,
(wildcard is specified as a star '*'), or the gateway argument may be omitted.
 
If Dest contains a * or ?, it is treated as a shell pattern, and only
matching destination routes are printed. The '*' matches any string,
and '?' matches any one char. Examples: 157.*.1, 157.*, 127.*, *224*.
Diagnostic Notes:
    Invalid MASK generates an error, that is when (DEST & MASK) != DEST.
    Example> route ADD 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1
             The route addition failed: The specified mask parameter is invalid
 (Destination & Mask) != Destination.
 
Examples
    > route PRINT
    > route ADD 157.0.0.0 MASK 255.0.0.0  157.55.80.1 METRIC 3 IF 2
destination^     ^mask  ^gateway   metric^     ^ Interface^
      If IF is not given, it tries to find the best interface for a given gateway.
    > route PRINT
    > route PRINT 157*          .... Only prints those matching 157*
    > route CHANGE 157.0.0.0 MASK 255.0.0.0 157.55.80.5 METRIC 2 IF 2
CHANGE is used to modify gateway and/or metric only.  仅用于修改网关和跳数
    > route PRINT
    > route DELETE 157.0.0.0
> route PRINT
 
命令总结:
route –f/-p command destination mask netmask gateway metric Metric if Interface
 
基本应用格式:
route command destination mask netmask gateway metric Metric
-f 清除所有网关入口的路由表。如果该参数与某个命令组合使用,路由表将在运行命令前清除。
-p add 命令一起使用时使路由具有永久性。该参数与 add 命令一起使用时,将使路由在系统引导程序之间持久存在。默认情况下,系统重新启动时不保留路由。与 print 命令一起使用时,显示已注册的持久路由列表。忽略其他所有总是影响相应持久路由的命令。
Command 指定您想运行的命令 (Add/Change/Delete/Print)
 
用实际例子分析:
C:\>route print
Active Routes:
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 50 56 c0 00 08 ...... VMware Virtual Ethernet Adapter for VMnet8
0x3 ...00 50 56 c0 00 01 ...... VMware Virtual Ethernet Adapter for VMnet1
0x10007 ...02 00 4c 4f 4f 50 ...... Microsoft Loopback Adapter
======================================================
Network Destination    Netmask      Gateway         Interface        Metric
      0.0.0.0            0.0.0.0        10.16.19.1      10.16.19.115       20
      0.0.0.0            0.0.0.0        192.3.3.1         192.3.3.3         30
Default Gateway:        10.16.19.1
======================================================
当我们启用loopback接口一段时间后,会发现上不了网的情况发生,如何解决呢:
如何修改缺省路由?
C:\>route change 0.0.0.0 mask 0.0.0.0 192.3.3.1 metric 5
C:\>route print 0*
Active Routes:
Network Destination    Netmask         Gateway       Interface    Metric
      0.0.0.0             0.0.0.0          192.3.3.1       192.3.3.3      5
Default Gateway:         192.3.3.1
C:\>
 
C:\>ping 192.3.3.1
Pinging 192.3.3.1 with 32 bytes of data:
Reply from 192.3.3.1: bytes=32 time=5ms TTL=255
Ok!!!
 
如何配置永久路由?
C:\>route -p add 0.0.0.0 mask 0.0.0.0  10.16.19.1  metric 20
C:\>route print 0*
======================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0       10.16.19.1    10.16.19.115       20
          0.0.0.0          0.0.0.0        192.3.3.1       192.3.3.3       5
Default Gateway:         192.3.3.1
 
如何删除路由?
C:\>route delete 0*
The route deletion failed: 参数不正确。
C:\>route delete 0
C:\>route print 0*
======================================================
Active Routes:
  None
Persistent Routes:
  None
 
如何为2个默认路由指定转发接口:
参数:if Interface为可以访问目标的接口指定接口索引。就是说发往甲的数据用接口A,发往乙的用接口B。这一条在一个网卡捆绑了多个同网段的IP时应用非常有效。比如你捆绑了*.1 *.2两个地址,你可以指定某一条主机路由是用*.1发,某一条是用*.2发。不然,默认情况下,发往子网的都是用一个IP发。
若要获得一个接口列表和它们相应的接口索引,使用 route print 命令的显示功能。可以使用十进制或十六进制值进行接口索引。
C:\>route add 0.0.0.0 mask 0.0.0.0 10.16.19.1 metric 20 if 0x4
C:\>route add 0.0.0.0 mask 0.0.0.0 192.3.3.1 metric 20 if 0x10007
 
C:\>route print 0*
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 50 56 c0 00 08 ...... VMware Virtual Ethernet Adapter for VMnet8
0x3 ...00 50 56 c0 00 01 ...... VMware Virtual Ethernet Adapter for VMnet1
0x4 ...00 18 8b cf 01 b1 ...... Broadcom 440x 10/100 Integrated Controller -
据包计划程序微型端口
0x5 ...00 1b 77 13 24 f9 ...... Intel(R) PRO/Wireless 3945ABG Network Connection
 - 数据包计划程序微型端口
0x10007 ...02 00 4c 4f 4f 50 ...... Microsoft Loopback Adapter
======================================================
Active Routes:
Network Destination    Netmask       Gateway       Interface      Metric
     0.0.0.0              0.0.0.0        10.16.19.1     10.16.19.115    20
     0.0.0.0              0.0.0.0        192.3.3.1       192.3.3.3       20
Default Gateway:         192.3.3.1
======================================================
Persistent Routes:
最后,如果要恢复原有网络配置!
可以禁用掉所有网卡,在启用 ; 也可使用命令恢复缺省路由
可以建立个批处理,来启用或删除路由我想这个就自己写了吧,命令上面全有!!!