2

In a typical Cisco router it's possible to ping a host from the router's OS. When the ping packet leaves router (call it R1) through the fa0/0 interface, the source IP of that packet it set to the IP of fa0/0, right?

Is it possible to specify the interface of R1 I want the ping packet to go through? Different interfaces = different source IPs.

I know that usually there's only one way to the destination, but still. I'm not even sure if it's possible, because we would need to somehow make the router ignore its routing table - simply because the routing table gives a router exact information where to send the packet to, there can't be two 'matching' entries with identical priority in the table.

1

You can set the source of the ping, but the direction is determined by the routing table and rules configured in the router.

You can use PBR to override the routing table, but that does affect the routing speed since it must be done in software. Also, it doesn't scale, and you can end up with routing loops.

  • But am I correct saying that by default, the source IP of my ping packet is set to the IP of the interface on the router that my packet is going through? – user4205580 Dec 9 '15 at 18:02
  • Yes. By default, the source IP address in an IP packet originated on the router is the router interface where the packet exits the router. You can override that in a ping command, but it doesn't change which interface the packets use to exit the router. There are also some commands that will set the default source interface for various things (e.g. NTP) so that you could use a loopback as the source, regardless of the interface which the packets actually use. – Ron Maupin Dec 9 '15 at 18:07
1

Let's say you have two interfaces:

Fa0/0: 192.168.0.1/24
Fa0/1: 10.0.0.1/8

The destination (who you want to ping) is 5.5.5.5 and the egress interface is Fa0/0 by default. You can add a static route:

ip route 5.5.5.5 255.255.255.255 Fa0/1

Now if you ping 5.5.5.5 it will egress though your Fa0/1 interface.

0

You can use extended ping as mentioned by another user, or you can specify it in the ping command like this:

ping source

Ex: ping 172.16.0.1 source gi5/2 or ping 172.16.0.1 source 172.16.200.1

  • That won't change the interface which the packets go through, and that is the question. – Ron Maupin Dec 9 '15 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.