Can I make ruby send network traffic over a specific iface?
- by rjorgenson
I am writing a script that grabs the external IP address along with some other information about each iface. I can't figure out how to make ruby send traffic over a specific iface(eth0 and wlan0 for example). I am currently using the open-uri library to open http://whatismyip.org and read it into a variable.
def get_external_ip
begin
open("http://whatismyip.org") { |f| return f.read }
rescue
return "none"
end
end
Is there any way to specify this at runtime of the script or from within the script itself(ideally)?