I need to capture the traffic while I connect to a given host from ruby. I'm using Open3.popen3
in combination with tcpdump
for that (I can safely assume I have tcpdump
in my running environment and that I have the privileges to capture packets). The only missing piece is that I need to provide the name of the interface I need to sniff, and I don't know which interface will take me to the desired IP address.
This kind of information is provided by system utilities such as ip
or route
, but I am seeking a platform-independent (still in the realm of Unix, but not exclusively Linux, e.g. FreeBSD) solution that does not require me to write code to support all versions of these utilities.
I looked in the neighborhood of Socket
, but could not find anything useful.
Does ruby offer such functionality?