HELPME: BGP + Route Map + Next Hop.
by David Sudjiman ~ January 23rd, 2007. Filed under: Cisco, helpme.I have two routers that connected back-to-back using two serials. I also have each e0 on each router (R1 and R2) configured. both routers are using BGP AS 1 and BGP as 2, respectively. What I’m trying to do next is to make any ICMP packets from R1’s e0 going to path R1E0-R1S1-R2S1-R2E0. I’m using route-map and next hop to achieve this.
The problem is why can’t I use ip policy route-map on the interface yet I have to use ip LOCAL policy route-map to do this?

These are the configurations for both routers.
R1#sh run ! hostname R1 ! interface Ethernet0 ip address 10.10.10.1 255.255.255.0 ip policy route-map FROM-10.10.10.1-TO-20.20.20.1 ! interface Serial0 ip address 131.108.1.1 255.255.255.252 no fair-queue clockrate 56000 ! interface Serial1 ip address 131.108.1.5 255.255.255.252 clockrate 56000 ! router bgp 1 bgp log-neighbor-changes network 10.10.10.0 mask 255.255.255.0 neighbor 131.108.1.2 remote-as 2 neighbor 131.108.1.6 remote-as 2 ! access-list 100 permit icmp host 10.10.10.1 host 20.20.20.1 route-map FROM-10.10.10.1-TO-20.20.20.1 permit 10 match ip address 100 set ip next-hop 131.108.1.6 ! end
R2#sh run ! hostname R2 ! interface Ethernet0 ip address 20.20.20.1 255.255.255.0 ip policy route-map FROM-20.20.20.1-TO-10.10.10.1 ! interface Serial0 ip address 131.108.1.2 255.255.255.252 no fair-queue ! interface Serial1 ip address 131.108.1.6 255.255.255.252 ! router bgp 2 bgp log-neighbor-changes network 20.20.20.0 mask 255.255.255.0 neighbor 131.108.1.1 remote-as 1 neighbor 131.108.1.5 remote-as 1 ! access-list 100 permit icmp host 20.20.20.1 host 10.10.10.1 route-map FROM-20.20.20.1-TO-10.10.10.1 permit 10 match ip address 100 set ip next-hop 131.108.1.4 ! end
Based on the above configuration I’m expecting whether I can have my icmp packets go through R1E0-R1S1-R2S1-R2E0.
R1#sh ip bgp BGP table version is 3, local router ID is 10.10.10.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 10.10.10.0/24 0.0.0.0 0 32768 i * 20.20.20.0/24 131.108.1.6 0 0 2 i *> 131.108.1.2 0 0 2 i
R1#sh access-list 100
Extended IP access list 100
permit icmp host 10.10.10.1 host 20.20.20.1
R1#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
20.0.0.0/24 is subnetted, 1 subnets
B 20.20.20.0 [20/0] via 131.108.1.2, 00:06:12
10.0.0.0/24 is subnetted, 1 subnets
C 10.10.10.0 is directly connected, Ethernet0
131.108.0.0/30 is subnetted, 2 subnets
C 131.108.1.4 is directly connected, Serial1
C 131.108.1.0 is directly connected, Serial0
R1#debug ip policy
Policy routing debugging is on
R1#ping
Protocol [ip]:
Target IP address: 20.20.20.1
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 10.10.10.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 20.20.20.1, timeout is 2 seconds:
Packet sent with a source address of 10.10.10.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/37/40 ms
R1#u all
All possible debugging has been turned off
R1#debug ip packet
IP packet debugging is on
R1#ping
Protocol [ip]:
Target IP address: 20.20.20.1
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 10.10.10.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 20.20.20.1, timeout is 2 seconds:
Packet sent with a source address of 10.10.10.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 52/52/52 ms
00:18:41: IP: tableid=0, s=10.10.10.1 (local), d=20.20.20.1 (Serial0), routed via RIB
00:18:41: IP: s=10.10.10.1 (local), d=20.20.20.1 (Serial0), len 100, sending
00:18:41: IP: tableid=0, s=20.20.20.1 (Serial0), d=10.10.10.1 (Ethernet0), routed via RIB
00:18:41: IP: s=20.20.20.1 (Serial0), d=10.10.10.1, len 100, rcvd 4
00:18:41: IP: tableid=0, s=10.10.10.1 (local), d=20.20.20.1 (Serial0), routed via RIB
00:18:41: IP: s=10.10.10.1 (local), d=20.20.20.1 (Serial0), len 100, sending
00:18:41: IP: tableid=0, s=20.20.20.1 (Serial0), d=10.10.10.1 (Ethernet0), routed via RIB
00:18:41: IP: s=20.20.20.1 (Serial0), d=10.10.10.1, len 100, rcvd 4
00:18:41: IP: tableid=0, s=10.10.10.1 (local), d=20.20.20.1 (Serial0), routed via RIB
00:18:41: IP: s=10.10.10.1 (local), d=20.20.20.1 (Serial0), len 100, sending
00:18:41: IP: tableid=0, s=20.20.20.1 (Serial0), d=10.10.10.1 (Ethernet0), routed via RIB
00:18:41: IP: s=20.20.20.1 (Serial0), d=10.10.10.1, len 100, rcvd 4
00:18:41: IP: tableid=0, s=10.10.10.1 (local), d=20.20.20.1 (Serial0), routed via RIB
00:18:41: IP: s=10.10.10.1 (local), d=20.20.20.1 (Serial0), len 100, sending
00:18:41: IP: tableid=0, s=20.20.20.1 (Serial0), d=10.10.10.1 (Ethernet0), routed via RIB
00:18:41: IP: s=20.20.20.1 (Serial0), d=10.10.10.1, len 100, rcvd 4
00:18:41: IP: tableid=0, s=10.10.10.1 (local), d=20.20.20.1 (Serial0), routed via RIB
00:18:41: IP: s=10.10.10.1 (local), d=20.20.20.1 (Serial0), len 100, sending
00:18:41: IP: tableid=0, s=20.20.20.1 (Serial0), d=10.10.10.1 (Ethernet0), routed via RIB
00:18:41: IP: s=20.20.20.1 (Serial0), d=10.10.10.1, len 100, rcvd 4
R1#u all
All possible debugging has been turned off
R1#traceroute 20.20.20.1
Type escape sequence to abort.
Tracing the route to 20.20.20.1
1 131.108.1.2 16 msec 16 msec *
Is there something wrong with the configuration?
Here’s another clue. I remove the ip policy route-map from the Ethernet0 and put ip local policy route-map globally.
R1#sh run ! hostname R1 ! interface Ethernet0 ip address 10.10.10.1 255.255.255.0 ! interface Serial0 ip address 131.108.1.1 255.255.255.252 no fair-queue clockrate 56000 ! interface Serial1 ip address 131.108.1.5 255.255.255.252 clockrate 56000 ! router bgp 1 bgp log-neighbor-changes network 10.10.10.0 mask 255.255.255.0 neighbor 131.108.1.2 remote-as 2 neighbor 131.108.1.6 remote-as 2 ! ip local policy route-map FROM-10.10.10.1-TO-20.20.20.1 ! access-list 100 permit icmp host 10.10.10.1 host 20.20.20.1 route-map FROM-10.10.10.1-TO-20.20.20.1 permit 10 match ip address 100 set ip next-hop 131.108.1.6 ! end
R2#sh run ! hostname R2 ! interface Ethernet0 ip address 20.20.20.1 255.255.255.0 ! interface Serial0 ip address 131.108.1.2 255.255.255.252 no fair-queue ! interface Serial1 ip address 131.108.1.6 255.255.255.252 ! router bgp 2 bgp log-neighbor-changes network 20.20.20.0 mask 255.255.255.0 neighbor 131.108.1.1 remote-as 1 neighbor 131.108.1.5 remote-as 1 ! ip local policy route-map FROM-20.20.20.1-TO-10.10.10.1 ! access-list 100 permit icmp host 20.20.20.1 host 10.10.10.1 route-map FROM-20.20.20.1-TO-10.10.10.1 permit 10 match ip address 100 set ip next-hop 131.108.1.4 ! end
Now the ICMP packet can be routed through R1E0-R1S1-R2S1-R2E0.
R1#debug ip policy Policy routing debugging is on R1#ping Protocol [ip]: Target IP address: 20.20.20.1 Repeat count [5]: Datagram size [100]: Timeout in seconds [2]: Extended commands [n]: y Source address or interface: 10.10.10.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 20.20.20.1, timeout is 2 seconds: Packet sent with a source address of 10.10.10.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 52/52/52 ms 00:43:18: IP: s=10.10.10.1 (local), d=20.20.20.1, len 100, policy match 00:43:18: IP: route map FROM-10.10.10.1-TO-20.20.20.1, item 10, permit 00:43:18: IP: s=10.10.10.1 (local), d=20.20.20.1 (Serial1), len 100, policy routed 00:43:18: IP: local to Serial1 131.108.1.6 00:43:18: IP: s=10.10.10.1 (local), d=20.20.20.1, len 100, policy match 00:43:18: IP: route map FROM-10.10.10.1-TO-20.20.20.1, item 10, permit 00:43:18: IP: s=10.10.10.1 (local), d=20.20.20.1 (Serial1), len 100, policy routed 00:43:18: IP: local to Serial1 131.108.1.6 00:43:18: IP: s=10.10.10.1 (local), d=20.20.20.1, len 100, policy match 00:43:18: IP: route map FROM-10.10.10.1-TO-20.20.20.1, item 10, permit 00:43:18: IP: s=10.10.10.1 (local), d=20.20.20.1 (Serial1), len 100, policy routed 00:43:18: IP: local to Serial1 131.108.1.6 00:43:18: IP: s=10.10.10.1 (local), d=20.20.20.1, len 100, policy match 00:43:18: IP: route map FROM-10.10.10.1-TO-20.20.20.1, item 10, permit 00:43:18: IP: s=10.10.10.1 (local), d=20.20.20.1 (Serial1), len 100, policy routed 00:43:18: IP: local to Serial1 131.108.1.6 00:43:18: IP: s=10.10.10.1 (local), d=20.20.20.1, len 100, policy match 00:43:18: IP: route map FROM-10.10.10.1-TO-20.20.20.1, item 10, permit 00:43:18: IP: s=10.10.10.1 (local), d=20.20.20.1 (Serial1), len 100, policy routed 00:43:18: IP: local to Serial1 131.108.1.6 R1#u all All possible debugging has been turned off R1#debug ip packet IP packet debugging is on R1#ping Protocol [ip]: Target IP address: 20.20.20.1 Repeat count [5]: Datagram size [100]: Timeout in seconds [2]: Extended commands [n]: y Source address or interface: 10.10.10.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 20.20.20.1, timeout is 2 seconds: Packet sent with a source address of 10.10.10.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 44/44/44 ms 00:43:49: IP: tableid=0, s=20.20.20.1 (Serial1), d=10.10.10.1 (Ethernet0), routed via RIB 00:43:49: IP: s=20.20.20.1 (Serial1), d=10.10.10.1, len 100, rcvd 4 00:43:49: IP: tableid=0, s=20.20.20.1 (Serial1), d=10.10.10.1 (Ethernet0), routed via RIB 00:43:49: IP: s=20.20.20.1 (Serial1), d=10.10.10.1, len 100, rcvd 4 00:43:49: IP: tableid=0, s=20.20.20.1 (Serial1), d=10.10.10.1 (Ethernet0), routed via RIB 00:43:49: IP: s=20.20.20.1 (Serial1), d=10.10.10.1, len 100, rcvd 4 00:43:49: IP: tableid=0, s=20.20.20.1 (Serial1), d=10.10.10.1 (Ethernet0), routed via RIB 00:43:49: IP: s=20.20.20.1 (Serial1), d=10.10.10.1, len 100, rcvd 4 00:43:50: IP: tableid=0, s=20.20.20.1 (Serial1), d=10.10.10.1 (Ethernet0), routed via RIB 00:43:50: IP: s=20.20.20.1 (Serial1), d=10.10.10.1, len 100, rcvd 4 00:43:52: IP: s=131.108.1.2 (Serial0), d=131.108.1.1, len 59, rcvd 0 00:43:52: IP: tableid=0, s=131.108.1.1 (local), d=131.108.1.2 (Serial0), routed via RIB 00:43:52: IP: s=131.108.1.2 (Serial0), d=131.108.1.1, len 40, rcvd 0 00:43:55: IP: tableid=0, s=131.108.1.5 (local), d=131.108.1.6 (Serial1), routed via RIB 00:43:55: IP: s=131.108.1.6 (Serial1), d=131.108.1.5, len 59, rcvd 0 00:43:55: IP: tableid=0, s=131.108.1.5 (local), d=131.108.1.6 (Serial1), routed via RIB
Why can’t I use ip policy route-map on the interface yet I have to use ip LOCAL policy route-map to do this?
Can somebody help me? All comments will be much appreciated.
January 23rd, 2007 at 9:01 pm
ip local policy = for traffic generated by the router itself, in your test you tried to ping from the router and not from the client…
the ip policy route-map will work for all traffic from the clients behind the router
January 23rd, 2007 at 9:15 pm
[tripleH] Tried that using a host connected to R1E0. No Luck.
January 23rd, 2007 at 10:50 pm
There is no significant configuration error.
The route map did not take effect in the first configuration.
Reason: The policy only works on the router interface where it is applied to. The ping test was condected in R1 and the traffic did not pass that interface. So the policy did not work in your test run.
In the second configuration, the local policy works for the whole route, not the certain interface (Global command). That was why you could see it did work.
Also, don’t forget use sh access-list to verify the access-list and check whether the route-map is working.
January 24th, 2007 at 12:04 am
Ricky and TripleH were right.
IP LOCAL POLICY matches any packets doesn’t matter where it was originated.
IP POLICY matched any packets particularly to the applied interface and NOT from the router itself.
Basically what I tried was attaching another router to R1E0 and did ping 20.20.20.1. From the R1, I got these matched packets.
Oh, BTW, I need to change the access-list on R1 to
access-list 100 permit icmp 10.10.10.0 0.0.0.255 host 20.20.20.1. You can change the access-list on R2 as well.However, when I checked the using
traceroute. It was still using path 131.108.1.1-131.108.1.2.Before, I thought that
traceroutewas only using ICMP packet to determine path. Richard Stevens, on his book, TCP/IP Illustrated, Volume 1, page 98, explained that:So, basically he was trying to say that
tracerouteprogram uses the combination of ICMP and UDP to reach its destination.Knowing it also uses UDP, we need to ammend the access-list to permit UDP packets as well.
Now test the
tracerouteagain.Voila!, it is now using 131.108.1.6. Looking at R1
debug ip policygives more assurance.Thanks to TripleH and Rick!
CASE CLOSED
January 24th, 2007 at 1:14 am
“… he [Richard Stevens] was trying to say that traceroute program uses the combination of ICMP and UDP to reach its destination”
That’s true for the original Unix-y version of traceroute. The later Windows-y version (aka tracert) uses ICMP echo requests (pings) as the probe packets rather than UDP packets.
January 29th, 2007 at 12:45 pm
I’m not master in cisco, but I will try to explain about traceroute. Yes, correct! Most of the traceroute programs are using UDP to check each hop status instead of ICMP. But the tracert command in windows is still using ICMP. You also can use -I option in unix to do a traceroute by using ICMP. For traceroute command under cisco IOS, I dont know how to set it using ICMP.
I blog this stuff last week. please check my blog http://fajri.freebsd.or.id/index.php/2007/01/26/traceroute/
August 8th, 2008 at 8:43 am
“IP LOCAL POLICY matches any packets doesn’t matter where it was originated.”
This is actually not true. The local policy only matches on traffic that is generated by the local router.