This is a little trick you can use to force outgoing traffic via one particular IP address on a server. By default, if your server has multiple IPs, it’ll use the default IP address for any outgoing traffic.
However, if you’re changing IP addresses or testing failovers, you might want to force traffic to leave your server as if it’s coming from one of the other IP addresses. That way, upstream switches learn your server has this IP address and they can update their ARP caches.
ping
allows you to do that very easily (sending ICMP traffic).
$ ping 8.8.8.8 -I 10.0.1.4
The -I
parameter sets the interface via which packets should be sent, it can accept either an interface name (like eth1
) or an IP address. This way, traffic leaves your server with srcip 10.0.1.4
.
Docs describe -I
like this;
-I interface address Set source address to specified interface address. Argument may be numeric IP address or name of device. When pinging IPv6 link-local address this option is required.
So works for both individual IP addresses as well as interfaces.