实验:
IP地址配置情况:
左边 R1:
FastEthernet0/0
1.1.1.3 255.0.0.0 secondary
1.1.1.5 255.0.0.0 secondary
1.1.1.1 255.0.0.0
Serial1/0    192.168.1.1
Serial1/1    192.168.2.1
右边 R2:
虚拟接口 Loopback0    3.3.3.3 
 Serial1/0  192.168.1.2
 Serial1/1   192.168.2.2
 
R1 配置:
interface Serial1/0
 ip address 192.168.1.1 255.255.255.0
 clock rate 64000
 
interface Serial1/1
 ip address 192.168.2.1 255.255.255.0
 clock rate 64000
 
router rip
 network 1.0.0.0
 network 192.168.1.0
 network 192.168.2.0
access-list 1 permit 1.1.1.1
access-list 2 permit 1.1.1.3
 
route-map ming permit 10
 match ip address 1
 set interface Serial1/0

route-map ming permit 20
 match ip address 2
 set interface Serial1/1
ip local policy route-map ming
 
右边R2 :
interface Loopback0
 ip address 3.3.3.3 255.0.0.0

interface Serial1/0
 ip address 192.168.1.2 255.255.255.0

interface Serial1/1
 ip address 192.168.2.2 255.255.255.0

router rip
 network 3.0.0.0
 network 192.168.1.0
 network 192.168.2.0
验证:
在R1# debug ip .
r2#ping
Protocol [ip]:
Target IP address: 3.3.3.3
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: yes
Source address or interface: 1.1.1.1
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
*Feb 28 22:24:19.851: IP: s=1.1.1.1 (local), d=3.3.3.3 (Serial1/0), len 100, policy routed
*Feb 28 22:24:19.851: IP: local to Serial1/0 192.168.1.2
*Feb 28 22:24:19.939: IP: s=1.1.1.1 (local), d=3.3.3.3, len 100, policy match
*Feb 28 22:24:19.939: IP: route map ming, item 10, permit
*Feb 28 22:24:19.939: IP: s=1.1.1.1 (local), d=3.3.3.3 (Serial1/0), len 100, policy routed
*Feb 28 22:24:19.939: IP: local to Serial1/0 192.168.1.2
*Feb 28 22:24:19.959: IP: s=1.1.1.1 (local), d=3.3.3.3, len 100, policy match
*Feb 28 22:24:19.959: IP: route map ming, item 10, permit
*Feb 28 22:24:19.959: IP: s=1.1.1.1 (local), d=3.3.3.3 (Serial1/0), len 100, policy routed
*Feb 28 22:24:19.963: IP: local to Serial1/0 192.168.1.2
*Feb 28 22:24:27.423: IP: s=192.168.2.1 (local), d=255.255.255.255 (Serial1/1), len 72, policy rejected -- normal forwarding
r2#
*Feb 28 22:24:40.575: IP: s=192.168.1.1 (local), d=255.255.255.255 (Serial1/0), len 72, policy rejected -- normal forwarding
*Feb 28 22:24:47.051: IP: s=1.1.1.1 (local), d=255.255.255.255, len 92, policy match
*Feb 28 22:24:47.051: IP: route map ming, item 10, permit
*Feb 28 22:24:47.051: IP: s=1.1.1.1 (local), d=255.255.255.255 (Serial1/0), len 92, policy routed
*Feb 28 22:24:47.055: IP: local to Serial1/0 255.255.255.255
*Feb 28 22:24:56.199: IP: s=192.168.2.1 (local), d=255.255.255.255 (Serial1/1), len 72, policy rejected -- normal forwarding
*Feb 28 22:25:08.735: IP: s=192.168.1.1 (local), d=255.255.255.255 (Serial1/0), len 72, policy rejected -- normal forwarding
r2#ping
Protocol [ip]:
Target IP address: 3.3.3.3
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: yes
Source address or interface: 1.1.1.3
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.3
!!!!!
*Feb 28 22:17:22.439: IP: route map ming, item 20, permit
*Feb 28 22:17:22.439: IP: s=192.168.1.1 (local), d=255.255.255.255 (Serial1/1), len 72, policy routed
*Feb 28 22:30:46.963: IP: local to Serial1/0 255.255.255.255
*Feb 28 22:30:48.355: IP: s=192.168.1.1 (local), d=255.255.255.255 (Serial1/0), len 72, policy rejected -- normal forwarding