I have searched everywhere but their solution requires some form of IP address. Here are the solutions i have found.
require \'socket\' #METHOD 1 ip
parse the output of the ip command?
ip
from https://gist.github.com/henriquemenezes/a99f13da957515023e78aea30d6c0a48
gw = `ip route show`[/default.*/][/\d+\.\d+\.\d+\.\d+/]
or parse the output of the ipconfig command: https://stackoverflow.com/a/12632929/32453
ipconfig