I'm making an script, and I need to detect in what interface is the traffic of an IP going through. This is because in the arch, an IP address is attended only for one of four NIC's, but can be any of those four.
The manual way I did is running a tcpdump: if I see packets, then this is the interface; if not, cancel tcpdump, and do another tcpdump on another interface.
I'm running FreeBSD.
route -n
?route -n
don't let me to know packets going on an interface, only changes of routingiftop
?