Skip to content

Instantly share code, notes, and snippets.

@henriquemenezes
Created April 1, 2016 14:32
Show Gist options
  • Save henriquemenezes/a99f13da957515023e78aea30d6c0a48 to your computer and use it in GitHub Desktop.
Save henriquemenezes/a99f13da957515023e78aea30d6c0a48 to your computer and use it in GitHub Desktop.
Get default gateway IP in Ruby
gw = `ip route show`[/default.*/][/\d+\.\d+\.\d+\.\d+/]
@maxadamo
Copy link

maxadamo commented Mar 23, 2020

you can also have multiple GW and this command will explode: you get a multiline string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment