Programmatically determine which eth0:x interfaces is requesting data
I have edited the /etc/network/interfaces file to provide me with several eth0:x interfaces. Now I want to programmatically determine which interface or IP address a request is coming through.
For example; I have eth0:1 = 192.168.227.205 and eth0:2 = 192.168.227.206
From my laptop I can ping either address.
In linux I want to run a program that responds differently based on the IP address being hit. If .205 do this if .206 do that.
How can I programmatically determine which IP address is being hit?